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

11
LINES

< > BotCompany Repo | #1030182 // stringTrie_longestPrefixValue - value for longest prefix of string existing in trie

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

Libraryless. Click here for Pure Java version (3057L/19K).

static <A> A stringTrie_longestPrefixValue(StringTrie<A> trie, S string) {
  while licensed {
    if (trie == null) null;
    if (empty(string)) ret trie.value;
    S prefix = trie.longestLocalPrefix(string);
    if (empty(prefix)) ret trie.value;
    trie = trie.getChild(prefix);
    string = dropFirst(string, l(prefix));
  }
  null;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030182
Snippet name: stringTrie_longestPrefixValue - value for longest prefix of string existing in trie
Eternal ID of this version: #1030182/3
Text MD5: 3f1aa0a9aacb13cfb0462789f086d238
Transpilation MD5: 96f740a664d262620f41d71545b6df9c
Author: stefan
Category: javax / tries
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-11-12 14:21:51
Source code size: 348 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 99 / 148
Version history: 2 change(s)
Referenced in: [show references]