Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

17
LINES

< > BotCompany Repo | #1026015 // conceptsSortedByField - try to use index if possible

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (13031L/88K).

1  
sbool conceptsSortedByField_verbose;
2  
3  
static <A extends Concept> Cl<A> nuLike conceptsSortedByField(Class<A> c, S field) {
4  
  ret conceptsSortedByField(db_mainConcepts(), c, field);
5  
}
6  
7  
static <A extends Concept> Cl<A> conceptsSortedByField(Concepts concepts, Class<A> c, S field) {
8  
  // indexed
9  
  IFieldIndex<A, O> index = concepts.getFieldIndex(c, field);
10  
  if (index cast ConceptFieldIndexDesc)
11  
    ret reverseInPlace(asList(index.objectIterator()));
12  
    
13  
  // sort manually
14  
  if (conceptsSortedByField_verbose)
15  
    print("conceptsSortedByField_verbose: Manual sort of " + c + " for " + field);
16  
  ret sortedByField(field, concepts.list(c));
17  
}

Author comment

Began life as a copy of #1025936

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1026015
Snippet name: conceptsSortedByField - try to use index if possible
Eternal ID of this version: #1026015/3
Text MD5: 7ec877af50019ac0c4e51c45d418d2c1
Transpilation MD5: ea2bb29a55741ee53f11883877598b86
Author: stefan
Category: javax / concepts
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-11-07 15:00:22
Source code size: 659 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 309 / 436
Version history: 2 change(s)
Referenced in: [show references]