The type of values stored in the trie-map.
Makes the TrieMap iterable.
Entries are yielded in their insertion order by default.
Optionalreversed: boolean = falseOptional boolean to reverse iteration order.
An iterator for the trie-map's entries.
const trieMap = new TrieMap([
['apple', 1],
['lemon', 2],
['orange', 3],
]);
// Forward iteration
for (const [word, value] of trieMap) {
console.log(`${word}: ${value}`);
}
// Output:
// apple: 1
// lemon: 2
// orange: 3
// Reverse iteration
for (const [word, value] of trieMap[Symbol.iterator](true)) {
console.log(`${word}: ${value}`);
}
// Output:
// orange: 3
// lemon: 2
// apple: 1
Removes an entry from the trie-map.
The key of the entry to remove.
true if the entry was found and removed, false if not found.
Returns an iterator of all entries in the trie-map.
Entries are yielded in their insertion order by default.
Optionalreversed: boolean = falseOptional boolean to reverse iteration order.
An iterator of the trie-map's entries.
const trieMap = new TrieMap([
['apple', 1],
['lemon', 2],
['orange', 3]
]);
// Forward order
for (const [word, value] of trieMap.entries()) {
console.log(`${word}: ${value}`);
}
// Output:
// apple: 1
// lemon: 2
// orange: 3
// Reverse iteration
for (const [word, value] of trieMap.entries(true)) {
console.log(`${word}: ${value}`);
}
// Output:
// orange: 3
// lemon: 2
// apple: 1
Finds all entries whose keys start with the given prefix.
The prefix to search for.
An array of matching [word, value] pairs.
Executes a callback for each entry in the trie-map.
Retrieves the value associated with a given key.
The key to look up.
The associated value if found, undefined otherwise.
Checks if an entry with the specified key exists in the trie-map.
The key to check.
true if an entry with the key exists, false otherwise.
Returns an iterator of all keys in the trie-map.
Keys are yielded in their entries' insertion order.
Optionalreversed: boolean = falseOptional boolean to reverse iteration order.
An iterator of the trie-map's keys.
Adds or updates an entry in the trie-map.
If the key already exists, its value is updated but its position in iteration order remains unchanged.
The key for the entry.
The value to associate with the key.
Returns an iterator of all values in the trie-map.
Values are yielded in their corresponding entries' insertion order.
Optionalreversed: boolean = falseOptional boolean to reverse iteration order.
An iterator of the trie-map's values.
A trie-based map implementation that extends
AbstractTrieMap. Associates values with string keys (words) while preserving key lookup efficiency.Example