data-structure-typed 1.52.4 → 1.52.6
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 +1 -1
- package/README.md +13 -13
- package/README_zh-CN.md +216 -26
- package/benchmark/report.html +13 -13
- package/benchmark/report.json +158 -158
- package/dist/cjs/data-structures/base/iterable-element-base.d.ts +1 -37
- package/dist/cjs/data-structures/base/iterable-element-base.js +1 -37
- package/dist/cjs/data-structures/base/iterable-element-base.js.map +1 -1
- package/dist/cjs/data-structures/base/iterable-entry-base.d.ts +2 -54
- package/dist/cjs/data-structures/base/iterable-entry-base.js +1 -49
- package/dist/cjs/data-structures/base/iterable-entry-base.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -32
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +9 -41
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +0 -46
- package/dist/cjs/data-structures/binary-tree/avl-tree.js +0 -46
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +82 -147
- package/dist/cjs/data-structures/binary-tree/binary-tree.js +300 -332
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/bst.d.ts +1 -40
- package/dist/cjs/data-structures/binary-tree/bst.js +12 -44
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +0 -48
- package/dist/cjs/data-structures/binary-tree/rb-tree.js +2 -50
- package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +0 -32
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +9 -41
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
- package/dist/cjs/data-structures/graph/abstract-graph.d.ts +0 -75
- package/dist/cjs/data-structures/graph/abstract-graph.js +0 -75
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/directed-graph.d.ts +0 -98
- package/dist/cjs/data-structures/graph/directed-graph.js +0 -98
- package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/undirected-graph.d.ts +0 -50
- package/dist/cjs/data-structures/graph/undirected-graph.js +0 -50
- package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
- package/dist/cjs/data-structures/hash/hash-map.d.ts +5 -92
- package/dist/cjs/data-structures/hash/hash-map.js +27 -111
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
- package/dist/cjs/data-structures/heap/heap.d.ts +0 -32
- package/dist/cjs/data-structures/heap/heap.js +0 -32
- package/dist/cjs/data-structures/heap/heap.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +5 -88
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +5 -88
- 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 +1 -83
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js +2 -84
- 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 +1 -35
- package/dist/cjs/data-structures/linked-list/skip-linked-list.js +1 -35
- package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/queue/deque.d.ts +1 -98
- package/dist/cjs/data-structures/queue/deque.js +3 -99
- package/dist/cjs/data-structures/queue/deque.js.map +1 -1
- package/dist/cjs/data-structures/queue/queue.d.ts +1 -54
- package/dist/cjs/data-structures/queue/queue.js +0 -53
- package/dist/cjs/data-structures/queue/queue.js.map +1 -1
- package/dist/cjs/data-structures/stack/stack.d.ts +1 -34
- package/dist/cjs/data-structures/stack/stack.js +1 -34
- package/dist/cjs/data-structures/stack/stack.js.map +1 -1
- package/dist/cjs/data-structures/tree/tree.js +2 -1
- package/dist/cjs/data-structures/tree/tree.js.map +1 -1
- package/dist/cjs/data-structures/trie/trie.d.ts +0 -64
- package/dist/cjs/data-structures/trie/trie.js +0 -64
- package/dist/cjs/data-structures/trie/trie.js.map +1 -1
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +8 -0
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.js +6 -0
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/types/utils/utils.d.ts +13 -12
- package/dist/cjs/utils/number.d.ts +13 -0
- package/dist/cjs/utils/number.js +13 -0
- package/dist/cjs/utils/number.js.map +1 -1
- package/dist/cjs/utils/utils.d.ts +125 -3
- package/dist/cjs/utils/utils.js +177 -21
- package/dist/cjs/utils/utils.js.map +1 -1
- package/dist/mjs/data-structures/base/iterable-element-base.d.ts +1 -37
- package/dist/mjs/data-structures/base/iterable-element-base.js +1 -37
- package/dist/mjs/data-structures/base/iterable-entry-base.d.ts +2 -54
- package/dist/mjs/data-structures/base/iterable-entry-base.js +1 -49
- package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -32
- package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +9 -41
- package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +0 -46
- package/dist/mjs/data-structures/binary-tree/avl-tree.js +0 -46
- package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +82 -147
- package/dist/mjs/data-structures/binary-tree/binary-tree.js +299 -333
- package/dist/mjs/data-structures/binary-tree/bst.d.ts +1 -40
- package/dist/mjs/data-structures/binary-tree/bst.js +12 -44
- package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +0 -48
- package/dist/mjs/data-structures/binary-tree/rb-tree.js +2 -50
- package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +0 -32
- package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +9 -41
- package/dist/mjs/data-structures/graph/abstract-graph.d.ts +0 -75
- package/dist/mjs/data-structures/graph/abstract-graph.js +0 -75
- package/dist/mjs/data-structures/graph/directed-graph.d.ts +0 -98
- package/dist/mjs/data-structures/graph/directed-graph.js +0 -98
- package/dist/mjs/data-structures/graph/undirected-graph.d.ts +0 -50
- package/dist/mjs/data-structures/graph/undirected-graph.js +0 -50
- package/dist/mjs/data-structures/hash/hash-map.d.ts +5 -92
- package/dist/mjs/data-structures/hash/hash-map.js +27 -111
- package/dist/mjs/data-structures/heap/heap.d.ts +0 -32
- package/dist/mjs/data-structures/heap/heap.js +0 -32
- package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +5 -88
- package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +5 -88
- package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +1 -83
- package/dist/mjs/data-structures/linked-list/singly-linked-list.js +2 -84
- package/dist/mjs/data-structures/linked-list/skip-linked-list.d.ts +1 -35
- package/dist/mjs/data-structures/linked-list/skip-linked-list.js +1 -35
- package/dist/mjs/data-structures/queue/deque.d.ts +1 -98
- package/dist/mjs/data-structures/queue/deque.js +3 -99
- package/dist/mjs/data-structures/queue/queue.d.ts +1 -54
- package/dist/mjs/data-structures/queue/queue.js +0 -53
- package/dist/mjs/data-structures/stack/stack.d.ts +1 -34
- package/dist/mjs/data-structures/stack/stack.js +1 -34
- package/dist/mjs/data-structures/tree/tree.js +2 -1
- package/dist/mjs/data-structures/trie/trie.d.ts +0 -64
- package/dist/mjs/data-structures/trie/trie.js +0 -64
- package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +8 -0
- package/dist/mjs/types/data-structures/binary-tree/binary-tree.js +5 -1
- package/dist/mjs/types/utils/utils.d.ts +13 -12
- package/dist/mjs/utils/number.d.ts +13 -0
- package/dist/mjs/utils/number.js +13 -0
- package/dist/mjs/utils/utils.d.ts +125 -3
- package/dist/mjs/utils/utils.js +177 -21
- package/dist/umd/data-structure-typed.js +411 -1475
- package/dist/umd/data-structure-typed.min.js +5 -4
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +6 -6
- package/src/data-structures/base/iterable-element-base.ts +2 -42
- package/src/data-structures/base/iterable-entry-base.ts +3 -62
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +8 -48
- package/src/data-structures/binary-tree/avl-tree.ts +0 -57
- package/src/data-structures/binary-tree/binary-tree.ts +330 -359
- package/src/data-structures/binary-tree/bst.ts +11 -54
- package/src/data-structures/binary-tree/rb-tree.ts +2 -62
- package/src/data-structures/binary-tree/tree-multi-map.ts +8 -48
- package/src/data-structures/graph/abstract-graph.ts +0 -92
- package/src/data-structures/graph/directed-graph.ts +0 -122
- package/src/data-structures/graph/undirected-graph.ts +0 -62
- package/src/data-structures/hash/hash-map.ts +29 -133
- package/src/data-structures/heap/heap.ts +0 -40
- package/src/data-structures/linked-list/doubly-linked-list.ts +5 -112
- package/src/data-structures/linked-list/singly-linked-list.ts +2 -104
- package/src/data-structures/linked-list/skip-linked-list.ts +1 -44
- package/src/data-structures/queue/deque.ts +2 -125
- package/src/data-structures/queue/queue.ts +1 -68
- package/src/data-structures/stack/stack.ts +1 -43
- package/src/data-structures/tree/tree.ts +1 -1
- package/src/data-structures/trie/trie.ts +0 -80
- package/src/types/data-structures/binary-tree/binary-tree.ts +8 -1
- package/src/types/utils/utils.ts +17 -15
- package/src/utils/number.ts +13 -0
- package/src/utils/utils.ts +174 -18
- package/test/config.ts +8 -0
- package/test/integration/all-in-one.test.ts +1 -1
- package/test/integration/avl-tree.test.ts +1 -1
- package/test/integration/bst.test.ts +2 -2
- package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +13 -13
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +18 -13
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +577 -167
- package/test/unit/data-structures/binary-tree/bst.test.ts +167 -23
- package/test/unit/data-structures/binary-tree/overall.test.ts +1 -1
- package/test/unit/data-structures/binary-tree/rb-tree.test.ts +136 -13
- package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +18 -13
- package/test/unit/data-structures/graph/directed-graph.test.ts +46 -32
- package/test/unit/data-structures/graph/map-graph.test.ts +24 -2
- package/test/unit/data-structures/graph/undirected-graph.test.ts +24 -24
- package/test/unit/data-structures/hash/hash-map.test.ts +225 -35
- package/test/unit/data-structures/heap/heap.test.ts +47 -39
- package/test/unit/data-structures/heap/min-heap.test.ts +5 -5
- package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +34 -4
- package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +32 -0
- package/test/unit/data-structures/matrix/matrix.test.ts +35 -5
- package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +31 -0
- package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +18 -0
- package/test/unit/data-structures/priority-queue/priority-queue.test.ts +17 -0
- package/test/unit/data-structures/queue/deque.test.ts +288 -47
- package/test/unit/data-structures/queue/queue.test.ts +62 -37
- package/test/unit/data-structures/stack/stack.test.ts +30 -5
- package/test/unit/data-structures/tree/tree.test.ts +58 -0
- package/test/unit/data-structures/trie/trie.test.ts +46 -5
- package/test/unit/utils/utils.test.ts +169 -0
|
@@ -48,10 +48,6 @@ export class Queue extends IterableElementBase {
|
|
|
48
48
|
get size() {
|
|
49
49
|
return this.elements.length - this.offset;
|
|
50
50
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Time Complexity: O(1)
|
|
53
|
-
* Space Complexity: O(1)
|
|
54
|
-
*/
|
|
55
51
|
/**
|
|
56
52
|
* Time Complexity: O(1)
|
|
57
53
|
* Space Complexity: O(1)
|
|
@@ -63,10 +59,6 @@ export class Queue extends IterableElementBase {
|
|
|
63
59
|
get first() {
|
|
64
60
|
return this.size > 0 ? this.elements[this.offset] : undefined;
|
|
65
61
|
}
|
|
66
|
-
/**
|
|
67
|
-
* Time Complexity: O(1)
|
|
68
|
-
* Space Complexity: O(1)
|
|
69
|
-
*/
|
|
70
62
|
/**
|
|
71
63
|
* Time Complexity: O(1)
|
|
72
64
|
* Space Complexity: O(1)
|
|
@@ -94,10 +86,6 @@ export class Queue extends IterableElementBase {
|
|
|
94
86
|
set autoCompactRatio(v) {
|
|
95
87
|
this._autoCompactRatio = v;
|
|
96
88
|
}
|
|
97
|
-
/**
|
|
98
|
-
* Time Complexity: O(n)
|
|
99
|
-
* Space Complexity: O(n)
|
|
100
|
-
*/
|
|
101
89
|
/**
|
|
102
90
|
* Time Complexity: O(n)
|
|
103
91
|
* Space Complexity: O(n)
|
|
@@ -111,10 +99,6 @@ export class Queue extends IterableElementBase {
|
|
|
111
99
|
static fromArray(elements) {
|
|
112
100
|
return new Queue(elements);
|
|
113
101
|
}
|
|
114
|
-
/**
|
|
115
|
-
* Time Complexity: O(1)
|
|
116
|
-
* Space Complexity: O(1)
|
|
117
|
-
*/
|
|
118
102
|
/**
|
|
119
103
|
* Time Complexity: O(1)
|
|
120
104
|
* Space Complexity: O(1)
|
|
@@ -127,10 +111,6 @@ export class Queue extends IterableElementBase {
|
|
|
127
111
|
this.elements.push(element);
|
|
128
112
|
return true;
|
|
129
113
|
}
|
|
130
|
-
/**
|
|
131
|
-
* Time Complexity: O(1)
|
|
132
|
-
* Space Complexity: O(1)
|
|
133
|
-
*/
|
|
134
114
|
/**
|
|
135
115
|
* Time Complexity: O(1)
|
|
136
116
|
* Space Complexity: O(1)
|
|
@@ -166,10 +146,6 @@ export class Queue extends IterableElementBase {
|
|
|
166
146
|
const spliced = this.elements.splice(index, 1);
|
|
167
147
|
return spliced.length === 1;
|
|
168
148
|
}
|
|
169
|
-
/**
|
|
170
|
-
* Time Complexity: O(1)
|
|
171
|
-
* Space Complexity: O(1)
|
|
172
|
-
*/
|
|
173
149
|
/**
|
|
174
150
|
* Time Complexity: O(1)
|
|
175
151
|
* Space Complexity: O(1)
|
|
@@ -179,10 +155,6 @@ export class Queue extends IterableElementBase {
|
|
|
179
155
|
at(index) {
|
|
180
156
|
return this.elements[index + this._offset];
|
|
181
157
|
}
|
|
182
|
-
/**
|
|
183
|
-
* Time Complexity: O(1)
|
|
184
|
-
* Space Complexity: O(1)
|
|
185
|
-
*/
|
|
186
158
|
/**
|
|
187
159
|
* Time Complexity: O(1)
|
|
188
160
|
* Space Complexity: O(1)
|
|
@@ -193,10 +165,6 @@ export class Queue extends IterableElementBase {
|
|
|
193
165
|
isEmpty() {
|
|
194
166
|
return this.size === 0;
|
|
195
167
|
}
|
|
196
|
-
/**
|
|
197
|
-
* Time Complexity: O(1)
|
|
198
|
-
* Space Complexity: O(n)
|
|
199
|
-
*/
|
|
200
168
|
/**
|
|
201
169
|
* Time Complexity: O(1)
|
|
202
170
|
* Space Complexity: O(n)
|
|
@@ -207,10 +175,6 @@ export class Queue extends IterableElementBase {
|
|
|
207
175
|
toArray() {
|
|
208
176
|
return this.elements.slice(this.offset);
|
|
209
177
|
}
|
|
210
|
-
/**
|
|
211
|
-
* Time Complexity: O(1)
|
|
212
|
-
* Space Complexity: O(1)
|
|
213
|
-
*/
|
|
214
178
|
/**
|
|
215
179
|
* Time Complexity: O(1)
|
|
216
180
|
* Space Complexity: O(1)
|
|
@@ -231,11 +195,6 @@ export class Queue extends IterableElementBase {
|
|
|
231
195
|
this._offset = 0;
|
|
232
196
|
return true;
|
|
233
197
|
}
|
|
234
|
-
/**
|
|
235
|
-
* Time Complexity: O(n)
|
|
236
|
-
* Space Complexity: O(n)
|
|
237
|
-
* where n is the number of elements in the queue. It creates a shallow copy of the internal array. the space required is proportional to the number of elements in the queue.
|
|
238
|
-
*/
|
|
239
198
|
/**
|
|
240
199
|
* Time Complexity: O(n)
|
|
241
200
|
* Space Complexity: O(n)
|
|
@@ -246,10 +205,6 @@ export class Queue extends IterableElementBase {
|
|
|
246
205
|
clone() {
|
|
247
206
|
return new Queue(this.elements.slice(this.offset), { toElementFn: this.toElementFn });
|
|
248
207
|
}
|
|
249
|
-
/**
|
|
250
|
-
* Time Complexity: O(n)
|
|
251
|
-
* Space Complexity: O(n)
|
|
252
|
-
*/
|
|
253
208
|
/**
|
|
254
209
|
* Time Complexity: O(n)
|
|
255
210
|
* Space Complexity: O(n)
|
|
@@ -290,10 +245,6 @@ export class Queue extends IterableElementBase {
|
|
|
290
245
|
}
|
|
291
246
|
return newDeque;
|
|
292
247
|
}
|
|
293
|
-
/**
|
|
294
|
-
* Time Complexity: O(n)
|
|
295
|
-
* Space Complexity: O(n)
|
|
296
|
-
*/
|
|
297
248
|
/**
|
|
298
249
|
* Time Complexity: O(n)
|
|
299
250
|
* Space Complexity: O(n)
|
|
@@ -313,10 +264,6 @@ export class Queue extends IterableElementBase {
|
|
|
313
264
|
* 4. Frequent Enqueuing and Dequeuing Operations: If your application involves frequent enqueuing and dequeuing operations and is less concerned with random access, then LinkedListQueue is a good choice.
|
|
314
265
|
*/
|
|
315
266
|
export class LinkedListQueue extends SinglyLinkedList {
|
|
316
|
-
/**
|
|
317
|
-
* Time Complexity: O(n)
|
|
318
|
-
* Space Complexity: O(n)
|
|
319
|
-
*/
|
|
320
267
|
/**
|
|
321
268
|
* Time Complexity: O(n)
|
|
322
269
|
* Space Complexity: O(n)
|
|
@@ -47,10 +47,6 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R, S
|
|
|
47
47
|
* @returns A boolean value indicating whether the `_elements` array is empty or not.
|
|
48
48
|
*/
|
|
49
49
|
isEmpty(): boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Time Complexity: O(1)
|
|
52
|
-
* Space Complexity: O(1)
|
|
53
|
-
*/
|
|
54
50
|
/**
|
|
55
51
|
* Time Complexity: O(1)
|
|
56
52
|
* Space Complexity: O(1)
|
|
@@ -59,10 +55,6 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R, S
|
|
|
59
55
|
* @returns The `peek()` function returns the last element of the `_elements` array, or `undefined` if the array is empty.
|
|
60
56
|
*/
|
|
61
57
|
peek(): E | undefined;
|
|
62
|
-
/**
|
|
63
|
-
* Time Complexity: O(1)
|
|
64
|
-
* Space Complexity: O(1)
|
|
65
|
-
*/
|
|
66
58
|
/**
|
|
67
59
|
* Time Complexity: O(1)
|
|
68
60
|
* Space Complexity: O(1)
|
|
@@ -72,10 +64,6 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R, S
|
|
|
72
64
|
* @returns The `push` method is returning the updated `Stack<E>` object.
|
|
73
65
|
*/
|
|
74
66
|
push(element: E): boolean;
|
|
75
|
-
/**
|
|
76
|
-
* Time Complexity: O(1)
|
|
77
|
-
* Space Complexity: O(1)
|
|
78
|
-
*/
|
|
79
67
|
/**
|
|
80
68
|
* Time Complexity: O(1)
|
|
81
69
|
* Space Complexity: O(1)
|
|
@@ -97,10 +85,6 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R, S
|
|
|
97
85
|
* @return A boolean value
|
|
98
86
|
*/
|
|
99
87
|
deleteAt(index: number): boolean;
|
|
100
|
-
/**
|
|
101
|
-
* Time Complexity: O(n)
|
|
102
|
-
* Space Complexity: O(n)
|
|
103
|
-
*/
|
|
104
88
|
/**
|
|
105
89
|
* Time Complexity: O(n)
|
|
106
90
|
* Space Complexity: O(n)
|
|
@@ -109,10 +93,6 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R, S
|
|
|
109
93
|
* @returns An array of type E.
|
|
110
94
|
*/
|
|
111
95
|
toArray(): E[];
|
|
112
|
-
/**
|
|
113
|
-
* Time Complexity: O(1)
|
|
114
|
-
* Space Complexity: O(1)
|
|
115
|
-
*/
|
|
116
96
|
/**
|
|
117
97
|
* Time Complexity: O(1)
|
|
118
98
|
* Space Complexity: O(1)
|
|
@@ -120,10 +100,6 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R, S
|
|
|
120
100
|
* The clear function clears the elements array.
|
|
121
101
|
*/
|
|
122
102
|
clear(): void;
|
|
123
|
-
/**
|
|
124
|
-
* Time Complexity: O(n)
|
|
125
|
-
* Space Complexity: O(n)
|
|
126
|
-
*/
|
|
127
103
|
/**
|
|
128
104
|
* Time Complexity: O(n)
|
|
129
105
|
* Space Complexity: O(n)
|
|
@@ -132,10 +108,6 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R, S
|
|
|
132
108
|
* @returns The `clone()` method is returning a new `Stack` object with a copy of the `_elements` array.
|
|
133
109
|
*/
|
|
134
110
|
clone(): Stack<E, R>;
|
|
135
|
-
/**
|
|
136
|
-
* Time Complexity: O(n)
|
|
137
|
-
* Space Complexity: O(n)
|
|
138
|
-
*/
|
|
139
111
|
/**
|
|
140
112
|
* Time Complexity: O(n)
|
|
141
113
|
* Space Complexity: O(n)
|
|
@@ -156,8 +128,7 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R, S
|
|
|
156
128
|
/**
|
|
157
129
|
* Time Complexity: O(n)
|
|
158
130
|
* Space Complexity: O(n)
|
|
159
|
-
|
|
160
|
-
/**
|
|
131
|
+
*
|
|
161
132
|
* The `map` function takes a callback function and applies it to each element in the stack,
|
|
162
133
|
* returning a new stack with the results.
|
|
163
134
|
* @param callback - The callback parameter is a function that will be called for each element in the
|
|
@@ -172,10 +143,6 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R, S
|
|
|
172
143
|
* @returns a new Stack object with elements of type EM and raw elements of type RM.
|
|
173
144
|
*/
|
|
174
145
|
map<EM, RM>(callback: ElementCallback<E, R, EM, Stack<E, R>>, toElementFn?: (rawElement: RM) => EM, thisArg?: any): Stack<EM, RM>;
|
|
175
|
-
/**
|
|
176
|
-
* Time Complexity: O(n)
|
|
177
|
-
* Space Complexity: O(n)
|
|
178
|
-
*/
|
|
179
146
|
/**
|
|
180
147
|
* Time Complexity: O(n)
|
|
181
148
|
* Space Complexity: O(n)
|
|
@@ -59,10 +59,6 @@ export class Stack extends IterableElementBase {
|
|
|
59
59
|
isEmpty() {
|
|
60
60
|
return this.elements.length === 0;
|
|
61
61
|
}
|
|
62
|
-
/**
|
|
63
|
-
* Time Complexity: O(1)
|
|
64
|
-
* Space Complexity: O(1)
|
|
65
|
-
*/
|
|
66
62
|
/**
|
|
67
63
|
* Time Complexity: O(1)
|
|
68
64
|
* Space Complexity: O(1)
|
|
@@ -75,10 +71,6 @@ export class Stack extends IterableElementBase {
|
|
|
75
71
|
return undefined;
|
|
76
72
|
return this.elements[this.elements.length - 1];
|
|
77
73
|
}
|
|
78
|
-
/**
|
|
79
|
-
* Time Complexity: O(1)
|
|
80
|
-
* Space Complexity: O(1)
|
|
81
|
-
*/
|
|
82
74
|
/**
|
|
83
75
|
* Time Complexity: O(1)
|
|
84
76
|
* Space Complexity: O(1)
|
|
@@ -91,10 +83,6 @@ export class Stack extends IterableElementBase {
|
|
|
91
83
|
this.elements.push(element);
|
|
92
84
|
return true;
|
|
93
85
|
}
|
|
94
|
-
/**
|
|
95
|
-
* Time Complexity: O(1)
|
|
96
|
-
* Space Complexity: O(1)
|
|
97
|
-
*/
|
|
98
86
|
/**
|
|
99
87
|
* Time Complexity: O(1)
|
|
100
88
|
* Space Complexity: O(1)
|
|
@@ -126,10 +114,6 @@ export class Stack extends IterableElementBase {
|
|
|
126
114
|
const spliced = this.elements.splice(index, 1);
|
|
127
115
|
return spliced.length === 1;
|
|
128
116
|
}
|
|
129
|
-
/**
|
|
130
|
-
* Time Complexity: O(n)
|
|
131
|
-
* Space Complexity: O(n)
|
|
132
|
-
*/
|
|
133
117
|
/**
|
|
134
118
|
* Time Complexity: O(n)
|
|
135
119
|
* Space Complexity: O(n)
|
|
@@ -140,10 +124,6 @@ export class Stack extends IterableElementBase {
|
|
|
140
124
|
toArray() {
|
|
141
125
|
return this.elements.slice();
|
|
142
126
|
}
|
|
143
|
-
/**
|
|
144
|
-
* Time Complexity: O(1)
|
|
145
|
-
* Space Complexity: O(1)
|
|
146
|
-
*/
|
|
147
127
|
/**
|
|
148
128
|
* Time Complexity: O(1)
|
|
149
129
|
* Space Complexity: O(1)
|
|
@@ -153,10 +133,6 @@ export class Stack extends IterableElementBase {
|
|
|
153
133
|
clear() {
|
|
154
134
|
this._elements = [];
|
|
155
135
|
}
|
|
156
|
-
/**
|
|
157
|
-
* Time Complexity: O(n)
|
|
158
|
-
* Space Complexity: O(n)
|
|
159
|
-
*/
|
|
160
136
|
/**
|
|
161
137
|
* Time Complexity: O(n)
|
|
162
138
|
* Space Complexity: O(n)
|
|
@@ -167,10 +143,6 @@ export class Stack extends IterableElementBase {
|
|
|
167
143
|
clone() {
|
|
168
144
|
return new Stack(this, { toElementFn: this.toElementFn });
|
|
169
145
|
}
|
|
170
|
-
/**
|
|
171
|
-
* Time Complexity: O(n)
|
|
172
|
-
* Space Complexity: O(n)
|
|
173
|
-
*/
|
|
174
146
|
/**
|
|
175
147
|
* Time Complexity: O(n)
|
|
176
148
|
* Space Complexity: O(n)
|
|
@@ -201,8 +173,7 @@ export class Stack extends IterableElementBase {
|
|
|
201
173
|
/**
|
|
202
174
|
* Time Complexity: O(n)
|
|
203
175
|
* Space Complexity: O(n)
|
|
204
|
-
|
|
205
|
-
/**
|
|
176
|
+
*
|
|
206
177
|
* The `map` function takes a callback function and applies it to each element in the stack,
|
|
207
178
|
* returning a new stack with the results.
|
|
208
179
|
* @param callback - The callback parameter is a function that will be called for each element in the
|
|
@@ -225,10 +196,6 @@ export class Stack extends IterableElementBase {
|
|
|
225
196
|
}
|
|
226
197
|
return newStack;
|
|
227
198
|
}
|
|
228
|
-
/**
|
|
229
|
-
* Time Complexity: O(n)
|
|
230
|
-
* Space Complexity: O(n)
|
|
231
|
-
*/
|
|
232
199
|
/**
|
|
233
200
|
* Time Complexity: O(n)
|
|
234
201
|
* Space Complexity: O(n)
|
|
@@ -92,10 +92,6 @@ export declare class Trie<R = any> extends IterableElementBase<string, R, Trie<R
|
|
|
92
92
|
* @return The root node
|
|
93
93
|
*/
|
|
94
94
|
get root(): TrieNode;
|
|
95
|
-
/**
|
|
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.
|
|
98
|
-
*/
|
|
99
95
|
/**
|
|
100
96
|
* Time Complexity: O(l), where l is the length of the word being added.
|
|
101
97
|
* Space Complexity: O(l) - Each character in the word adds a TrieNode.
|
|
@@ -105,10 +101,6 @@ export declare class Trie<R = any> extends IterableElementBase<string, R, Trie<R
|
|
|
105
101
|
* @returns {boolean} True if the word was successfully added.
|
|
106
102
|
*/
|
|
107
103
|
add(word: string): boolean;
|
|
108
|
-
/**
|
|
109
|
-
* Time Complexity: O(l), where l is the length of the input word.
|
|
110
|
-
* Space Complexity: O(1) - Constant space.
|
|
111
|
-
*/
|
|
112
104
|
/**
|
|
113
105
|
* Time Complexity: O(l), where l is the length of the input word.
|
|
114
106
|
* Space Complexity: O(1) - Constant space.
|
|
@@ -118,10 +110,6 @@ export declare class Trie<R = any> extends IterableElementBase<string, R, Trie<R
|
|
|
118
110
|
* @returns {boolean} True if the word is present in the Trie.
|
|
119
111
|
*/
|
|
120
112
|
has(word: string): boolean;
|
|
121
|
-
/**
|
|
122
|
-
* Time Complexity: O(1)
|
|
123
|
-
* Space Complexity: O(1)
|
|
124
|
-
*/
|
|
125
113
|
/**
|
|
126
114
|
* Time Complexity: O(1)
|
|
127
115
|
* Space Complexity: O(1)
|
|
@@ -130,10 +118,6 @@ export declare class Trie<R = any> extends IterableElementBase<string, R, Trie<R
|
|
|
130
118
|
* @return True if the size of the queue is 0
|
|
131
119
|
*/
|
|
132
120
|
isEmpty(): boolean;
|
|
133
|
-
/**
|
|
134
|
-
* Time Complexity: O(1)
|
|
135
|
-
* Space Complexity: O(1)
|
|
136
|
-
*/
|
|
137
121
|
/**
|
|
138
122
|
* Time Complexity: O(1)
|
|
139
123
|
* Space Complexity: O(1)
|
|
@@ -141,10 +125,6 @@ export declare class Trie<R = any> extends IterableElementBase<string, R, Trie<R
|
|
|
141
125
|
* The clear function resets the size of the Trie to 0 and creates a new root TrieNode.
|
|
142
126
|
*/
|
|
143
127
|
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.
|
|
147
|
-
*/
|
|
148
128
|
/**
|
|
149
129
|
* Time Complexity: O(l), where l is the length of the word being deleted.
|
|
150
130
|
* Space Complexity: O(n) - Due to the recursive DFS approach.
|
|
@@ -154,20 +134,12 @@ export declare class Trie<R = any> extends IterableElementBase<string, R, Trie<R
|
|
|
154
134
|
* @returns {boolean} True if the word was successfully removed.
|
|
155
135
|
*/
|
|
156
136
|
delete(word: string): boolean;
|
|
157
|
-
/**
|
|
158
|
-
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
|
159
|
-
* Space Complexity: O(1) - Constant space.
|
|
160
|
-
*/
|
|
161
137
|
/**
|
|
162
138
|
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
|
163
139
|
* Space Complexity: O(1) - Constant space.
|
|
164
140
|
*
|
|
165
141
|
*/
|
|
166
142
|
getHeight(): number;
|
|
167
|
-
/**
|
|
168
|
-
* Time Complexity: O(l), where l is the length of the input prefix.
|
|
169
|
-
* Space Complexity: O(1) - Constant space.
|
|
170
|
-
*/
|
|
171
143
|
/**
|
|
172
144
|
* Time Complexity: O(l), where l is the length of the input prefix.
|
|
173
145
|
* Space Complexity: O(1) - Constant space.
|
|
@@ -177,10 +149,6 @@ export declare class Trie<R = any> extends IterableElementBase<string, R, Trie<R
|
|
|
177
149
|
* @returns {boolean} True if it's an absolute prefix in the Trie.
|
|
178
150
|
*/
|
|
179
151
|
hasPurePrefix(input: string): boolean;
|
|
180
|
-
/**
|
|
181
|
-
* Time Complexity: O(l), where l is the length of the input prefix.
|
|
182
|
-
* Space Complexity: O(1) - Constant space.
|
|
183
|
-
*/
|
|
184
152
|
/**
|
|
185
153
|
* Time Complexity: O(l), where l is the length of the input prefix.
|
|
186
154
|
* Space Complexity: O(1) - Constant space.
|
|
@@ -190,10 +158,6 @@ export declare class Trie<R = any> extends IterableElementBase<string, R, Trie<R
|
|
|
190
158
|
* @returns {boolean} True if it's a prefix in the Trie.
|
|
191
159
|
*/
|
|
192
160
|
hasPrefix(input: string): boolean;
|
|
193
|
-
/**
|
|
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.
|
|
196
|
-
*/
|
|
197
161
|
/**
|
|
198
162
|
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
|
199
163
|
* Space Complexity: O(l), where l is the length of the input prefix.
|
|
@@ -203,10 +167,6 @@ export declare class Trie<R = any> extends IterableElementBase<string, R, Trie<R
|
|
|
203
167
|
* @returns {boolean} True if it's a common prefix in the Trie.
|
|
204
168
|
*/
|
|
205
169
|
hasCommonPrefix(input: string): boolean;
|
|
206
|
-
/**
|
|
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.
|
|
209
|
-
*/
|
|
210
170
|
/**
|
|
211
171
|
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
|
212
172
|
* Space Complexity: O(l), where l is the length of the longest common prefix.
|
|
@@ -215,10 +175,6 @@ export declare class Trie<R = any> extends IterableElementBase<string, R, Trie<R
|
|
|
215
175
|
* @returns {string} The longest common prefix found in the Trie.
|
|
216
176
|
*/
|
|
217
177
|
getLongestCommonPrefix(): string;
|
|
218
|
-
/**
|
|
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.
|
|
221
|
-
*/
|
|
222
178
|
/**
|
|
223
179
|
* Time Complexity: O(w * l), where w is the number of words retrieved, and l is the average length of the words.
|
|
224
180
|
* Space Complexity: O(w * l) - The space required for the output array.
|
|
@@ -231,10 +187,6 @@ export declare class Trie<R = any> extends IterableElementBase<string, R, Trie<R
|
|
|
231
187
|
* @returns {string[]} an array of strings.
|
|
232
188
|
*/
|
|
233
189
|
getWords(prefix?: string, max?: number, isAllWhenEmptyPrefix?: boolean): string[];
|
|
234
|
-
/**
|
|
235
|
-
* Time Complexity: O(n)
|
|
236
|
-
* Space Complexity: O(n)
|
|
237
|
-
*/
|
|
238
190
|
/**
|
|
239
191
|
* Time Complexity: O(n)
|
|
240
192
|
* Space Complexity: O(n)
|
|
@@ -244,10 +196,6 @@ export declare class Trie<R = any> extends IterableElementBase<string, R, Trie<R
|
|
|
244
196
|
* @returns A new instance of the Trie class is being returned.
|
|
245
197
|
*/
|
|
246
198
|
clone(): Trie<R>;
|
|
247
|
-
/**
|
|
248
|
-
* Time Complexity: O(n)
|
|
249
|
-
* Space Complexity: O(n)
|
|
250
|
-
*/
|
|
251
199
|
/**
|
|
252
200
|
* Time Complexity: O(n)
|
|
253
201
|
* Space Complexity: O(n)
|
|
@@ -263,10 +211,6 @@ export declare class Trie<R = any> extends IterableElementBase<string, R, Trie<R
|
|
|
263
211
|
* @returns The `filter` method is returning an array of strings (`string[]`).
|
|
264
212
|
*/
|
|
265
213
|
filter(predicate: ElementCallback<string, R, boolean, Trie<R>>, thisArg?: any): Trie<R>;
|
|
266
|
-
/**
|
|
267
|
-
* Time Complexity: O(n)
|
|
268
|
-
* Space Complexity: O(n)
|
|
269
|
-
*/
|
|
270
214
|
/**
|
|
271
215
|
* Time Complexity: O(n)
|
|
272
216
|
* Space Complexity: O(n)
|
|
@@ -286,10 +230,6 @@ export declare class Trie<R = any> extends IterableElementBase<string, R, Trie<R
|
|
|
286
230
|
* @returns a new Trie object.
|
|
287
231
|
*/
|
|
288
232
|
map<RM>(callback: ElementCallback<string, R, string, Trie<R>>, toElementFn?: (rawElement: RM) => string, thisArg?: any): Trie<RM>;
|
|
289
|
-
/**
|
|
290
|
-
* Time Complexity: O(n)
|
|
291
|
-
* Space Complexity: O(n)
|
|
292
|
-
*/
|
|
293
233
|
/**
|
|
294
234
|
* Time Complexity: O(n)
|
|
295
235
|
* Space Complexity: O(n)
|
|
@@ -298,10 +238,6 @@ export declare class Trie<R = any> extends IterableElementBase<string, R, Trie<R
|
|
|
298
238
|
* trie data structure and yields all the paths to the end nodes.
|
|
299
239
|
*/
|
|
300
240
|
protected _getIterator(): IterableIterator<string>;
|
|
301
|
-
/**
|
|
302
|
-
* Time Complexity: O(l), where l is the length of the input string.
|
|
303
|
-
* Space Complexity: O(1) - Constant space.
|
|
304
|
-
*/
|
|
305
241
|
/**
|
|
306
242
|
* Time Complexity: O(l), where l is the length of the input string.
|
|
307
243
|
* Space Complexity: O(1) - Constant space.
|
|
@@ -123,10 +123,6 @@ export class Trie extends IterableElementBase {
|
|
|
123
123
|
get root() {
|
|
124
124
|
return this._root;
|
|
125
125
|
}
|
|
126
|
-
/**
|
|
127
|
-
* Time Complexity: O(l), where l is the length of the word being added.
|
|
128
|
-
* Space Complexity: O(l) - Each character in the word adds a TrieNode.
|
|
129
|
-
*/
|
|
130
126
|
/**
|
|
131
127
|
* Time Complexity: O(l), where l is the length of the word being added.
|
|
132
128
|
* Space Complexity: O(l) - Each character in the word adds a TrieNode.
|
|
@@ -154,10 +150,6 @@ export class Trie extends IterableElementBase {
|
|
|
154
150
|
}
|
|
155
151
|
return isNewWord;
|
|
156
152
|
}
|
|
157
|
-
/**
|
|
158
|
-
* Time Complexity: O(l), where l is the length of the input word.
|
|
159
|
-
* Space Complexity: O(1) - Constant space.
|
|
160
|
-
*/
|
|
161
153
|
/**
|
|
162
154
|
* Time Complexity: O(l), where l is the length of the input word.
|
|
163
155
|
* Space Complexity: O(1) - Constant space.
|
|
@@ -177,10 +169,6 @@ export class Trie extends IterableElementBase {
|
|
|
177
169
|
}
|
|
178
170
|
return cur.isEnd;
|
|
179
171
|
}
|
|
180
|
-
/**
|
|
181
|
-
* Time Complexity: O(1)
|
|
182
|
-
* Space Complexity: O(1)
|
|
183
|
-
*/
|
|
184
172
|
/**
|
|
185
173
|
* Time Complexity: O(1)
|
|
186
174
|
* Space Complexity: O(1)
|
|
@@ -191,10 +179,6 @@ export class Trie extends IterableElementBase {
|
|
|
191
179
|
isEmpty() {
|
|
192
180
|
return this.size === 0;
|
|
193
181
|
}
|
|
194
|
-
/**
|
|
195
|
-
* Time Complexity: O(1)
|
|
196
|
-
* Space Complexity: O(1)
|
|
197
|
-
*/
|
|
198
182
|
/**
|
|
199
183
|
* Time Complexity: O(1)
|
|
200
184
|
* Space Complexity: O(1)
|
|
@@ -205,10 +189,6 @@ export class Trie extends IterableElementBase {
|
|
|
205
189
|
this._size = 0;
|
|
206
190
|
this._root = new TrieNode('');
|
|
207
191
|
}
|
|
208
|
-
/**
|
|
209
|
-
* Time Complexity: O(l), where l is the length of the word being deleted.
|
|
210
|
-
* Space Complexity: O(n) - Due to the recursive DFS approach.
|
|
211
|
-
*/
|
|
212
192
|
/**
|
|
213
193
|
* Time Complexity: O(l), where l is the length of the word being deleted.
|
|
214
194
|
* Space Complexity: O(n) - Due to the recursive DFS approach.
|
|
@@ -252,10 +232,6 @@ export class Trie extends IterableElementBase {
|
|
|
252
232
|
}
|
|
253
233
|
return isDeleted;
|
|
254
234
|
}
|
|
255
|
-
/**
|
|
256
|
-
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
|
257
|
-
* Space Complexity: O(1) - Constant space.
|
|
258
|
-
*/
|
|
259
235
|
/**
|
|
260
236
|
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
|
261
237
|
* Space Complexity: O(1) - Constant space.
|
|
@@ -280,10 +256,6 @@ export class Trie extends IterableElementBase {
|
|
|
280
256
|
}
|
|
281
257
|
return maxDepth;
|
|
282
258
|
}
|
|
283
|
-
/**
|
|
284
|
-
* Time Complexity: O(l), where l is the length of the input prefix.
|
|
285
|
-
* Space Complexity: O(1) - Constant space.
|
|
286
|
-
*/
|
|
287
259
|
/**
|
|
288
260
|
* Time Complexity: O(l), where l is the length of the input prefix.
|
|
289
261
|
* Space Complexity: O(1) - Constant space.
|
|
@@ -303,10 +275,6 @@ export class Trie extends IterableElementBase {
|
|
|
303
275
|
}
|
|
304
276
|
return !cur.isEnd;
|
|
305
277
|
}
|
|
306
|
-
/**
|
|
307
|
-
* Time Complexity: O(l), where l is the length of the input prefix.
|
|
308
|
-
* Space Complexity: O(1) - Constant space.
|
|
309
|
-
*/
|
|
310
278
|
/**
|
|
311
279
|
* Time Complexity: O(l), where l is the length of the input prefix.
|
|
312
280
|
* Space Complexity: O(1) - Constant space.
|
|
@@ -326,10 +294,6 @@ export class Trie extends IterableElementBase {
|
|
|
326
294
|
}
|
|
327
295
|
return true;
|
|
328
296
|
}
|
|
329
|
-
/**
|
|
330
|
-
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
|
331
|
-
* Space Complexity: O(l), where l is the length of the input prefix.
|
|
332
|
-
*/
|
|
333
297
|
/**
|
|
334
298
|
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
|
335
299
|
* Space Complexity: O(l), where l is the length of the input prefix.
|
|
@@ -355,10 +319,6 @@ export class Trie extends IterableElementBase {
|
|
|
355
319
|
dfs(this.root);
|
|
356
320
|
return commonPre === input;
|
|
357
321
|
}
|
|
358
|
-
/**
|
|
359
|
-
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
|
360
|
-
* Space Complexity: O(l), where l is the length of the longest common prefix.
|
|
361
|
-
*/
|
|
362
322
|
/**
|
|
363
323
|
* Time Complexity: O(n), where n is the total number of nodes in the trie.
|
|
364
324
|
* Space Complexity: O(l), where l is the length of the longest common prefix.
|
|
@@ -380,10 +340,6 @@ export class Trie extends IterableElementBase {
|
|
|
380
340
|
dfs(this.root);
|
|
381
341
|
return commonPre;
|
|
382
342
|
}
|
|
383
|
-
/**
|
|
384
|
-
* Time Complexity: O(w * l), where w is the number of words retrieved, and l is the average length of the words.
|
|
385
|
-
* Space Complexity: O(w * l) - The space required for the output array.
|
|
386
|
-
*/
|
|
387
343
|
/**
|
|
388
344
|
* Time Complexity: O(w * l), where w is the number of words retrieved, and l is the average length of the words.
|
|
389
345
|
* Space Complexity: O(w * l) - The space required for the output array.
|
|
@@ -430,10 +386,6 @@ export class Trie extends IterableElementBase {
|
|
|
430
386
|
dfs(startNode, prefix);
|
|
431
387
|
return words;
|
|
432
388
|
}
|
|
433
|
-
/**
|
|
434
|
-
* Time Complexity: O(n)
|
|
435
|
-
* Space Complexity: O(n)
|
|
436
|
-
*/
|
|
437
389
|
/**
|
|
438
390
|
* Time Complexity: O(n)
|
|
439
391
|
* Space Complexity: O(n)
|
|
@@ -445,10 +397,6 @@ export class Trie extends IterableElementBase {
|
|
|
445
397
|
clone() {
|
|
446
398
|
return new Trie(this, { caseSensitive: this.caseSensitive, toElementFn: this.toElementFn });
|
|
447
399
|
}
|
|
448
|
-
/**
|
|
449
|
-
* Time Complexity: O(n)
|
|
450
|
-
* Space Complexity: O(n)
|
|
451
|
-
*/
|
|
452
400
|
/**
|
|
453
401
|
* Time Complexity: O(n)
|
|
454
402
|
* Space Complexity: O(n)
|
|
@@ -474,10 +422,6 @@ export class Trie extends IterableElementBase {
|
|
|
474
422
|
}
|
|
475
423
|
return results;
|
|
476
424
|
}
|
|
477
|
-
/**
|
|
478
|
-
* Time Complexity: O(n)
|
|
479
|
-
* Space Complexity: O(n)
|
|
480
|
-
*/
|
|
481
425
|
/**
|
|
482
426
|
* Time Complexity: O(n)
|
|
483
427
|
* Space Complexity: O(n)
|
|
@@ -505,10 +449,6 @@ export class Trie extends IterableElementBase {
|
|
|
505
449
|
}
|
|
506
450
|
return newTrie;
|
|
507
451
|
}
|
|
508
|
-
/**
|
|
509
|
-
* Time Complexity: O(n)
|
|
510
|
-
* Space Complexity: O(n)
|
|
511
|
-
*/
|
|
512
452
|
/**
|
|
513
453
|
* Time Complexity: O(n)
|
|
514
454
|
* Space Complexity: O(n)
|
|
@@ -527,10 +467,6 @@ export class Trie extends IterableElementBase {
|
|
|
527
467
|
}
|
|
528
468
|
yield* _dfs(this.root, '');
|
|
529
469
|
}
|
|
530
|
-
/**
|
|
531
|
-
* Time Complexity: O(l), where l is the length of the input string.
|
|
532
|
-
* Space Complexity: O(1) - Constant space.
|
|
533
|
-
*/
|
|
534
470
|
/**
|
|
535
471
|
* Time Complexity: O(l), where l is the length of the input string.
|
|
536
472
|
* Space Complexity: O(1) - Constant space.
|
|
@@ -23,3 +23,11 @@ export type BinaryTreeDeleteResult<NODE> = {
|
|
|
23
23
|
needBalanced: OptBTNOrNull<NODE>;
|
|
24
24
|
};
|
|
25
25
|
export type BTNCallback<NODE, D = any> = (node: NODE) => D;
|
|
26
|
+
export declare enum DFSOperation {
|
|
27
|
+
VISIT = 0,
|
|
28
|
+
PROCESS = 1
|
|
29
|
+
}
|
|
30
|
+
export type DFSStackItem<NODE> = {
|
|
31
|
+
opt: DFSOperation;
|
|
32
|
+
node: OptBTNOrNull<NODE>;
|
|
33
|
+
};
|