Protected
Optional
_toThe converter used to transform a raw element (R
) into a public element (E
).
Protected
_total(Protected) Get total count for base class iteration.
Total number of elements.
Get whether comparisons are case-sensitive.
True if case-sensitive.
Get the number of stored words.
Word count.
Protected
_caseProtected
_create(Protected) Create an empty instance of the same concrete class.
Optional
options: TrieOptions<R>Options forwarded to the constructor.
An empty like-kind trie instance.
Protected
_createProtected
_getProtected
_spawnReturns an iterator over the structure's elements.
Rest
...args: unknown[]Optional iterator arguments forwarded to the internal iterator.
An IterableIterator<E>
that yields the elements in traversal order.
Insert many words from an iterable.
Iterable of strings (or raw records if toElementFn is provided).
Array of per-word 'added' flags.
Tests whether all elements satisfy the predicate.
Function invoked for each element with signature (value, index, self)
.
Optional
thisArg: unknownOptional this
binding for the predicate.
true
if every element passes; otherwise false
.
Filter words into a new trie of the same class.
Predicate (word, index, trie) → boolean to keep word.
Optional
thisArg: anyValue for this
inside the predicate.
A new trie containing words that satisfy the predicate.
Finds the first element that satisfies the predicate and returns it.
Finds the first element of type S
(a subtype of E
) that satisfies the predicate and returns it.
The matched element typed as S
, or undefined
if not found.
Invokes a callback for each element in iteration order.
Function invoked per element with signature (value, index, self)
.
Optional
thisArg: unknownOptional this
binding for the callback.
void
.
Collect words under a prefix up to a maximum count.
Optional
prefix: string = ''Prefix to match; default empty string for root.
Optional
max: number = Number.MAX_SAFE_INTEGERMaximum number of words to return; default is Number.MAX_SAFE_INTEGER.
Optional
isAllWhenEmptyPrefix: boolean = falseWhen true, collect from root even if prefix is empty.
Array of collected words (at most max).
Maps each element to a new element and returns a new iterable structure.
A new IterableElementBase<EM, RM>
containing mapped elements.
Map words into a new trie (possibly different record type).
A new Trie constructed from mapped words.
Map words into a new trie of the same element type.
Mapping function (word, index, trie) → string.
Optional
thisArg: anyValue for this
inside the callback.
A new trie with mapped words.
Tests whether at least one element satisfies the predicate.
Function invoked for each element with signature (value, index, self)
.
Optional
thisArg: unknownOptional this
binding for the predicate.
true
if any element passes; otherwise false
.
Prefix tree (Trie) for fast prefix queries and word storage.
Remarks
Time O(1), Space O(1)
Example
Example
Example
Example
Example