Libraryless. Click here for Pure Java version (3684L/23K).
transient sclass DoubleWordIndex<A> { new WordIndex<A> index1; // forwards (normal words) new WordIndex<A> index2; // backwards (reversed words) *() {} *(Comparator<A> valueComparator) { index1 = new WordIndex(valueComparator); index2 = new WordIndex(valueComparator); } *(Map<A, S> map) { fOr (A a, S text : map) add(a, text); } void add(A a, S text) { Set<S> words = extractWords(text); for (S word : words) addWord(a, word); } void addWord(A a, S word) { index1.addWord(a, word); index2.addWord(a, reversed(word)); } Set<A> get(S word) { ret index1.get(word); } Set<S> extractWords(S text) { ret index1.extractWords(text); } L<IntRange> wordRanges(S text) { ret index1.wordRanges(text); } int numWords() { ret index1.numWords(); } }
Began life as a copy of #1024242
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1029004 |
| Snippet name: | DoubleWordIndex - words indexed forwards and backwards |
| Eternal ID of this version: | #1029004/8 |
| Text MD5: | ff3a9c1ccb45f60c983f1500959080a9 |
| Transpilation MD5: | b7b527e20d901a68ea24edf87b3ef102 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-07-16 20:49:17 |
| Source code size: | 877 bytes / 38 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 435 / 791 |
| Version history: | 7 change(s) |
| Referenced in: | [show references] |