@Test public void testGetKeysEndingWith() throws Exception { ConcurrentSuffixTree<Integer> tree = newConcurrentSuffixTreeForUnitTests(); tree.put("BANANA", 1); tree.put("BANDANA", 2); assertEquals("[BANANA, BANDANA]", Iterables.toString(tree.getKeysEndingWith("ANA"))); assertEquals("[BANDANA]", Iterables.toString(tree.getKeysEndingWith("DANA"))); assertEquals("[]", Iterables.toString(tree.getKeysEndingWith("BAN"))); assertEquals("[]", Iterables.toString(tree.getKeysEndingWith(""))); }
@Override public Iterable<CharSequence> getKeysEndingWith(CharSequence suffix) { Set<? extends CharSequence> originalKeys = radixTree.getValueForExactKey(suffix); if (originalKeys == null) { return Collections.emptySet(); } @SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"}) Set<CharSequence> results = (Set<CharSequence>) originalKeys; return results; }
ConcurrentSuffixTree implements SuffixTree<O>, PrettyPrintable, Serializable { @Override public Iterable<CharSequence> getKeysEndingWith(CharSequence suffix) { Set<? extends CharSequence> originalKeys = radixTree.getValueForExactKey(suffix); if (originalKeys == null) { return Collections.emptySet(); } @SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"}) Set<CharSequence> results = (Set<CharSequence>) originalKeys; return results; } }
ConcurrentSuffixTree implements SuffixTree<O>, PrettyPrintable, Serializable { @Override public Iterable<CharSequence> getKeysEndingWith(CharSequence suffix) { Set<? extends CharSequence> originalKeys = radixTree.getValueForExactKey(suffix); if (originalKeys == null) { return Collections.emptySet(); } @SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"}) Set<CharSequence> results = (Set<CharSequence>) originalKeys; return results; } ConcurrentSuffixTree(NodeFactory nodeFactory); }
ConcurrentSuffixTree implements SuffixTree<O>, PrettyPrintable, Serializable { @Override public Iterable<CharSequence> getKeysEndingWith(CharSequence suffix) { Set<? extends CharSequence> originalKeys = radixTree.getValueForExactKey(suffix); if (originalKeys == null) { return Collections.emptySet(); } @SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"}) Set<CharSequence> results = (Set<CharSequence>) originalKeys; return results; } 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<CharSequence> getKeysEndingWith(CharSequence suffix) { Set<? extends CharSequence> originalKeys = radixTree.getValueForExactKey(suffix); if (originalKeys == null) { return Collections.emptySet(); } @SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"}) Set<CharSequence> results = (Set<CharSequence>) originalKeys; return results; } 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();  }