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

17
LINES

< > BotCompany Repo | #1029647 // conceptsWithFieldLessThan

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

Libraryless. Click here for Pure Java version (13630L/92K).

// tries to use index if possible
// result is sorted if index was used
// result is always an independent collection
static <A extends Concept> Cl<A> nuLike conceptsWithFieldLessThan (Class<A> c, S field, O value) {
  ret conceptsWithFieldLessThan(db_mainConcepts(), c, field, value);
}

static <A extends Concept> Cl<A> conceptsWithFieldLessThan(Concepts concepts, Class<A> c, S field, O value) {
  // indexed
  IFieldIndex<A, O> index = concepts.getFieldIndex(c, field);
  if (index cast ConceptFieldIndexDesc) synchronized(index.mutex()) { 
    ret reverseInPlace(concatLists(values(((NavigableMap) index.valueToObject.data).tailMap(value, false))));
  }
    
  // filter manually
  ret filter(concepts.list(c), o -> cmp(getOpt(o, field), value) < 0);
}

Author comment

Began life as a copy of #1026015

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: #1029647
Snippet name: conceptsWithFieldLessThan
Eternal ID of this version: #1029647/8
Text MD5: 1b511f497d3645c5f6ee4751ff00c042
Transpilation MD5: 849d6d2f8791a2b24c8857f255ab39ba
Author: stefan
Category: javax / concepts
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-09-04 20:59:20
Source code size: 773 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 178 / 289
Version history: 7 change(s)
Referenced in: [show references]