@Test public void testGetValuesForKeysEndingWith() throws Exception { ConcurrentSuffixTree<Integer> tree = newConcurrentSuffixTreeForUnitTests(); tree.put("BANANA", 1); tree.put("BANDANA", 2); assertEquals("[1, 2]", Iterables.toString(tree.getValuesForKeysEndingWith("ANA"))); assertEquals("[2]", Iterables.toString(tree.getValuesForKeysEndingWith("DANA"))); assertEquals("[]", Iterables.toString(tree.getValuesForKeysEndingWith("BAN"))); assertEquals("[]", Iterables.toString(tree.getValuesForKeysEndingWith(""))); }
@Override public Iterable<O> getValuesForKeysEndingWith(final CharSequence suffix) { return new Iterable<O>() { @Override public Iterator<O> iterator() { return new LazyIterator<O>() { Iterator<String> originalKeys = nullSafeIterator(radixTree.getValueForExactKey(suffix)); @Override protected O computeNext() { O value = null; while (value == null) { if (!originalKeys.hasNext()) { return endOfData(); } String originalKey = originalKeys.next(); value = valueMap.get(originalKey); } return value; } }; } }; }
ConcurrentSuffixTree implements SuffixTree<O>, PrettyPrintable, Serializable { @Override public Iterable<O> getValuesForKeysEndingWith(final CharSequence suffix) { return new Iterable<O>() { @Override public Iterator<O> iterator() { return new LazyIterator<O>() { Iterator<String> originalKeys = nullSafeIterator(radixTree.getValueForExactKey(suffix)); @Override protected O computeNext() { O value = null; while (value == null) { if (!originalKeys.hasNext()) { return endOfData(); } String originalKey = originalKeys.next(); value = valueMap.get(originalKey); } return value; } }; } }; } }
ConcurrentSuffixTree implements SuffixTree<O>, PrettyPrintable, Serializable { @Override public Iterable<O> getValuesForKeysEndingWith(final CharSequence suffix) { return new Iterable<O>() { @Override public Iterator<O> iterator() { return new LazyIterator<O>() { Iterator<String> originalKeys = nullSafeIterator(radixTree.getValueForExactKey(suffix)); @Override protected O computeNext() { O value = null; while (value == null) { if (!originalKeys.hasNext()) { return endOfData(); } String originalKey = originalKeys.next(); value = valueMap.get(originalKey); } return value; } }; } }; } ConcurrentSuffixTree(NodeFactory nodeFactory); }
ConcurrentSuffixTree implements SuffixTree<O>, PrettyPrintable, Serializable { @Override public Iterable<O> getValuesForKeysEndingWith(final CharSequence suffix) { return new Iterable<O>() { @Override public Iterator<O> iterator() { return new LazyIterator<O>() { Iterator<String> originalKeys = nullSafeIterator(radixTree.getValueForExactKey(suffix)); @Override protected O computeNext() { O value = null; while (value == null) { if (!originalKeys.hasNext()) { return endOfData(); } String originalKey = originalKeys.next(); value = valueMap.get(originalKey); } return 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(); }
ConcurrentSuffixTree implements SuffixTree<O>, PrettyPrintable, Serializable { @Override public Iterable<O> getValuesForKeysEndingWith(final CharSequence suffix) { return new Iterable<O>() { @Override public Iterator<O> iterator() { return new LazyIterator<O>() { Iterator<String> originalKeys = nullSafeIterator(radixTree.getValueForExactKey(suffix)); @Override protected O computeNext() { O value = null; while (value == null) { if (!originalKeys.hasNext()) { return endOfData(); } String originalKey = originalKeys.next(); value = valueMap.get(originalKey); } return 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();  }