TrieNode
data-structure-typed / TrieNode
Class: TrieNode
Defined in: data-structures/trie/trie.ts:17
Node used by Trie to store one character and its children.
Remarks
Time O(1), Space O(1)
Constructors
Constructor
new TrieNode(key): TrieNode;
Defined in: data-structures/trie/trie.ts:24
Create a Trie node with a character key.
Parameters
key
string
Returns
TrieNode
New TrieNode instance.
Remarks
Time O(1), Space O(1)
Accessors
children
Get Signature
get children(): Map<string, TrieNode>;
Defined in: data-structures/trie/trie.ts:61
Get the child map of this node.
Remarks
Time O(1), Space O(1)
Returns
Map<string, TrieNode>
Map from character to child node.
Set Signature
set children(value): void;
Defined in: data-structures/trie/trie.ts:72
Replace the child map of this node.
Remarks
Time O(1), Space O(1)
Parameters
value
Map<string, TrieNode>
New map of character → node.
Returns
void
void
isEnd
Get Signature
get isEnd(): boolean;
Defined in: data-structures/trie/trie.ts:84
Check whether this node marks the end of a word.
Remarks
Time O(1), Space O(1)
Returns
boolean
True if this node ends a word.
Set Signature
set isEnd(value): void;
Defined in: data-structures/trie/trie.ts:95
Mark this node as the end of a word or not.
Remarks
Time O(1), Space O(1)
Parameters
value
boolean
Whether this node ends a word.
Returns
void
void
key
Get Signature
get key(): string;
Defined in: data-structures/trie/trie.ts:38
Get the character key of this node.
Remarks
Time O(1), Space O(1)
Returns
string
Character key string.
Set Signature
set key(value): void;
Defined in: data-structures/trie/trie.ts:49
Set the character key of this node.
Remarks
Time O(1), Space O(1)
Parameters
value
string
New character key.
Returns
void
void