Skip to main content

TrieNode

data-structure-typed


data-structure-typed / TrieNode

Class: TrieNode

Defined in: data-structures/trie/trie.ts:16

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:22

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:56

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:66

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:77

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:87

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:35

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:45

Set the character key of this node.

Remarks​

Time O(1), Space O(1)

Parameters​
value​

string

New character key.

Returns​

void

void