Package com.palmergames.util
Class Trie
java.lang.Object
com.palmergames.util.Trie
Dynamic trie structure that can add/remove keys and recursively get matching strings for a key
- Author:
- stzups
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
TrieNode implementation that handles any character and keeps track of its own children and character -
Constructor Summary
-
Method Summary
-
Constructor Details
-
Trie
public Trie()Constructor that creates a new trie with a null root
-
-
Method Details
-
addKey
Adds and links new TrieNodes to the trie for each character in the string- Parameters:
key
- key to add to trie, can be longer than one character
-
removeKey
Removes TrieNodes for a key- Parameters:
key
- key to remove
-
getStringsFromKey
Gets all matching strings and their children for a key- Parameters:
key
- string to search for in tree- Returns:
- matching strings and their children
-