ConcurrentSuffixTree implements SuffixTree<O>, PrettyPrintable, Serializable { @Override public Iterable<KeyValuePair<O>> getKeyValuePairsForKeysEndingWith(final CharSequence suffix) { return new Iterable<KeyValuePair<O>>() { @Override public Iterator<KeyValuePair<O>> iterator() { return new LazyIterator<KeyValuePair<O>>() { Iterator<String> originalKeys = nullSafeIterator(radixTree.getValueForExactKey(suffix)); @Override protected KeyValuePair<O> computeNext() { String originalKey = null; O value = null; while (value == null) { if (!originalKeys.hasNext()) { return endOfData(); } originalKey = originalKeys.next(); value = valueMap.get(originalKey); } return new ConcurrentRadixTree.KeyValuePairImpl<O>(originalKey, value); } }; } }; } ConcurrentSuffixTree(NodeFactory nodeFactory); @Override O put(CharSequence key, O value); @Override O putIfAbsent(CharSequence key, O value); @Override boolean remove(CharSequence key); @Override O getValueForExactKey(CharSequence key); @Override Iterable<CharSequence> getKeysEndingWith(CharSequence suffix); @Override Iterable<O> getValuesForKeysEndingWith(final CharSequence suffix); @Override Iterable<KeyValuePair<O>> getKeyValuePairsForKeysEndingWith(final CharSequence suffix); @Override Iterable<CharSequence> getKeysContaining(final CharSequence fragment); @Override Iterable<O> getValuesForKeysContaining(final CharSequence fragment); @Override Iterable<KeyValuePair<O>> getKeyValuePairsForKeysContaining(final CharSequence fragment); @Override int size(); @Override Node getNode();  }
@Test public void testGetKeyValuePairsForKeysEndingWith() throws Exception { ConcurrentSuffixTree<Integer> tree = newConcurrentSuffixTreeForUnitTests(); tree.put("BANANA", 1); tree.put("BANDANA", 2); assertEquals("[(BANANA, 1), (BANDANA, 2)]", Iterables.toString(tree.getKeyValuePairsForKeysEndingWith("ANA"))); assertEquals("[(BANDANA, 2)]", Iterables.toString(tree.getKeyValuePairsForKeysEndingWith("DANA"))); assertEquals("[]", Iterables.toString(tree.getKeyValuePairsForKeysEndingWith("BAN"))); assertEquals("[]", Iterables.toString(tree.getKeyValuePairsForKeysEndingWith(""))); }