data-structure-typed 1.52.4 → 1.52.5

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.
Files changed (181) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +13 -13
  3. package/README_zh-CN.md +216 -26
  4. package/benchmark/report.html +13 -13
  5. package/benchmark/report.json +158 -158
  6. package/dist/cjs/data-structures/base/iterable-element-base.d.ts +1 -37
  7. package/dist/cjs/data-structures/base/iterable-element-base.js +1 -37
  8. package/dist/cjs/data-structures/base/iterable-element-base.js.map +1 -1
  9. package/dist/cjs/data-structures/base/iterable-entry-base.d.ts +2 -54
  10. package/dist/cjs/data-structures/base/iterable-entry-base.js +1 -49
  11. package/dist/cjs/data-structures/base/iterable-entry-base.js.map +1 -1
  12. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -32
  13. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +9 -41
  14. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  15. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +0 -46
  16. package/dist/cjs/data-structures/binary-tree/avl-tree.js +0 -46
  17. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  18. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +82 -147
  19. package/dist/cjs/data-structures/binary-tree/binary-tree.js +299 -331
  20. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  21. package/dist/cjs/data-structures/binary-tree/bst.d.ts +1 -40
  22. package/dist/cjs/data-structures/binary-tree/bst.js +12 -44
  23. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  24. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +0 -48
  25. package/dist/cjs/data-structures/binary-tree/rb-tree.js +2 -50
  26. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  27. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +0 -32
  28. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +9 -41
  29. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  30. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +0 -75
  31. package/dist/cjs/data-structures/graph/abstract-graph.js +0 -75
  32. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  33. package/dist/cjs/data-structures/graph/directed-graph.d.ts +0 -98
  34. package/dist/cjs/data-structures/graph/directed-graph.js +0 -98
  35. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  36. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +0 -50
  37. package/dist/cjs/data-structures/graph/undirected-graph.js +0 -50
  38. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  39. package/dist/cjs/data-structures/hash/hash-map.d.ts +5 -92
  40. package/dist/cjs/data-structures/hash/hash-map.js +27 -111
  41. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  42. package/dist/cjs/data-structures/heap/heap.d.ts +0 -32
  43. package/dist/cjs/data-structures/heap/heap.js +0 -32
  44. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  45. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +5 -88
  46. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +5 -88
  47. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  48. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +1 -83
  49. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +2 -84
  50. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  51. package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +1 -35
  52. package/dist/cjs/data-structures/linked-list/skip-linked-list.js +1 -35
  53. package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +1 -1
  54. package/dist/cjs/data-structures/queue/deque.d.ts +1 -98
  55. package/dist/cjs/data-structures/queue/deque.js +3 -99
  56. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  57. package/dist/cjs/data-structures/queue/queue.d.ts +1 -54
  58. package/dist/cjs/data-structures/queue/queue.js +0 -53
  59. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  60. package/dist/cjs/data-structures/stack/stack.d.ts +1 -34
  61. package/dist/cjs/data-structures/stack/stack.js +1 -34
  62. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  63. package/dist/cjs/data-structures/tree/tree.js +0 -1
  64. package/dist/cjs/data-structures/tree/tree.js.map +1 -1
  65. package/dist/cjs/data-structures/trie/trie.d.ts +0 -64
  66. package/dist/cjs/data-structures/trie/trie.js +0 -64
  67. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  68. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +8 -0
  69. package/dist/cjs/types/data-structures/binary-tree/binary-tree.js +6 -0
  70. package/dist/cjs/types/data-structures/binary-tree/binary-tree.js.map +1 -1
  71. package/dist/cjs/types/utils/utils.d.ts +13 -12
  72. package/dist/cjs/utils/number.d.ts +13 -0
  73. package/dist/cjs/utils/number.js +13 -0
  74. package/dist/cjs/utils/number.js.map +1 -1
  75. package/dist/cjs/utils/utils.d.ts +125 -3
  76. package/dist/cjs/utils/utils.js +177 -21
  77. package/dist/cjs/utils/utils.js.map +1 -1
  78. package/dist/mjs/data-structures/base/iterable-element-base.d.ts +1 -37
  79. package/dist/mjs/data-structures/base/iterable-element-base.js +1 -37
  80. package/dist/mjs/data-structures/base/iterable-entry-base.d.ts +2 -54
  81. package/dist/mjs/data-structures/base/iterable-entry-base.js +1 -49
  82. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -32
  83. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +9 -41
  84. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +0 -46
  85. package/dist/mjs/data-structures/binary-tree/avl-tree.js +0 -46
  86. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +82 -147
  87. package/dist/mjs/data-structures/binary-tree/binary-tree.js +298 -332
  88. package/dist/mjs/data-structures/binary-tree/bst.d.ts +1 -40
  89. package/dist/mjs/data-structures/binary-tree/bst.js +12 -44
  90. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +0 -48
  91. package/dist/mjs/data-structures/binary-tree/rb-tree.js +2 -50
  92. package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +0 -32
  93. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +9 -41
  94. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +0 -75
  95. package/dist/mjs/data-structures/graph/abstract-graph.js +0 -75
  96. package/dist/mjs/data-structures/graph/directed-graph.d.ts +0 -98
  97. package/dist/mjs/data-structures/graph/directed-graph.js +0 -98
  98. package/dist/mjs/data-structures/graph/undirected-graph.d.ts +0 -50
  99. package/dist/mjs/data-structures/graph/undirected-graph.js +0 -50
  100. package/dist/mjs/data-structures/hash/hash-map.d.ts +5 -92
  101. package/dist/mjs/data-structures/hash/hash-map.js +27 -111
  102. package/dist/mjs/data-structures/heap/heap.d.ts +0 -32
  103. package/dist/mjs/data-structures/heap/heap.js +0 -32
  104. package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +5 -88
  105. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +5 -88
  106. package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +1 -83
  107. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +2 -84
  108. package/dist/mjs/data-structures/linked-list/skip-linked-list.d.ts +1 -35
  109. package/dist/mjs/data-structures/linked-list/skip-linked-list.js +1 -35
  110. package/dist/mjs/data-structures/queue/deque.d.ts +1 -98
  111. package/dist/mjs/data-structures/queue/deque.js +3 -99
  112. package/dist/mjs/data-structures/queue/queue.d.ts +1 -54
  113. package/dist/mjs/data-structures/queue/queue.js +0 -53
  114. package/dist/mjs/data-structures/stack/stack.d.ts +1 -34
  115. package/dist/mjs/data-structures/stack/stack.js +1 -34
  116. package/dist/mjs/data-structures/tree/tree.js +0 -1
  117. package/dist/mjs/data-structures/trie/trie.d.ts +0 -64
  118. package/dist/mjs/data-structures/trie/trie.js +0 -64
  119. package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +8 -0
  120. package/dist/mjs/types/data-structures/binary-tree/binary-tree.js +5 -1
  121. package/dist/mjs/types/utils/utils.d.ts +13 -12
  122. package/dist/mjs/utils/number.d.ts +13 -0
  123. package/dist/mjs/utils/number.js +13 -0
  124. package/dist/mjs/utils/utils.d.ts +125 -3
  125. package/dist/mjs/utils/utils.js +177 -21
  126. package/dist/umd/data-structure-typed.js +408 -1474
  127. package/dist/umd/data-structure-typed.min.js +5 -4
  128. package/dist/umd/data-structure-typed.min.js.map +1 -1
  129. package/package.json +6 -6
  130. package/src/data-structures/base/iterable-element-base.ts +2 -42
  131. package/src/data-structures/base/iterable-entry-base.ts +3 -62
  132. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +8 -48
  133. package/src/data-structures/binary-tree/avl-tree.ts +0 -57
  134. package/src/data-structures/binary-tree/binary-tree.ts +329 -358
  135. package/src/data-structures/binary-tree/bst.ts +11 -54
  136. package/src/data-structures/binary-tree/rb-tree.ts +2 -62
  137. package/src/data-structures/binary-tree/tree-multi-map.ts +8 -48
  138. package/src/data-structures/graph/abstract-graph.ts +0 -92
  139. package/src/data-structures/graph/directed-graph.ts +0 -122
  140. package/src/data-structures/graph/undirected-graph.ts +0 -62
  141. package/src/data-structures/hash/hash-map.ts +29 -133
  142. package/src/data-structures/heap/heap.ts +0 -40
  143. package/src/data-structures/linked-list/doubly-linked-list.ts +5 -112
  144. package/src/data-structures/linked-list/singly-linked-list.ts +2 -104
  145. package/src/data-structures/linked-list/skip-linked-list.ts +1 -44
  146. package/src/data-structures/queue/deque.ts +2 -125
  147. package/src/data-structures/queue/queue.ts +1 -68
  148. package/src/data-structures/stack/stack.ts +1 -43
  149. package/src/data-structures/tree/tree.ts +1 -1
  150. package/src/data-structures/trie/trie.ts +0 -80
  151. package/src/types/data-structures/binary-tree/binary-tree.ts +8 -1
  152. package/src/types/utils/utils.ts +17 -15
  153. package/src/utils/number.ts +13 -0
  154. package/src/utils/utils.ts +174 -18
  155. package/test/config.ts +8 -0
  156. package/test/integration/all-in-one.test.ts +1 -1
  157. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +13 -13
  158. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +18 -13
  159. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +471 -64
  160. package/test/unit/data-structures/binary-tree/bst.test.ts +167 -23
  161. package/test/unit/data-structures/binary-tree/overall.test.ts +1 -1
  162. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +136 -13
  163. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +18 -13
  164. package/test/unit/data-structures/graph/directed-graph.test.ts +46 -32
  165. package/test/unit/data-structures/graph/map-graph.test.ts +24 -2
  166. package/test/unit/data-structures/graph/undirected-graph.test.ts +24 -24
  167. package/test/unit/data-structures/hash/hash-map.test.ts +225 -35
  168. package/test/unit/data-structures/heap/heap.test.ts +47 -39
  169. package/test/unit/data-structures/heap/min-heap.test.ts +5 -5
  170. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +34 -4
  171. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +32 -0
  172. package/test/unit/data-structures/matrix/matrix.test.ts +35 -5
  173. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +31 -0
  174. package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +18 -0
  175. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +17 -0
  176. package/test/unit/data-structures/queue/deque.test.ts +288 -47
  177. package/test/unit/data-structures/queue/queue.test.ts +62 -37
  178. package/test/unit/data-structures/stack/stack.test.ts +30 -5
  179. package/test/unit/data-structures/tree/tree.test.ts +58 -0
  180. package/test/unit/data-structures/trie/trie.test.ts +46 -5
  181. 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)
@@ -12,7 +12,6 @@ export class TreeNode {
12
12
  constructor(key, value, children) {
13
13
  this._key = key;
14
14
  this._value = value || undefined;
15
- this._children = children || [];
16
15
  }
17
16
  _key;
18
17
  /**
@@ -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
+ };
@@ -1 +1,5 @@
1
- export {};
1
+ export var DFSOperation;
2
+ (function (DFSOperation) {
3
+ DFSOperation[DFSOperation["VISIT"] = 0] = "VISIT";
4
+ DFSOperation[DFSOperation["PROCESS"] = 1] = "PROCESS";
5
+ })(DFSOperation || (DFSOperation = {}));