Package org.naviqore.utils.search
Class CompressedTrie<T>
java.lang.Object
org.naviqore.utils.search.CompressedTrie<T>
- All Implemented Interfaces:
Trie<T>
A trie data structure that compresses the edges. It allows for efficient storage and retrieval of strings and their
associated values.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetNodes()Retrieves all nodes currently in the Trie.voidInserts a value into the Trie associated with a specific key.intsize()Gets the number of unique keys in the Trie.startsWith(String prefix) Searches for all values associated with keys that start with the given prefix.voidReduces the memory footprint by trimming the capacity of node internal data structures.
-
Constructor Details
-
CompressedTrie
public CompressedTrie()
-
-
Method Details
-
insert
Description copied from interface:TrieInserts a value into the Trie associated with a specific key. If the key already exists, the value is added to the list of values for that key, allowing for duplicate values under the same key. -
startsWith
Description copied from interface:TrieSearches for all values associated with keys that start with the given prefix. If no values are found, returns an empty list.- Specified by:
startsWithin interfaceTrie<T>- Parameters:
prefix- the prefix of the key to search for.- Returns:
- a list of values whose keys start with the given prefix.
-
getNodes
Description copied from interface:TrieRetrieves all nodes currently in the Trie. -
size
public int size()Description copied from interface:TrieGets the number of unique keys in the Trie. -
trimToSize
public void trimToSize()Reduces the memory footprint by trimming the capacity of node internal data structures.
-