transient sclass DoubleWordIndex {
new WordIndex index1; // forwards (normal words)
new WordIndex index2; // backwards (reversed words)
*() {}
*(Comparator valueComparator) {
index1 = new WordIndex(valueComparator);
index2 = new WordIndex(valueComparator);
}
*(Map map) { fOr (A a, S text : map) add(a, text); }
void add(A a, S text) {
Set 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 get(S word) {
ret index1.get(word);
}
Set extractWords(S text) {
ret index1.extractWords(text);
}
L wordRanges(S text) {
ret index1.wordRanges(text);
}
int numWords() { ret index1.numWords(); }
}