Skip to content

Instantly share code, notes, and snippets.

@jokeofweek
Created November 10, 2012 19:00
Show Gist options
  • Save jokeofweek/4052140 to your computer and use it in GitHub Desktop.
Save jokeofweek/4052140 to your computer and use it in GitHub Desktop.
Trie iterator
for (String word : list) {
if (!otherTrie.matchPrefix(trie.getPrefix(word)))
System.out.println("matchPrefix Error for word " + word + " ");
List<String> otherTrieResult = otherTrie.findCompletions(word);
List<String> trieResult = trie.getAllPrefixMatches(word);
if (!(otherTrieResult.containsAll(trieResult) && trieResult
.containsAll(otherTrieResult))) {
throw new RuntimeException("autocomplete " + word + " ");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment