Makes the CompressedTrieMap
iterable.
Entries are yielded in their insertion order by default.
Optional
reversed: boolean = falseOptional boolean
to reverse iteration order.
An iterator for the compressed-trie-map's entries.
const trieMap = new CompressedTrieMap([
['apple', 1],
['lemon', 2],
['orange', 3]
]);
// Forward iteration
for (const [word, value] of trieMap) {
console.log(`${word}: ${value}`);
}
// Output:
// apple: 1
// lemon: 2
// orange: 2
// Reverse iteration
for (const [word, value] of trieMap[Symbol.iterator](true)) {
console.log(`${word}: ${value}`);
}
// Output:
// orange: 2
// lemon: 2
// apple: 1
Removes an entry from the compressed-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 compressed-trie-map.
Entries are yielded in their insertion order by default.
Optional
reversed: boolean = falseOptional boolean
to reverse iteration order.
An iterator of the compressed-trie-map's entries.
const trieMap = new CompressedTrieMap([
['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 compressed-trie-map.
The value of the current entry.
The word of the current entry.
The compressed-trie-map instance being traversed.
Optional
thisArg: anyRetrieves 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 compressed-trie-map.
The key to check.
true
if an entry with the key exists, false
otherwise.
Returns an iterator of all keys in the compressed-trie-map.
Keys are yielded in their entries' insertion order.
Optional
reversed: boolean = falseOptional boolean
to reverse iteration order.
An iterator of the compressed-trie-map's keys.
const trieMap = new CompressedTrieMap([
['apple', 1],
['lemon', 2],
['orange', 3]
]);
// Forward order
for (const key of trieMap.keys()) {
console.log(key);
}
// Output:
// apple
// lemon
// orange
// Reverse order
for (const key of trieMap.keys(true)) {
console.log(key);
}
// Output:
// orange
// lemon
// apple
Adds or updates an entry in the compressed-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 compressed-trie-map.
Values are yielded in their corresponding entries' insertion order.
Optional
reversed: boolean = falseOptional boolean
to reverse iteration order.
An iterator of the compressed-trie-map's values.
A memory-optimized trie-map implementation that extends
AbstractTrieMap
. Associates values with string keys (words) while preserving key-value lookup efficiency.Example