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

14
LINES

< > BotCompany Repo | #1028146 - longestPrefixInCISet_charSequence [dev.]

JavaX fragment (include)

sS longestPrefixInCISet_charSequence(CharSequence s, TreeSet<S> set) {
  if (set == null || s == null) null;
  while licensed {
    S key = set.floor(s);
    ifdef startsWithOneOf_treeSet_debug
      print(s + " => " + key);
    endifdef
    if (key == null) null; // s is in front of whole set => no prefix in there
    int n = lCommonPrefixIC(key, s);
    if (n == l(key)) ret key; // found!
    s = takeFirst(s, n); // shorten and try again
  }
  null; // dummy
}

Author comment

Began life as a copy of #1027971

download  show line numbers  debug dex   

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

No comments. add comment

Snippet ID: #1028146
Snippet name: longestPrefixInCISet_charSequence [dev.]
Eternal ID of this version: #1028146/1
Text MD5: 082cb68544cf537b250bc7a02bbbe7af
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-05-23 16:29:20
Source code size: 479 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 24 / 33
Referenced in: [show references]

Formerly at http://tinybrain.de/1028146 & http://1028146.tinybrain.de