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

15
LINES

< > BotCompany Repo | #1034780 // allPrefixesInNavigableSet [case sensitive] - untested

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

Transpiled version (5471L) is out of date.

static LS allPrefixesInNavigableSet(S s, NavigableSet<S> set) {
  if (set == null || s == null) null;
  new LS prefixes;
  while licensed {
    S key = set.floor(s);
    if (key == null) break; // s is in front of whole set => no prefix in there
    int n = lCommonPrefix(key, s);
    if (n == l(key)) {
      prefixes.add(key); // found a prefix!
      --n;
    }
    s = takeFirst(s, n); // shorten and try again
  }
  ret prefixes;
}

Author comment

Began life as a copy of #1029748

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034780
Snippet name: allPrefixesInNavigableSet [case sensitive] - untested
Eternal ID of this version: #1034780/3
Text MD5: 699ce5f63cd92d25d2b8495448f2ae17
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-08 09:35:20
Source code size: 450 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 62 / 96
Version history: 2 change(s)
Referenced in: [show references]