AbstractAbstractsizeGets the number of words stored in the trie.
The total count of words.
Abstract[iterator]Makes the AbstractTrie iterable.
If true, words are yielded in reverse insertion order.
An iterator for the trie's entries.
AbstractaddAdds a word to the trie. If the word already exists, it will not create duplicates and the original insertion order is preserved.
The word to add.
AbstractclearRemoves all words from the trie, resetting it to an empty state.
AbstractdeleteRemoves a word from the trie.
The word to remove.
true if the word was found and removed, false if not found.
AbstractentriesReturns an iterator for the words in the trie.
If true, words are yielded in reverse insertion order.
An iterator of the trie's entries.
AbstractfindFinds all words that start with the given prefix.
The prefix to search for.
An array of matching words.
AbstractforExecutes a callback function for each word in the trie.
The word of the current entry.
The trie instance being traversed.
OptionalthisArg: anyAbstracthasChecks if a word exists in the trie.
The word to check.
true if the exact word exists, false otherwise.
Abstract base class for implementing trie (prefix tree) data structures. Provides the core interface for storing and retrieving strings efficiently.
A trie is a tree-like data structure that enables fast string operations by storing characters as nodes, where all descendants share a common prefix.
Example