Empty Root Trie that can be used for empty initiation
import { emptyTrie } from '@micham/trie-ts';
const trie = add("word", emptyTrie);
Check if word is in trie
import { add, has, of } from '@micham/trie-ts';
const trie = of("hello", "world");
has("hello", trie); // true
has("hel", trie); // false
has("hello world", trie); // false
has("world", trie); // true
has("wor", trie); // false
word to check
true if there exists at least one prefix in the trie that is also a prefix of word
Check if any of leaf in the trie is a prefix of the input
import { add, hasPrefix, of } from '@micham/trie-ts';
let trie = of("hello", "world");
hasPrefix("hello", trie); // true
hasPrefix("hello world", trie); // true
hasPrefix("hell", trie); // false
hasPrefix("all", trie); // false
word to check
true if there exists at least one prefix in the trie that is also a prefix of word
This function will try to remove a word from the trie. If this word was not present in the trie, the trie will not be updated
import { remove, emptyTrie } from '@micham/trie-ts';
const trie = remove("word", emptyTrie);
to remove from the trie
to remove the word from
the trie with the word removed
Search for all the words in the trie that start with the given prefix
import { add, search, of } from '@micham/trie-ts';
const trie = of("hello", "hello world", "world");
const result = search("hello", trie);
// result == ["hello", "hello world"]
prefix that will be used to search in trie
trie to scan
the list of word in the trie that contain query as a prefix
Generated using TypeDoc
A Trie Node that contains