Libraryless. Click here for Pure Java version (3057L/19K).
1 | static <A> A stringTrie_longestPrefixValue(StringTrie<A> trie, S string) { |
2 | while licensed { |
3 | if (trie == null) null; |
4 | if (empty(string)) ret trie.value; |
5 | S prefix = trie.longestLocalPrefix(string); |
6 | if (empty(prefix)) ret trie.value; |
7 | trie = trie.getChild(prefix); |
8 | string = dropFirst(string, l(prefix)); |
9 | } |
10 | null; |
11 | } |
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: | 171 / 242 |
Version history: | 2 change(s) |
Referenced in: | [show references] |