Class ReversePrefixTrie
java.lang.Object
com.abstractkamen.datastructures.impl.trees.search.PrefixTrieImpl
com.abstractkamen.datastructures.impl.trees.search.ReversePrefixTrie
- All Implemented Interfaces:
- PrefixTrie,- SuffixTrie
This implementation uses the same insert/delete/search algorithm as the 
PrefixTrieImpl. In order to implement the
 SuffixTrie it reverses the input string. The cost of insert/delete/search is double that of the PrefixTrieImpl, but is
 still O(m) where m is the length of the input string.- 
Nested Class SummaryNested classes/interfaces inherited from class com.abstractkamen.datastructures.impl.trees.search.PrefixTrieImplPrefixTrieImpl.PrefixTrieNode
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleanDeletes a word from the trie.Try to find strings which end with suffix.booleanInserts a word into the trie.booleanChecks if prefix is present in this trie.booleanChecks if suffix is present in this trie.protected booleanPrefixTrieImpl.completeWordsdecrementing condition.startsWith(String prefix, int limit) Try to find strings which start with prefix.toString()protected voidvisitWordNode(PrefixTrieImpl.PrefixTrieNode node, StringBuilder visitor, StringBuilder currentChars) Visit a node which we know is a word.Methods inherited from class com.abstractkamen.datastructures.impl.trees.search.PrefixTrieImplcompleteWords, contains, delete, getRoot, insert, prettyString, search, sizeMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.abstractkamen.datastructures.api.trees.search.PrefixTriecompleteWords, contains, prettyString, size
- 
Constructor Details- 
ReversePrefixTriepublic ReversePrefixTrie()
 
- 
- 
Method Details- 
shouldDecrementWordOnDeleteDescription copied from class:PrefixTrieImplPrefixTrieImpl.completeWordsdecrementing condition. Can be overridden in extensions.- Overrides:
- shouldDecrementWordOnDeletein class- PrefixTrieImpl
- Parameters:
- n- word node
- Returns:
- true if PrefixTrieImpl.completeWordsshould be decremented
 
- 
visitWordNodeprotected void visitWordNode(PrefixTrieImpl.PrefixTrieNode node, StringBuilder visitor, StringBuilder currentChars) Description copied from class:PrefixTrieImplVisit a node which we know is a word.- Overrides:
- visitWordNodein class- PrefixTrieImpl
- Parameters:
- node- word node
- visitor- sb visitor
- currentChars- word so far
 
- 
insertDescription copied from interface:PrefixTrieInserts a word into the trie. Duplicate words will be ignored.- Specified by:
- insertin interface- PrefixTrie
- Overrides:
- insertin class- PrefixTrieImpl
- Parameters:
- string- word to be inserted
- Returns:
- true if the word was inserted false if it already existed
 
- 
deleteDescription copied from interface:PrefixTrieDeletes a word from the trie. The number of complete words will be decremented by one and the size of the trie will shrink by the number of unique characters and their placements in the deleted word if they aren't used by a different word.- Specified by:
- deletein interface- PrefixTrie
- Overrides:
- deletein class- PrefixTrieImpl
- Parameters:
- string- to be deleted
- Returns:
- true if word is successfully deleted false if word was not in the trie
 
- 
endsWithDescription copied from interface:SuffixTrieTry to find strings which end with suffix. Matching strings are always in arbitrary order.- Specified by:
- endsWithin interface- SuffixTrie
- Parameters:
- suffix- to look for
- limit- maximum number of found strings
- Returns:
- collection of words with the same suffix
 
- 
isSuffixDescription copied from interface:SuffixTrieChecks if suffix is present in this trie.- Specified by:
- isSuffixin interface- SuffixTrie
- Parameters:
- suffix- to check
- Returns:
- true if suffix exists
 
- 
isPrefixDescription copied from interface:PrefixTrieChecks if prefix is present in this trie.- Specified by:
- isPrefixin interface- PrefixTrie
- Overrides:
- isPrefixin class- PrefixTrieImpl
- Parameters:
- prefix- to check
- Returns:
- true if prefix exists
 
- 
startsWithDescription copied from interface:PrefixTrieTry to find strings which start with prefix. Matching strings are always in lexicographical order.- Specified by:
- startsWithin interface- PrefixTrie
- Overrides:
- startsWithin class- PrefixTrieImpl
- Parameters:
- prefix- to look for
- limit- maximum number of found strings
- Returns:
- collection of words with the same prefix
 
- 
toString- Overrides:
- toStringin class- PrefixTrieImpl
 
 
-