1 | // tok = CNC |
2 | // returns [(index, tree leaf)] |
3 | static LPair<Int, O> matchEndUsingWordTree_all(L<S> tok, Map<S, O> tree) {
|
4 | O best = null; // best leaf |
5 | int bestIndex = 0; // best index |
6 | |
7 | int j = l(tok)-2; |
8 | LPair<Int, O> out = new L; |
9 | while (j > 0) {
|
10 | O def = tree.get("<default>");
|
11 | if (def != null) { best = def; bestIndex = j; }
|
12 | |
13 | O t = tree.get(tok.get(j)); |
14 | if (t == null) break; |
15 | if (!t instanceof Map) break with addPair(out, j, t); // leaf! |
16 | j -= 2; |
17 | tree = (Map) t; |
18 | } |
19 | |
20 | if (best != null) addPair(out, bestIndex, best); |
21 | ret out; |
22 | } |
Began life as a copy of #1018097
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1018103 |
| Snippet name: | matchEndUsingWordTree_all - return all options |
| Eternal ID of this version: | #1018103/4 |
| Text MD5: | d4c3fdc7a8fa9134bbe6c73b4ce43ed4 |
| Author: | stefan |
| Category: | javax / a.i. |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-09-02 13:05:00 |
| Source code size: | 594 bytes / 22 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 570 / 617 |
| Version history: | 3 change(s) |
| Referenced in: | [show references] |