Trie with superpowers! 馃挭
$ yarn add @clarketm/supertrie
$ npm install @clarketm/supertrie --save
Construct a Trie
Get the root of the trie
Insert a string into the trie
Name | Type | Attribute | Description |
---|---|---|---|
word | string | string to insert |
Remove a string from the trie
Name | Type | Attribute | Description |
---|---|---|---|
word | string | string to remove |
Search for a node in the trie matching the query
Name | Type | Attribute | Description |
---|---|---|---|
query | string | string query to search for |
Check if the trie includes a word
Name | Type | Attribute | Description |
---|---|---|---|
word | string | full word to search for |
Alias to
includes(word)
Check if the trie contains a word
Name | Type | Attribute | Description |
---|---|---|---|
word | string | full word to search for |
Check if the trie contains a prefix
Name | Type | Attribute | Description |
---|---|---|---|
prefix | string | prefix (i.e. partial word) to search for |
TrieNode
Construct a TrieNode
Get children count of the node
Get character value of node
Checks if node is a complete word
Check if node has a specific character as a child
Name | Type | Attribute | Description |
---|---|---|---|
char | character | character to check |
Get child node with specific character value
Name | Type | Attribute | Description |
---|---|---|---|
char | character | character to get |
Set child node with specific character value
Name | Type | Attribute | Description |
---|---|---|---|
char | character | character to set | |
node | TrieNode | node to assign to character |
Delete child node with specific character value
Name | Type | Attribute | Description |
---|---|---|---|
char | character | character to delete |