Libraryless. Click here for Pure Java version (3061L/19K).
1 | static <A> Pair<S, StringTrie<A>> stringTrie_firstNodeStartingWith(StringTrie<A> trie, S string) { |
2 | new StringBuilder buf; |
3 | S s = string; |
4 | while licensed { |
5 | if (trie == null) break; |
6 | if (empty(string)) break; |
7 | S prefix = trie.longestLocalPrefix(s); |
8 | if (empty(prefix)) break; |
9 | Map.Entry<S, StringTrie<A>> e = trie.children.ceilingEntry(prefix); |
10 | buf.append(e.getKey()); |
11 | trie = e.getValue(); |
12 | s = dropFirst(s, l(e.getKey())); |
13 | } |
14 | ret trie == null ? null : pair(str(buf), trie); |
15 | } |
Began life as a copy of #1030183
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1030184 |
Snippet name: | stringTrie_firstNodeStartingWith |
Eternal ID of this version: | #1030184/3 |
Text MD5: | 499d975dff89ea0f0b2faed1a4250d1f |
Transpilation MD5: | 19e06605c8c17752d3cd18a5b5019ab9 |
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:33:43 |
Source code size: | 522 bytes / 15 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 198 / 276 |
Version history: | 2 change(s) |
Referenced in: | [show references] |