data-structure-typed 1.50.1 → 1.50.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -1
- package/README.md +30 -28
- package/README_zh-CN.md +1 -1
- package/SPECIFICATION.md +56 -0
- package/SPONSOR-zh-CN.md +90 -0
- package/SPONSOR.md +54 -0
- package/benchmark/report.html +13 -13
- package/benchmark/report.json +149 -161
- package/dist/cjs/data-structures/base/iterable-base.d.ts +120 -9
- package/dist/cjs/data-structures/base/iterable-base.js +143 -7
- package/dist/cjs/data-structures/base/iterable-base.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +72 -47
- package/dist/cjs/data-structures/binary-tree/avl-tree.js +101 -72
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.d.ts +22 -0
- package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js +22 -0
- package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +244 -199
- package/dist/cjs/data-structures/binary-tree/binary-tree.js +484 -376
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/bst.d.ts +92 -79
- package/dist/cjs/data-structures/binary-tree/bst.js +68 -76
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +127 -57
- package/dist/cjs/data-structures/binary-tree/rb-tree.js +152 -99
- package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/segment-tree.d.ts +99 -6
- package/dist/cjs/data-structures/binary-tree/segment-tree.js +127 -10
- package/dist/cjs/data-structures/binary-tree/segment-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/tree-multimap.d.ts +72 -58
- package/dist/cjs/data-structures/binary-tree/tree-multimap.js +102 -85
- package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
- package/dist/cjs/data-structures/graph/abstract-graph.d.ts +1 -78
- package/dist/cjs/data-structures/graph/abstract-graph.js +3 -189
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/directed-graph.d.ts +73 -0
- package/dist/cjs/data-structures/graph/directed-graph.js +131 -0
- package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/map-graph.d.ts +8 -0
- package/dist/cjs/data-structures/graph/map-graph.js +14 -0
- package/dist/cjs/data-structures/graph/map-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/undirected-graph.d.ts +76 -7
- package/dist/cjs/data-structures/graph/undirected-graph.js +151 -18
- package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
- package/dist/cjs/data-structures/hash/hash-map.d.ts +254 -28
- package/dist/cjs/data-structures/hash/hash-map.js +347 -78
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
- package/dist/cjs/data-structures/heap/heap.d.ts +95 -25
- package/dist/cjs/data-structures/heap/heap.js +95 -26
- package/dist/cjs/data-structures/heap/heap.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +126 -63
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +141 -77
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +154 -106
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js +164 -115
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +63 -36
- package/dist/cjs/data-structures/linked-list/skip-linked-list.js +63 -36
- package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/matrix/matrix.d.ts +35 -4
- package/dist/cjs/data-structures/matrix/matrix.js +50 -11
- package/dist/cjs/data-structures/matrix/matrix.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +10 -0
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +10 -0
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +11 -0
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +11 -0
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +8 -0
- package/dist/cjs/data-structures/priority-queue/priority-queue.js +8 -0
- package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/queue/deque.d.ts +139 -35
- package/dist/cjs/data-structures/queue/deque.js +200 -62
- package/dist/cjs/data-structures/queue/deque.js.map +1 -1
- package/dist/cjs/data-structures/queue/queue.d.ts +103 -49
- package/dist/cjs/data-structures/queue/queue.js +111 -49
- package/dist/cjs/data-structures/queue/queue.js.map +1 -1
- package/dist/cjs/data-structures/stack/stack.d.ts +51 -21
- package/dist/cjs/data-structures/stack/stack.js +58 -22
- package/dist/cjs/data-structures/stack/stack.js.map +1 -1
- package/dist/cjs/data-structures/tree/tree.d.ts +57 -3
- package/dist/cjs/data-structures/tree/tree.js +77 -11
- package/dist/cjs/data-structures/tree/tree.js.map +1 -1
- package/dist/cjs/data-structures/trie/trie.d.ts +135 -34
- package/dist/cjs/data-structures/trie/trie.js +153 -33
- package/dist/cjs/data-structures/trie/trie.js.map +1 -1
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
- package/dist/cjs/types/data-structures/hash/hash-map.d.ts +4 -3
- package/dist/cjs/types/utils/utils.d.ts +1 -0
- package/dist/mjs/data-structures/base/iterable-base.d.ts +120 -9
- package/dist/mjs/data-structures/base/iterable-base.js +143 -7
- package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +72 -47
- package/dist/mjs/data-structures/binary-tree/avl-tree.js +102 -73
- package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.d.ts +22 -0
- package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.js +22 -0
- package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +244 -199
- package/dist/mjs/data-structures/binary-tree/binary-tree.js +483 -375
- package/dist/mjs/data-structures/binary-tree/bst.d.ts +92 -79
- package/dist/mjs/data-structures/binary-tree/bst.js +68 -76
- package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +127 -57
- package/dist/mjs/data-structures/binary-tree/rb-tree.js +153 -100
- package/dist/mjs/data-structures/binary-tree/segment-tree.d.ts +99 -6
- package/dist/mjs/data-structures/binary-tree/segment-tree.js +127 -10
- package/dist/mjs/data-structures/binary-tree/tree-multimap.d.ts +72 -58
- package/dist/mjs/data-structures/binary-tree/tree-multimap.js +102 -86
- package/dist/mjs/data-structures/graph/abstract-graph.d.ts +1 -78
- package/dist/mjs/data-structures/graph/abstract-graph.js +3 -188
- package/dist/mjs/data-structures/graph/directed-graph.d.ts +73 -0
- package/dist/mjs/data-structures/graph/directed-graph.js +131 -0
- package/dist/mjs/data-structures/graph/map-graph.d.ts +8 -0
- package/dist/mjs/data-structures/graph/map-graph.js +14 -0
- package/dist/mjs/data-structures/graph/undirected-graph.d.ts +76 -7
- package/dist/mjs/data-structures/graph/undirected-graph.js +152 -19
- package/dist/mjs/data-structures/hash/hash-map.d.ts +254 -28
- package/dist/mjs/data-structures/hash/hash-map.js +353 -84
- package/dist/mjs/data-structures/heap/heap.d.ts +95 -25
- package/dist/mjs/data-structures/heap/heap.js +95 -26
- package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +126 -63
- package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +144 -80
- package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +154 -106
- package/dist/mjs/data-structures/linked-list/singly-linked-list.js +166 -117
- package/dist/mjs/data-structures/linked-list/skip-linked-list.d.ts +63 -36
- package/dist/mjs/data-structures/linked-list/skip-linked-list.js +63 -36
- package/dist/mjs/data-structures/matrix/matrix.d.ts +35 -4
- package/dist/mjs/data-structures/matrix/matrix.js +50 -11
- package/dist/mjs/data-structures/priority-queue/max-priority-queue.d.ts +10 -0
- package/dist/mjs/data-structures/priority-queue/max-priority-queue.js +10 -0
- package/dist/mjs/data-structures/priority-queue/min-priority-queue.d.ts +11 -0
- package/dist/mjs/data-structures/priority-queue/min-priority-queue.js +11 -0
- package/dist/mjs/data-structures/priority-queue/priority-queue.d.ts +8 -0
- package/dist/mjs/data-structures/priority-queue/priority-queue.js +8 -0
- package/dist/mjs/data-structures/queue/deque.d.ts +139 -35
- package/dist/mjs/data-structures/queue/deque.js +205 -67
- package/dist/mjs/data-structures/queue/queue.d.ts +103 -49
- package/dist/mjs/data-structures/queue/queue.js +111 -49
- package/dist/mjs/data-structures/stack/stack.d.ts +51 -21
- package/dist/mjs/data-structures/stack/stack.js +58 -22
- package/dist/mjs/data-structures/tree/tree.d.ts +57 -3
- package/dist/mjs/data-structures/tree/tree.js +80 -14
- package/dist/mjs/data-structures/trie/trie.d.ts +135 -34
- package/dist/mjs/data-structures/trie/trie.js +156 -36
- package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
- package/dist/mjs/types/data-structures/hash/hash-map.d.ts +4 -3
- package/dist/mjs/types/utils/utils.d.ts +1 -0
- package/dist/umd/data-structure-typed.js +3121 -1583
- package/dist/umd/data-structure-typed.min.js +3 -3
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +61 -55
- package/src/data-structures/base/iterable-base.ts +184 -19
- package/src/data-structures/binary-tree/avl-tree.ts +134 -100
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +22 -0
- package/src/data-structures/binary-tree/binary-tree.ts +674 -671
- package/src/data-structures/binary-tree/bst.ts +127 -136
- package/src/data-structures/binary-tree/rb-tree.ts +199 -166
- package/src/data-structures/binary-tree/segment-tree.ts +145 -11
- package/src/data-structures/binary-tree/tree-multimap.ts +138 -115
- package/src/data-structures/graph/abstract-graph.ts +4 -211
- package/src/data-structures/graph/directed-graph.ts +152 -0
- package/src/data-structures/graph/map-graph.ts +15 -0
- package/src/data-structures/graph/undirected-graph.ts +171 -19
- package/src/data-structures/hash/hash-map.ts +389 -96
- package/src/data-structures/heap/heap.ts +97 -26
- package/src/data-structures/linked-list/doubly-linked-list.ts +156 -83
- package/src/data-structures/linked-list/singly-linked-list.ts +174 -120
- package/src/data-structures/linked-list/skip-linked-list.ts +63 -37
- package/src/data-structures/matrix/matrix.ts +52 -12
- package/src/data-structures/priority-queue/max-priority-queue.ts +10 -0
- package/src/data-structures/priority-queue/min-priority-queue.ts +11 -0
- package/src/data-structures/priority-queue/priority-queue.ts +8 -0
- package/src/data-structures/queue/deque.ts +225 -70
- package/src/data-structures/queue/queue.ts +118 -49
- package/src/data-structures/stack/stack.ts +63 -23
- package/src/data-structures/tree/tree.ts +89 -15
- package/src/data-structures/trie/trie.ts +173 -38
- package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
- package/src/types/data-structures/hash/hash-map.ts +4 -3
- package/src/types/utils/utils.ts +2 -0
- package/test/performance/data-structures/graph/directed-graph.test.ts +4 -4
- package/test/performance/data-structures/queue/deque.test.ts +26 -25
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +37 -0
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +46 -17
- package/test/unit/data-structures/binary-tree/bst.test.ts +65 -1
- package/test/unit/data-structures/binary-tree/rb-tree.test.ts +38 -1
- package/test/unit/data-structures/binary-tree/tree-multimap.test.ts +37 -32
- package/test/unit/data-structures/graph/abstract-graph.test.ts +11 -0
- package/test/unit/data-structures/graph/directed-graph.test.ts +190 -5
- package/test/unit/data-structures/graph/undirected-graph.test.ts +263 -18
- package/test/unit/data-structures/hash/hash-map.test.ts +376 -353
- package/test/unit/data-structures/heap/heap.test.ts +18 -1
- package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +24 -5
- package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +20 -2
- package/test/unit/data-structures/linked-list/skip-list.test.ts +1 -1
- package/test/unit/data-structures/queue/deque.test.ts +65 -5
- package/test/unit/data-structures/queue/queue.test.ts +24 -5
- package/test/unit/data-structures/stack/stack.test.ts +17 -0
- package/test/unit/data-structures/trie/trie.test.ts +17 -0
|
@@ -12,10 +12,46 @@ import { IterableElementBase } from '../base';
|
|
|
12
12
|
* and a flag indicating whether it's the end of a word.
|
|
13
13
|
*/
|
|
14
14
|
export declare class TrieNode {
|
|
15
|
-
key: string;
|
|
16
|
-
children: Map<string, TrieNode>;
|
|
17
|
-
isEnd: boolean;
|
|
18
15
|
constructor(key: string);
|
|
16
|
+
protected _key: string;
|
|
17
|
+
/**
|
|
18
|
+
* The function returns the value of the protected variable _key.
|
|
19
|
+
* @returns The value of the `_key` property, which is a string.
|
|
20
|
+
*/
|
|
21
|
+
get key(): string;
|
|
22
|
+
/**
|
|
23
|
+
* The above function sets the value of a protected variable called "key".
|
|
24
|
+
* @param {string} value - The value parameter is a string that represents the value to be assigned
|
|
25
|
+
* to the key.
|
|
26
|
+
*/
|
|
27
|
+
set key(value: string);
|
|
28
|
+
protected _children: Map<string, TrieNode>;
|
|
29
|
+
/**
|
|
30
|
+
* The function returns the children of a TrieNode as a Map.
|
|
31
|
+
* @returns The `children` property of the TrieNode object, which is a Map containing string keys and
|
|
32
|
+
* TrieNode values.
|
|
33
|
+
*/
|
|
34
|
+
get children(): Map<string, TrieNode>;
|
|
35
|
+
/**
|
|
36
|
+
* The function sets the value of the `_children` property of a TrieNode object.
|
|
37
|
+
* @param value - The value parameter is a Map object that represents the children of a TrieNode. The
|
|
38
|
+
* keys of the map are strings, which represent the characters that are associated with each child
|
|
39
|
+
* TrieNode. The values of the map are TrieNode objects, which represent the child nodes of the
|
|
40
|
+
* current TrieNode.
|
|
41
|
+
*/
|
|
42
|
+
set children(value: Map<string, TrieNode>);
|
|
43
|
+
protected _isEnd: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* The function returns a boolean value indicating whether a certain condition is met.
|
|
46
|
+
* @returns The method is returning a boolean value, specifically the value of the variable `_isEnd`.
|
|
47
|
+
*/
|
|
48
|
+
get isEnd(): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The function sets the value of the "_isEnd" property.
|
|
51
|
+
* @param {boolean} value - The value parameter is a boolean value that indicates whether the current
|
|
52
|
+
* state is the end state or not.
|
|
53
|
+
*/
|
|
54
|
+
set isEnd(value: boolean);
|
|
19
55
|
}
|
|
20
56
|
/**
|
|
21
57
|
* 1. Node Structure: Each node in a Trie represents a string (or a part of a string). The root node typically represents an empty string.
|
|
@@ -30,21 +66,39 @@ export declare class TrieNode {
|
|
|
30
66
|
* 10. IP Routing: Used in certain types of IP routing algorithms.
|
|
31
67
|
* 11. Text Word Frequency Count: Counting and storing the frequency of words in a large amount of text data."
|
|
32
68
|
*/
|
|
33
|
-
export declare class Trie extends IterableElementBase<string> {
|
|
69
|
+
export declare class Trie extends IterableElementBase<string, Trie> {
|
|
70
|
+
/**
|
|
71
|
+
* The constructor function for the Trie class.
|
|
72
|
+
* @param words: Iterable string Initialize the trie with a set of words
|
|
73
|
+
* @param options?: TrieOptions Allow the user to pass in options for the trie
|
|
74
|
+
* @return This
|
|
75
|
+
*/
|
|
34
76
|
constructor(words?: Iterable<string>, options?: TrieOptions);
|
|
35
77
|
protected _size: number;
|
|
78
|
+
/**
|
|
79
|
+
* The size function returns the size of the stack.
|
|
80
|
+
* @return The number of elements in the list
|
|
81
|
+
*/
|
|
36
82
|
get size(): number;
|
|
37
83
|
protected _caseSensitive: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* The caseSensitive function is a getter that returns the value of the protected _caseSensitive property.
|
|
86
|
+
* @return The value of the _caseSensitive protected variable
|
|
87
|
+
*/
|
|
38
88
|
get caseSensitive(): boolean;
|
|
39
89
|
protected _root: TrieNode;
|
|
90
|
+
/**
|
|
91
|
+
* The root function returns the root node of the tree.
|
|
92
|
+
* @return The root node
|
|
93
|
+
*/
|
|
40
94
|
get root(): TrieNode;
|
|
41
95
|
/**
|
|
42
|
-
* Time Complexity: O(
|
|
43
|
-
* Space Complexity: O(
|
|
96
|
+
* Time Complexity: O(l), where l is the length of the word being added.
|
|
97
|
+
* Space Complexity: O(l) - Each character in the word adds a TrieNode.
|
|
44
98
|
*/
|
|
45
99
|
/**
|
|
46
|
-
* Time Complexity: O(
|
|
47
|
-
* Space Complexity: O(
|
|
100
|
+
* Time Complexity: O(l), where l is the length of the word being added.
|
|
101
|
+
* Space Complexity: O(l) - Each character in the word adds a TrieNode.
|
|
48
102
|
*
|
|
49
103
|
* Add a word to the Trie structure.
|
|
50
104
|
* @param {string} word - The word to add.
|
|
@@ -52,11 +106,11 @@ export declare class Trie extends IterableElementBase<string> {
|
|
|
52
106
|
*/
|
|
53
107
|
add(word: string): boolean;
|
|
54
108
|
/**
|
|
55
|
-
* Time Complexity: O(
|
|
109
|
+
* Time Complexity: O(l), where l is the length of the input word.
|
|
56
110
|
* Space Complexity: O(1) - Constant space.
|
|
57
111
|
*/
|
|
58
112
|
/**
|
|
59
|
-
* Time Complexity: O(
|
|
113
|
+
* Time Complexity: O(l), where l is the length of the input word.
|
|
60
114
|
* Space Complexity: O(1) - Constant space.
|
|
61
115
|
*
|
|
62
116
|
* Check if the Trie contains a given word.
|
|
@@ -65,12 +119,35 @@ export declare class Trie extends IterableElementBase<string> {
|
|
|
65
119
|
*/
|
|
66
120
|
has(word: string): boolean;
|
|
67
121
|
/**
|
|
68
|
-
* Time Complexity: O(
|
|
69
|
-
* Space Complexity: O(
|
|
122
|
+
* Time Complexity: O(1)
|
|
123
|
+
* Space Complexity: O(1)
|
|
124
|
+
*/
|
|
125
|
+
/**
|
|
126
|
+
* Time Complexity: O(1)
|
|
127
|
+
* Space Complexity: O(1)
|
|
128
|
+
*
|
|
129
|
+
* The isEmpty function checks if the size of the queue is 0.
|
|
130
|
+
* @return True if the size of the queue is 0
|
|
131
|
+
*/
|
|
132
|
+
isEmpty(): boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Time Complexity: O(1)
|
|
135
|
+
* Space Complexity: O(1)
|
|
136
|
+
*/
|
|
137
|
+
/**
|
|
138
|
+
* Time Complexity: O(1)
|
|
139
|
+
* Space Complexity: O(1)
|
|
140
|
+
*
|
|
141
|
+
* The clear function resets the size of the Trie to 0 and creates a new root TrieNode.
|
|
142
|
+
*/
|
|
143
|
+
clear(): void;
|
|
144
|
+
/**
|
|
145
|
+
* Time Complexity: O(l), where l is the length of the word being deleted.
|
|
146
|
+
* Space Complexity: O(n) - Due to the recursive DFS approach.
|
|
70
147
|
*/
|
|
71
148
|
/**
|
|
72
|
-
* Time Complexity: O(
|
|
73
|
-
* Space Complexity: O(
|
|
149
|
+
* Time Complexity: O(l), where l is the length of the word being deleted.
|
|
150
|
+
* Space Complexity: O(n) - Due to the recursive DFS approach.
|
|
74
151
|
*
|
|
75
152
|
* Remove a word from the Trie structure.
|
|
76
153
|
* @param{string} word - The word to delete.
|
|
@@ -78,21 +155,21 @@ export declare class Trie extends IterableElementBase<string> {
|
|
|
78
155
|
*/
|
|
79
156
|
delete(word: string): boolean;
|
|
80
157
|
/**
|
|
81
|
-
* Time Complexity: O(
|
|
158
|
+
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
|
82
159
|
* Space Complexity: O(1) - Constant space.
|
|
83
160
|
*/
|
|
84
161
|
/**
|
|
85
|
-
* Time Complexity: O(
|
|
162
|
+
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
|
86
163
|
* Space Complexity: O(1) - Constant space.
|
|
87
164
|
*
|
|
88
165
|
*/
|
|
89
166
|
getHeight(): number;
|
|
90
167
|
/**
|
|
91
|
-
* Time Complexity: O(
|
|
168
|
+
* Time Complexity: O(l), where l is the length of the input prefix.
|
|
92
169
|
* Space Complexity: O(1) - Constant space.
|
|
93
170
|
*/
|
|
94
171
|
/**
|
|
95
|
-
* Time Complexity: O(
|
|
172
|
+
* Time Complexity: O(l), where l is the length of the input prefix.
|
|
96
173
|
* Space Complexity: O(1) - Constant space.
|
|
97
174
|
*
|
|
98
175
|
* Check if a given input string has an absolute prefix in the Trie, meaning it's not a complete word.
|
|
@@ -101,11 +178,11 @@ export declare class Trie extends IterableElementBase<string> {
|
|
|
101
178
|
*/
|
|
102
179
|
hasPurePrefix(input: string): boolean;
|
|
103
180
|
/**
|
|
104
|
-
* Time Complexity: O(
|
|
181
|
+
* Time Complexity: O(l), where l is the length of the input prefix.
|
|
105
182
|
* Space Complexity: O(1) - Constant space.
|
|
106
183
|
*/
|
|
107
184
|
/**
|
|
108
|
-
* Time Complexity: O(
|
|
185
|
+
* Time Complexity: O(l), where l is the length of the input prefix.
|
|
109
186
|
* Space Complexity: O(1) - Constant space.
|
|
110
187
|
*
|
|
111
188
|
* Check if a given input string is a prefix of any existing word in the Trie, whether as an absolute prefix or a complete word.
|
|
@@ -114,12 +191,12 @@ export declare class Trie extends IterableElementBase<string> {
|
|
|
114
191
|
*/
|
|
115
192
|
hasPrefix(input: string): boolean;
|
|
116
193
|
/**
|
|
117
|
-
* Time Complexity: O(
|
|
118
|
-
* Space Complexity: O(
|
|
194
|
+
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
|
195
|
+
* Space Complexity: O(l), where l is the length of the input prefix.
|
|
119
196
|
*/
|
|
120
197
|
/**
|
|
121
|
-
* Time Complexity: O(
|
|
122
|
-
* Space Complexity: O(
|
|
198
|
+
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
|
199
|
+
* Space Complexity: O(l), where l is the length of the input prefix.
|
|
123
200
|
*
|
|
124
201
|
* Check if the input string is a common prefix in the Trie, meaning it's a prefix shared by all words in the Trie.
|
|
125
202
|
* @param {string} input - The input string representing the common prefix to check for.
|
|
@@ -127,24 +204,24 @@ export declare class Trie extends IterableElementBase<string> {
|
|
|
127
204
|
*/
|
|
128
205
|
hasCommonPrefix(input: string): boolean;
|
|
129
206
|
/**
|
|
130
|
-
* Time Complexity: O(
|
|
131
|
-
* Space Complexity: O(
|
|
207
|
+
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
|
208
|
+
* Space Complexity: O(l), where l is the length of the longest common prefix.
|
|
132
209
|
*/
|
|
133
210
|
/**
|
|
134
|
-
* Time Complexity: O(
|
|
135
|
-
* Space Complexity: O(
|
|
211
|
+
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
|
212
|
+
* Space Complexity: O(l), where l is the length of the longest common prefix.
|
|
136
213
|
*
|
|
137
214
|
* Get the longest common prefix among all the words stored in the Trie.
|
|
138
215
|
* @returns {string} The longest common prefix found in the Trie.
|
|
139
216
|
*/
|
|
140
217
|
getLongestCommonPrefix(): string;
|
|
141
218
|
/**
|
|
142
|
-
* Time Complexity: O(
|
|
143
|
-
* Space Complexity: O(
|
|
219
|
+
* Time Complexity: O(w * l), where w is the number of words retrieved, and l is the average length of the words.
|
|
220
|
+
* Space Complexity: O(w * l) - The space required for the output array.
|
|
144
221
|
*/
|
|
145
222
|
/**
|
|
146
|
-
* Time Complexity: O(
|
|
147
|
-
* Space Complexity: O(
|
|
223
|
+
* Time Complexity: O(w * l), where w is the number of words retrieved, and l is the average length of the words.
|
|
224
|
+
* Space Complexity: O(w * l) - The space required for the output array.
|
|
148
225
|
*
|
|
149
226
|
* The `getAll` function returns an array of all words in a Trie data structure that start with a given prefix.
|
|
150
227
|
* @param {string} prefix - The `prefix` parameter is a string that represents the prefix that we want to search for in the
|
|
@@ -154,6 +231,19 @@ export declare class Trie extends IterableElementBase<string> {
|
|
|
154
231
|
* @returns {string[]} an array of strings.
|
|
155
232
|
*/
|
|
156
233
|
getWords(prefix?: string, max?: number, isAllWhenEmptyPrefix?: boolean): string[];
|
|
234
|
+
/**
|
|
235
|
+
* Time Complexity: O(n)
|
|
236
|
+
* Space Complexity: O(n)
|
|
237
|
+
*/
|
|
238
|
+
/**
|
|
239
|
+
* Time Complexity: O(n)
|
|
240
|
+
* Space Complexity: O(n)
|
|
241
|
+
*
|
|
242
|
+
* The `clone` function returns a new instance of the Trie class with the same values and case
|
|
243
|
+
* sensitivity as the original Trie.
|
|
244
|
+
* @returns A new instance of the Trie class is being returned.
|
|
245
|
+
*/
|
|
246
|
+
clone(): Trie;
|
|
157
247
|
/**
|
|
158
248
|
* Time Complexity: O(n)
|
|
159
249
|
* Space Complexity: O(n)
|
|
@@ -191,13 +281,24 @@ export declare class Trie extends IterableElementBase<string> {
|
|
|
191
281
|
* @returns The `map` function is returning a new Trie object.
|
|
192
282
|
*/
|
|
193
283
|
map(callback: ElementCallback<string, string>, thisArg?: any): Trie;
|
|
284
|
+
/**
|
|
285
|
+
* Time Complexity: O(n)
|
|
286
|
+
* Space Complexity: O(n)
|
|
287
|
+
*/
|
|
288
|
+
/**
|
|
289
|
+
* Time Complexity: O(n)
|
|
290
|
+
* Space Complexity: O(n)
|
|
291
|
+
*
|
|
292
|
+
* The function `_getIterator` returns an iterable iterator that performs a depth-first search on a
|
|
293
|
+
* trie data structure and yields all the paths to the end nodes.
|
|
294
|
+
*/
|
|
194
295
|
protected _getIterator(): IterableIterator<string>;
|
|
195
296
|
/**
|
|
196
|
-
* Time Complexity: O(
|
|
297
|
+
* Time Complexity: O(l), where l is the length of the input string.
|
|
197
298
|
* Space Complexity: O(1) - Constant space.
|
|
198
299
|
*/
|
|
199
300
|
/**
|
|
200
|
-
* Time Complexity: O(
|
|
301
|
+
* Time Complexity: O(l), where l is the length of the input string.
|
|
201
302
|
* Space Complexity: O(1) - Constant space.
|
|
202
303
|
*
|
|
203
304
|
* @param str
|
|
@@ -4,13 +4,61 @@ import { IterableElementBase } from '../base';
|
|
|
4
4
|
* and a flag indicating whether it's the end of a word.
|
|
5
5
|
*/
|
|
6
6
|
export class TrieNode {
|
|
7
|
-
key;
|
|
8
|
-
children;
|
|
9
|
-
isEnd;
|
|
10
7
|
constructor(key) {
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
8
|
+
this._key = key;
|
|
9
|
+
this._isEnd = false;
|
|
10
|
+
this._children = new Map();
|
|
11
|
+
}
|
|
12
|
+
_key;
|
|
13
|
+
/**
|
|
14
|
+
* The function returns the value of the protected variable _key.
|
|
15
|
+
* @returns The value of the `_key` property, which is a string.
|
|
16
|
+
*/
|
|
17
|
+
get key() {
|
|
18
|
+
return this._key;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The above function sets the value of a protected variable called "key".
|
|
22
|
+
* @param {string} value - The value parameter is a string that represents the value to be assigned
|
|
23
|
+
* to the key.
|
|
24
|
+
*/
|
|
25
|
+
set key(value) {
|
|
26
|
+
this._key = value;
|
|
27
|
+
}
|
|
28
|
+
_children;
|
|
29
|
+
/**
|
|
30
|
+
* The function returns the children of a TrieNode as a Map.
|
|
31
|
+
* @returns The `children` property of the TrieNode object, which is a Map containing string keys and
|
|
32
|
+
* TrieNode values.
|
|
33
|
+
*/
|
|
34
|
+
get children() {
|
|
35
|
+
return this._children;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The function sets the value of the `_children` property of a TrieNode object.
|
|
39
|
+
* @param value - The value parameter is a Map object that represents the children of a TrieNode. The
|
|
40
|
+
* keys of the map are strings, which represent the characters that are associated with each child
|
|
41
|
+
* TrieNode. The values of the map are TrieNode objects, which represent the child nodes of the
|
|
42
|
+
* current TrieNode.
|
|
43
|
+
*/
|
|
44
|
+
set children(value) {
|
|
45
|
+
this._children = value;
|
|
46
|
+
}
|
|
47
|
+
_isEnd;
|
|
48
|
+
/**
|
|
49
|
+
* The function returns a boolean value indicating whether a certain condition is met.
|
|
50
|
+
* @returns The method is returning a boolean value, specifically the value of the variable `_isEnd`.
|
|
51
|
+
*/
|
|
52
|
+
get isEnd() {
|
|
53
|
+
return this._isEnd;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The function sets the value of the "_isEnd" property.
|
|
57
|
+
* @param {boolean} value - The value parameter is a boolean value that indicates whether the current
|
|
58
|
+
* state is the end state or not.
|
|
59
|
+
*/
|
|
60
|
+
set isEnd(value) {
|
|
61
|
+
this._isEnd = value;
|
|
14
62
|
}
|
|
15
63
|
}
|
|
16
64
|
/**
|
|
@@ -27,6 +75,12 @@ export class TrieNode {
|
|
|
27
75
|
* 11. Text Word Frequency Count: Counting and storing the frequency of words in a large amount of text data."
|
|
28
76
|
*/
|
|
29
77
|
export class Trie extends IterableElementBase {
|
|
78
|
+
/**
|
|
79
|
+
* The constructor function for the Trie class.
|
|
80
|
+
* @param words: Iterable string Initialize the trie with a set of words
|
|
81
|
+
* @param options?: TrieOptions Allow the user to pass in options for the trie
|
|
82
|
+
* @return This
|
|
83
|
+
*/
|
|
30
84
|
constructor(words = [], options) {
|
|
31
85
|
super();
|
|
32
86
|
if (options) {
|
|
@@ -40,24 +94,36 @@ export class Trie extends IterableElementBase {
|
|
|
40
94
|
}
|
|
41
95
|
}
|
|
42
96
|
_size = 0;
|
|
97
|
+
/**
|
|
98
|
+
* The size function returns the size of the stack.
|
|
99
|
+
* @return The number of elements in the list
|
|
100
|
+
*/
|
|
43
101
|
get size() {
|
|
44
102
|
return this._size;
|
|
45
103
|
}
|
|
46
104
|
_caseSensitive = true;
|
|
105
|
+
/**
|
|
106
|
+
* The caseSensitive function is a getter that returns the value of the protected _caseSensitive property.
|
|
107
|
+
* @return The value of the _caseSensitive protected variable
|
|
108
|
+
*/
|
|
47
109
|
get caseSensitive() {
|
|
48
110
|
return this._caseSensitive;
|
|
49
111
|
}
|
|
50
112
|
_root = new TrieNode('');
|
|
113
|
+
/**
|
|
114
|
+
* The root function returns the root node of the tree.
|
|
115
|
+
* @return The root node
|
|
116
|
+
*/
|
|
51
117
|
get root() {
|
|
52
118
|
return this._root;
|
|
53
119
|
}
|
|
54
120
|
/**
|
|
55
|
-
* Time Complexity: O(
|
|
56
|
-
* Space Complexity: O(
|
|
121
|
+
* Time Complexity: O(l), where l is the length of the word being added.
|
|
122
|
+
* Space Complexity: O(l) - Each character in the word adds a TrieNode.
|
|
57
123
|
*/
|
|
58
124
|
/**
|
|
59
|
-
* Time Complexity: O(
|
|
60
|
-
* Space Complexity: O(
|
|
125
|
+
* Time Complexity: O(l), where l is the length of the word being added.
|
|
126
|
+
* Space Complexity: O(l) - Each character in the word adds a TrieNode.
|
|
61
127
|
*
|
|
62
128
|
* Add a word to the Trie structure.
|
|
63
129
|
* @param {string} word - The word to add.
|
|
@@ -83,11 +149,11 @@ export class Trie extends IterableElementBase {
|
|
|
83
149
|
return isNewWord;
|
|
84
150
|
}
|
|
85
151
|
/**
|
|
86
|
-
* Time Complexity: O(
|
|
152
|
+
* Time Complexity: O(l), where l is the length of the input word.
|
|
87
153
|
* Space Complexity: O(1) - Constant space.
|
|
88
154
|
*/
|
|
89
155
|
/**
|
|
90
|
-
* Time Complexity: O(
|
|
156
|
+
* Time Complexity: O(l), where l is the length of the input word.
|
|
91
157
|
* Space Complexity: O(1) - Constant space.
|
|
92
158
|
*
|
|
93
159
|
* Check if the Trie contains a given word.
|
|
@@ -106,12 +172,40 @@ export class Trie extends IterableElementBase {
|
|
|
106
172
|
return cur.isEnd;
|
|
107
173
|
}
|
|
108
174
|
/**
|
|
109
|
-
* Time Complexity: O(
|
|
110
|
-
* Space Complexity: O(
|
|
175
|
+
* Time Complexity: O(1)
|
|
176
|
+
* Space Complexity: O(1)
|
|
111
177
|
*/
|
|
112
178
|
/**
|
|
113
|
-
* Time Complexity: O(
|
|
114
|
-
* Space Complexity: O(
|
|
179
|
+
* Time Complexity: O(1)
|
|
180
|
+
* Space Complexity: O(1)
|
|
181
|
+
*
|
|
182
|
+
* The isEmpty function checks if the size of the queue is 0.
|
|
183
|
+
* @return True if the size of the queue is 0
|
|
184
|
+
*/
|
|
185
|
+
isEmpty() {
|
|
186
|
+
return this.size === 0;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Time Complexity: O(1)
|
|
190
|
+
* Space Complexity: O(1)
|
|
191
|
+
*/
|
|
192
|
+
/**
|
|
193
|
+
* Time Complexity: O(1)
|
|
194
|
+
* Space Complexity: O(1)
|
|
195
|
+
*
|
|
196
|
+
* The clear function resets the size of the Trie to 0 and creates a new root TrieNode.
|
|
197
|
+
*/
|
|
198
|
+
clear() {
|
|
199
|
+
this._size = 0;
|
|
200
|
+
this._root = new TrieNode('');
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Time Complexity: O(l), where l is the length of the word being deleted.
|
|
204
|
+
* Space Complexity: O(n) - Due to the recursive DFS approach.
|
|
205
|
+
*/
|
|
206
|
+
/**
|
|
207
|
+
* Time Complexity: O(l), where l is the length of the word being deleted.
|
|
208
|
+
* Space Complexity: O(n) - Due to the recursive DFS approach.
|
|
115
209
|
*
|
|
116
210
|
* Remove a word from the Trie structure.
|
|
117
211
|
* @param{string} word - The word to delete.
|
|
@@ -153,11 +247,11 @@ export class Trie extends IterableElementBase {
|
|
|
153
247
|
return isDeleted;
|
|
154
248
|
}
|
|
155
249
|
/**
|
|
156
|
-
* Time Complexity: O(
|
|
250
|
+
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
|
157
251
|
* Space Complexity: O(1) - Constant space.
|
|
158
252
|
*/
|
|
159
253
|
/**
|
|
160
|
-
* Time Complexity: O(
|
|
254
|
+
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
|
161
255
|
* Space Complexity: O(1) - Constant space.
|
|
162
256
|
*
|
|
163
257
|
*/
|
|
@@ -181,11 +275,11 @@ export class Trie extends IterableElementBase {
|
|
|
181
275
|
return maxDepth;
|
|
182
276
|
}
|
|
183
277
|
/**
|
|
184
|
-
* Time Complexity: O(
|
|
278
|
+
* Time Complexity: O(l), where l is the length of the input prefix.
|
|
185
279
|
* Space Complexity: O(1) - Constant space.
|
|
186
280
|
*/
|
|
187
281
|
/**
|
|
188
|
-
* Time Complexity: O(
|
|
282
|
+
* Time Complexity: O(l), where l is the length of the input prefix.
|
|
189
283
|
* Space Complexity: O(1) - Constant space.
|
|
190
284
|
*
|
|
191
285
|
* Check if a given input string has an absolute prefix in the Trie, meaning it's not a complete word.
|
|
@@ -204,11 +298,11 @@ export class Trie extends IterableElementBase {
|
|
|
204
298
|
return !cur.isEnd;
|
|
205
299
|
}
|
|
206
300
|
/**
|
|
207
|
-
* Time Complexity: O(
|
|
301
|
+
* Time Complexity: O(l), where l is the length of the input prefix.
|
|
208
302
|
* Space Complexity: O(1) - Constant space.
|
|
209
303
|
*/
|
|
210
304
|
/**
|
|
211
|
-
* Time Complexity: O(
|
|
305
|
+
* Time Complexity: O(l), where l is the length of the input prefix.
|
|
212
306
|
* Space Complexity: O(1) - Constant space.
|
|
213
307
|
*
|
|
214
308
|
* Check if a given input string is a prefix of any existing word in the Trie, whether as an absolute prefix or a complete word.
|
|
@@ -227,12 +321,12 @@ export class Trie extends IterableElementBase {
|
|
|
227
321
|
return true;
|
|
228
322
|
}
|
|
229
323
|
/**
|
|
230
|
-
* Time Complexity: O(
|
|
231
|
-
* Space Complexity: O(
|
|
324
|
+
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
|
325
|
+
* Space Complexity: O(l), where l is the length of the input prefix.
|
|
232
326
|
*/
|
|
233
327
|
/**
|
|
234
|
-
* Time Complexity: O(
|
|
235
|
-
* Space Complexity: O(
|
|
328
|
+
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
|
329
|
+
* Space Complexity: O(l), where l is the length of the input prefix.
|
|
236
330
|
*
|
|
237
331
|
* Check if the input string is a common prefix in the Trie, meaning it's a prefix shared by all words in the Trie.
|
|
238
332
|
* @param {string} input - The input string representing the common prefix to check for.
|
|
@@ -256,12 +350,12 @@ export class Trie extends IterableElementBase {
|
|
|
256
350
|
return commonPre === input;
|
|
257
351
|
}
|
|
258
352
|
/**
|
|
259
|
-
* Time Complexity: O(
|
|
260
|
-
* Space Complexity: O(
|
|
353
|
+
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
|
354
|
+
* Space Complexity: O(l), where l is the length of the longest common prefix.
|
|
261
355
|
*/
|
|
262
356
|
/**
|
|
263
|
-
* Time Complexity: O(
|
|
264
|
-
* Space Complexity: O(
|
|
357
|
+
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
|
358
|
+
* Space Complexity: O(l), where l is the length of the longest common prefix.
|
|
265
359
|
*
|
|
266
360
|
* Get the longest common prefix among all the words stored in the Trie.
|
|
267
361
|
* @returns {string} The longest common prefix found in the Trie.
|
|
@@ -281,12 +375,12 @@ export class Trie extends IterableElementBase {
|
|
|
281
375
|
return commonPre;
|
|
282
376
|
}
|
|
283
377
|
/**
|
|
284
|
-
* Time Complexity: O(
|
|
285
|
-
* Space Complexity: O(
|
|
378
|
+
* Time Complexity: O(w * l), where w is the number of words retrieved, and l is the average length of the words.
|
|
379
|
+
* Space Complexity: O(w * l) - The space required for the output array.
|
|
286
380
|
*/
|
|
287
381
|
/**
|
|
288
|
-
* Time Complexity: O(
|
|
289
|
-
* Space Complexity: O(
|
|
382
|
+
* Time Complexity: O(w * l), where w is the number of words retrieved, and l is the average length of the words.
|
|
383
|
+
* Space Complexity: O(w * l) - The space required for the output array.
|
|
290
384
|
*
|
|
291
385
|
* The `getAll` function returns an array of all words in a Trie data structure that start with a given prefix.
|
|
292
386
|
* @param {string} prefix - The `prefix` parameter is a string that represents the prefix that we want to search for in the
|
|
@@ -325,6 +419,21 @@ export class Trie extends IterableElementBase {
|
|
|
325
419
|
dfs(startNode, prefix);
|
|
326
420
|
return words;
|
|
327
421
|
}
|
|
422
|
+
/**
|
|
423
|
+
* Time Complexity: O(n)
|
|
424
|
+
* Space Complexity: O(n)
|
|
425
|
+
*/
|
|
426
|
+
/**
|
|
427
|
+
* Time Complexity: O(n)
|
|
428
|
+
* Space Complexity: O(n)
|
|
429
|
+
*
|
|
430
|
+
* The `clone` function returns a new instance of the Trie class with the same values and case
|
|
431
|
+
* sensitivity as the original Trie.
|
|
432
|
+
* @returns A new instance of the Trie class is being returned.
|
|
433
|
+
*/
|
|
434
|
+
clone() {
|
|
435
|
+
return new Trie(this.values(), { caseSensitive: this.caseSensitive });
|
|
436
|
+
}
|
|
328
437
|
/**
|
|
329
438
|
* Time Complexity: O(n)
|
|
330
439
|
* Space Complexity: O(n)
|
|
@@ -380,6 +489,17 @@ export class Trie extends IterableElementBase {
|
|
|
380
489
|
}
|
|
381
490
|
return newTrie;
|
|
382
491
|
}
|
|
492
|
+
/**
|
|
493
|
+
* Time Complexity: O(n)
|
|
494
|
+
* Space Complexity: O(n)
|
|
495
|
+
*/
|
|
496
|
+
/**
|
|
497
|
+
* Time Complexity: O(n)
|
|
498
|
+
* Space Complexity: O(n)
|
|
499
|
+
*
|
|
500
|
+
* The function `_getIterator` returns an iterable iterator that performs a depth-first search on a
|
|
501
|
+
* trie data structure and yields all the paths to the end nodes.
|
|
502
|
+
*/
|
|
383
503
|
*_getIterator() {
|
|
384
504
|
function* _dfs(node, path) {
|
|
385
505
|
if (node.isEnd) {
|
|
@@ -392,11 +512,11 @@ export class Trie extends IterableElementBase {
|
|
|
392
512
|
yield* _dfs(this.root, '');
|
|
393
513
|
}
|
|
394
514
|
/**
|
|
395
|
-
* Time Complexity: O(
|
|
515
|
+
* Time Complexity: O(l), where l is the length of the input string.
|
|
396
516
|
* Space Complexity: O(1) - Constant space.
|
|
397
517
|
*/
|
|
398
518
|
/**
|
|
399
|
-
* Time Complexity: O(
|
|
519
|
+
* Time Complexity: O(l), where l is the length of the input string.
|
|
400
520
|
* Space Complexity: O(1) - Constant space.
|
|
401
521
|
*
|
|
402
522
|
* @param str
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BinaryTree, BinaryTreeNode } from '../../../data-structures';
|
|
2
2
|
import { IterationType } from "../../common";
|
|
3
3
|
export type BinaryTreeNodeNested<K, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
4
|
-
export type BinaryTreeNested<K, V,
|
|
4
|
+
export type BinaryTreeNested<K, V, NODE extends BinaryTreeNode<K, V, NODE>> = BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, BinaryTree<K, V, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
5
5
|
export type BinaryTreeOptions<K> = {
|
|
6
6
|
iterationType?: IterationType;
|
|
7
7
|
extractor?: (key: K) => number;
|
|
@@ -4,13 +4,14 @@ export type HashMapLinkedNode<K, V> = {
|
|
|
4
4
|
next: HashMapLinkedNode<K, V>;
|
|
5
5
|
prev: HashMapLinkedNode<K, V>;
|
|
6
6
|
};
|
|
7
|
-
export type LinkedHashMapOptions<K> = {
|
|
7
|
+
export type LinkedHashMapOptions<K, V, R> = {
|
|
8
8
|
hashFn?: (key: K) => string;
|
|
9
9
|
objHashFn?: (key: K) => object;
|
|
10
|
+
toEntryFn?: (rawElement: R) => [K, V];
|
|
10
11
|
};
|
|
11
|
-
export type HashMapOptions<K, V,
|
|
12
|
+
export type HashMapOptions<K, V, R> = {
|
|
12
13
|
hashFn?: (key: K) => string;
|
|
13
|
-
toEntryFn?: (rawElement:
|
|
14
|
+
toEntryFn?: (rawElement: R) => [K, V];
|
|
14
15
|
};
|
|
15
16
|
export type HashMapStoreItem<K, V> = {
|
|
16
17
|
key: K;
|
|
@@ -5,3 +5,4 @@ export type Thunk = () => ReturnType<ToThunkFn> & {
|
|
|
5
5
|
export type TrlFn = (...args: any[]) => any;
|
|
6
6
|
export type TrlAsyncFn = (...args: any[]) => any;
|
|
7
7
|
export type SpecifyOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
8
|
+
export type Any = string | number | boolean | object | null | undefined | symbol;
|