data-structure-typed 1.52.3 → 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 +2 -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 +29 -115
  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 +5 -58
  58. package/dist/cjs/data-structures/queue/queue.js +4 -57
  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 +29 -115
  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 +5 -58
  113. package/dist/mjs/data-structures/queue/queue.js +4 -57
  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 +414 -1482
  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 +31 -139
  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 +5 -72
  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
@@ -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.
@@ -124,10 +124,6 @@ class Trie extends base_1.IterableElementBase {
124
124
  get root() {
125
125
  return this._root;
126
126
  }
127
- /**
128
- * Time Complexity: O(l), where l is the length of the word being added.
129
- * Space Complexity: O(l) - Each character in the word adds a TrieNode.
130
- */
131
127
  /**
132
128
  * Time Complexity: O(l), where l is the length of the word being added.
133
129
  * Space Complexity: O(l) - Each character in the word adds a TrieNode.
@@ -155,10 +151,6 @@ class Trie extends base_1.IterableElementBase {
155
151
  }
156
152
  return isNewWord;
157
153
  }
158
- /**
159
- * Time Complexity: O(l), where l is the length of the input word.
160
- * Space Complexity: O(1) - Constant space.
161
- */
162
154
  /**
163
155
  * Time Complexity: O(l), where l is the length of the input word.
164
156
  * Space Complexity: O(1) - Constant space.
@@ -178,10 +170,6 @@ class Trie extends base_1.IterableElementBase {
178
170
  }
179
171
  return cur.isEnd;
180
172
  }
181
- /**
182
- * Time Complexity: O(1)
183
- * Space Complexity: O(1)
184
- */
185
173
  /**
186
174
  * Time Complexity: O(1)
187
175
  * Space Complexity: O(1)
@@ -192,10 +180,6 @@ class Trie extends base_1.IterableElementBase {
192
180
  isEmpty() {
193
181
  return this.size === 0;
194
182
  }
195
- /**
196
- * Time Complexity: O(1)
197
- * Space Complexity: O(1)
198
- */
199
183
  /**
200
184
  * Time Complexity: O(1)
201
185
  * Space Complexity: O(1)
@@ -206,10 +190,6 @@ class Trie extends base_1.IterableElementBase {
206
190
  this._size = 0;
207
191
  this._root = new TrieNode('');
208
192
  }
209
- /**
210
- * Time Complexity: O(l), where l is the length of the word being deleted.
211
- * Space Complexity: O(n) - Due to the recursive DFS approach.
212
- */
213
193
  /**
214
194
  * Time Complexity: O(l), where l is the length of the word being deleted.
215
195
  * Space Complexity: O(n) - Due to the recursive DFS approach.
@@ -253,10 +233,6 @@ class Trie extends base_1.IterableElementBase {
253
233
  }
254
234
  return isDeleted;
255
235
  }
256
- /**
257
- * Time Complexity: O(n), where n is the total number of nodes in the trie.
258
- * Space Complexity: O(1) - Constant space.
259
- */
260
236
  /**
261
237
  * Time Complexity: O(n), where n is the total number of nodes in the trie.
262
238
  * Space Complexity: O(1) - Constant space.
@@ -281,10 +257,6 @@ class Trie extends base_1.IterableElementBase {
281
257
  }
282
258
  return maxDepth;
283
259
  }
284
- /**
285
- * Time Complexity: O(l), where l is the length of the input prefix.
286
- * Space Complexity: O(1) - Constant space.
287
- */
288
260
  /**
289
261
  * Time Complexity: O(l), where l is the length of the input prefix.
290
262
  * Space Complexity: O(1) - Constant space.
@@ -304,10 +276,6 @@ class Trie extends base_1.IterableElementBase {
304
276
  }
305
277
  return !cur.isEnd;
306
278
  }
307
- /**
308
- * Time Complexity: O(l), where l is the length of the input prefix.
309
- * Space Complexity: O(1) - Constant space.
310
- */
311
279
  /**
312
280
  * Time Complexity: O(l), where l is the length of the input prefix.
313
281
  * Space Complexity: O(1) - Constant space.
@@ -327,10 +295,6 @@ class Trie extends base_1.IterableElementBase {
327
295
  }
328
296
  return true;
329
297
  }
330
- /**
331
- * Time Complexity: O(n), where n is the total number of nodes in the trie.
332
- * Space Complexity: O(l), where l is the length of the input prefix.
333
- */
334
298
  /**
335
299
  * Time Complexity: O(n), where n is the total number of nodes in the trie.
336
300
  * Space Complexity: O(l), where l is the length of the input prefix.
@@ -356,10 +320,6 @@ class Trie extends base_1.IterableElementBase {
356
320
  dfs(this.root);
357
321
  return commonPre === input;
358
322
  }
359
- /**
360
- * Time Complexity: O(n), where n is the total number of nodes in the trie.
361
- * Space Complexity: O(l), where l is the length of the longest common prefix.
362
- */
363
323
  /**
364
324
  * Time Complexity: O(n), where n is the total number of nodes in the trie.
365
325
  * Space Complexity: O(l), where l is the length of the longest common prefix.
@@ -381,10 +341,6 @@ class Trie extends base_1.IterableElementBase {
381
341
  dfs(this.root);
382
342
  return commonPre;
383
343
  }
384
- /**
385
- * Time Complexity: O(w * l), where w is the number of words retrieved, and l is the average length of the words.
386
- * Space Complexity: O(w * l) - The space required for the output array.
387
- */
388
344
  /**
389
345
  * Time Complexity: O(w * l), where w is the number of words retrieved, and l is the average length of the words.
390
346
  * Space Complexity: O(w * l) - The space required for the output array.
@@ -431,10 +387,6 @@ class Trie extends base_1.IterableElementBase {
431
387
  dfs(startNode, prefix);
432
388
  return words;
433
389
  }
434
- /**
435
- * Time Complexity: O(n)
436
- * Space Complexity: O(n)
437
- */
438
390
  /**
439
391
  * Time Complexity: O(n)
440
392
  * Space Complexity: O(n)
@@ -446,10 +398,6 @@ class Trie extends base_1.IterableElementBase {
446
398
  clone() {
447
399
  return new Trie(this, { caseSensitive: this.caseSensitive, toElementFn: this.toElementFn });
448
400
  }
449
- /**
450
- * Time Complexity: O(n)
451
- * Space Complexity: O(n)
452
- */
453
401
  /**
454
402
  * Time Complexity: O(n)
455
403
  * Space Complexity: O(n)
@@ -475,10 +423,6 @@ class Trie extends base_1.IterableElementBase {
475
423
  }
476
424
  return results;
477
425
  }
478
- /**
479
- * Time Complexity: O(n)
480
- * Space Complexity: O(n)
481
- */
482
426
  /**
483
427
  * Time Complexity: O(n)
484
428
  * Space Complexity: O(n)
@@ -506,10 +450,6 @@ class Trie extends base_1.IterableElementBase {
506
450
  }
507
451
  return newTrie;
508
452
  }
509
- /**
510
- * Time Complexity: O(n)
511
- * Space Complexity: O(n)
512
- */
513
453
  /**
514
454
  * Time Complexity: O(n)
515
455
  * Space Complexity: O(n)
@@ -528,10 +468,6 @@ class Trie extends base_1.IterableElementBase {
528
468
  }
529
469
  yield* _dfs(this.root, '');
530
470
  }
531
- /**
532
- * Time Complexity: O(l), where l is the length of the input string.
533
- * Space Complexity: O(1) - Constant space.
534
- */
535
471
  /**
536
472
  * Time Complexity: O(l), where l is the length of the input string.
537
473
  * Space Complexity: O(1) - Constant space.
@@ -1 +1 @@
1
- {"version":3,"file":"trie.js","sourceRoot":"","sources":["../../../../src/data-structures/trie/trie.ts"],"names":[],"mappings":";;;AAQA,kCAA8C;AAE9C;;;GAGG;AACH,MAAa,QAAQ;IACnB,YAAY,GAAW;QACrB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;IAC/C,CAAC;IAID;;;OAGG;IACH,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACH,IAAI,GAAG,CAAC,KAAa;QACnB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;IACpB,CAAC;IAID;;;;OAIG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;;;;OAMG;IACH,IAAI,QAAQ,CAAC,KAA4B;QACvC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,CAAC;IAID;;;OAGG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACH,IAAI,KAAK,CAAC,KAAc;QACtB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;CACF;AAlED,4BAkEC;AAED;;;;;;;;;;;;GAYG;AACH,MAAa,IAAc,SAAQ,0BAAuC;IACxE;;;;;O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IAAI,EAAE,EAAE,CAAC,CAAC;IAC7B,CAAC;IAED;;;;;;OAMG;IACO,YAAY,CAAC,GAAW;QAChC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;YACzB,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,+CAA+C;QAC1E,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAvaD,oBAuaC"}
@@ -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,3 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DFSOperation = void 0;
4
+ var DFSOperation;
5
+ (function (DFSOperation) {
6
+ DFSOperation[DFSOperation["VISIT"] = 0] = "VISIT";
7
+ DFSOperation[DFSOperation["PROCESS"] = 1] = "PROCESS";
8
+ })(DFSOperation || (exports.DFSOperation = DFSOperation = {}));
3
9
  //# sourceMappingURL=binary-tree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"binary-tree.js","sourceRoot":"","sources":["../../../../../src/types/data-structures/binary-tree/binary-tree.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"binary-tree.js","sourceRoot":"","sources":["../../../../../src/types/data-structures/binary-tree/binary-tree.ts"],"names":[],"mappings":";;;AAgCA,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,iDAAS,CAAA;IACT,qDAAW,CAAA;AACb,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB"}
@@ -1,17 +1,18 @@
1
- export type ToThunkFn = () => ReturnType<TrlFn>;
2
- export type Thunk = () => ReturnType<ToThunkFn> & {
3
- __THUNK__: symbol;
1
+ export type ToThunkFn<R = any> = () => R;
2
+ export type Thunk<R = any> = ToThunkFn<R> & {
3
+ __THUNK__?: symbol;
4
4
  };
5
- export type TrlFn = (...args: any[]) => any;
5
+ export type TrlFn<A extends any[] = any[], R = any> = (...args: A) => R;
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
8
  export type Any = string | number | bigint | boolean | symbol | undefined | object;
9
- export type Comparable = number | string | bigint | boolean | ({
9
+ export type ComparablePrimitive = number | bigint | string | boolean;
10
+ export type ComparableObject = {
10
11
  [key in string]: any;
11
- } & {
12
- valueOf(): Comparable;
13
- }) | ({
14
- [key in string]: any;
15
- } & {
16
- toString(): Comparable;
17
- }) | (() => Comparable);
12
+ } & ({
13
+ valueOf: () => ComparablePrimitive | ComparableObject;
14
+ toString?: () => string;
15
+ } | {
16
+ toString: () => string;
17
+ });
18
+ export type Comparable = ComparablePrimitive | Date | ComparableObject;
@@ -1 +1,14 @@
1
+ /**
2
+ * The function `toBinaryString` converts a number to a binary string representation with a specified
3
+ * number of digits.
4
+ * @param {number} num - The `num` parameter in the `toBinaryString` function represents the number
5
+ * that you want to convert to a binary string.
6
+ * @param [digit=32] - The `digit` parameter in the `toBinaryString` function represents the number of
7
+ * digits the binary string should have. By default, it is set to 32, meaning that the binary string
8
+ * will be padded with zeros at the beginning to ensure it is 32 bits long. You can provide a
9
+ * @returns The function `toBinaryString` takes a number as input and converts it to a binary string
10
+ * representation with a specified number of digits (default is 32). The binary string is padded with
11
+ * zeros at the beginning to ensure it has the specified number of digits. The function returns the
12
+ * binary string representation of the input number.
13
+ */
1
14
  export declare function toBinaryString(num: number, digit?: number): string;
@@ -1,6 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toBinaryString = toBinaryString;
4
+ /**
5
+ * The function `toBinaryString` converts a number to a binary string representation with a specified
6
+ * number of digits.
7
+ * @param {number} num - The `num` parameter in the `toBinaryString` function represents the number
8
+ * that you want to convert to a binary string.
9
+ * @param [digit=32] - The `digit` parameter in the `toBinaryString` function represents the number of
10
+ * digits the binary string should have. By default, it is set to 32, meaning that the binary string
11
+ * will be padded with zeros at the beginning to ensure it is 32 bits long. You can provide a
12
+ * @returns The function `toBinaryString` takes a number as input and converts it to a binary string
13
+ * representation with a specified number of digits (default is 32). The binary string is padded with
14
+ * zeros at the beginning to ensure it has the specified number of digits. The function returns the
15
+ * binary string representation of the input number.
16
+ */
4
17
  function toBinaryString(num, digit = 32) {
5
18
  // Convert number to binary string
6
19
  let binaryString = (num >>> 0).toString(2); // Use the unsigned right shift operator to ensure you get a binary representation of a 32-bit unsigned integer
@@ -1 +1 @@
1
- {"version":3,"file":"number.js","sourceRoot":"","sources":["../../../src/utils/number.ts"],"names":[],"mappings":";;AAAA,wCAQC;AARD,SAAgB,cAAc,CAAC,GAAW,EAAE,KAAK,GAAG,EAAE;IACpD,kCAAkC;IAClC,IAAI,YAAY,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,+GAA+G;IAE3J,uDAAuD;IACvD,YAAY,GAAG,YAAY,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAEjD,OAAO,YAAY,CAAC;AACtB,CAAC"}
1
+ {"version":3,"file":"number.js","sourceRoot":"","sources":["../../../src/utils/number.ts"],"names":[],"mappings":";;AAaA,wCAQC;AArBD;;;;;;;;;;;;GAYG;AACH,SAAgB,cAAc,CAAC,GAAW,EAAE,KAAK,GAAG,EAAE;IACpD,kCAAkC;IAClC,IAAI,YAAY,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,+GAA+G;IAE3J,uDAAuD;IACvD,YAAY,GAAG,YAAY,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAEjD,OAAO,YAAY,CAAC;AACtB,CAAC"}
@@ -6,21 +6,143 @@
6
6
  * @license MIT License
7
7
  */
8
8
  import type { Comparable, Thunk, ToThunkFn, TrlAsyncFn, TrlFn } from '../types';
9
+ /**
10
+ * The function generates a random UUID (Universally Unique Identifier) in TypeScript.
11
+ * @returns A randomly generated UUID (Universally Unique Identifier) in the format
12
+ * 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' where each 'x' is replaced with a random hexadecimal
13
+ * character.
14
+ */
9
15
  export declare const uuidV4: () => string;
16
+ /**
17
+ * The `arrayRemove` function removes elements from an array based on a specified predicate function
18
+ * and returns the removed elements.
19
+ * @param {T[]} array - An array of elements that you want to filter based on the provided predicate
20
+ * function.
21
+ * @param predicate - The `predicate` parameter is a function that takes three arguments:
22
+ * @returns The `arrayRemove` function returns an array containing the elements that satisfy the given
23
+ * `predicate` function.
24
+ */
10
25
  export declare const arrayRemove: <T>(array: T[], predicate: (item: T, index: number, array: T[]) => boolean) => T[];
11
26
  export declare const THUNK_SYMBOL: unique symbol;
27
+ /**
28
+ * The function `isThunk` checks if a given value is a function with a specific symbol property.
29
+ * @param {any} fnOrValue - The `fnOrValue` parameter in the `isThunk` function can be either a
30
+ * function or a value that you want to check if it is a thunk. Thunks are functions that are wrapped
31
+ * around a value or computation for lazy evaluation. The function checks if the `fnOrValue` is
32
+ * @returns The function `isThunk` is checking if the input `fnOrValue` is a function and if it has a
33
+ * property `__THUNK__` equal to `THUNK_SYMBOL`. The return value will be `true` if both conditions are
34
+ * met, otherwise it will be `false`.
35
+ */
12
36
  export declare const isThunk: (fnOrValue: any) => boolean;
37
+ /**
38
+ * The `toThunk` function in TypeScript converts a function into a thunk by wrapping it in a closure.
39
+ * @param {ToThunkFn} fn - `fn` is a function that will be converted into a thunk.
40
+ * @returns A thunk function is being returned. Thunk functions are functions that delay the evaluation
41
+ * of an expression or operation until it is explicitly called or invoked. In this case, the `toThunk`
42
+ * function takes a function `fn` as an argument and returns a thunk function that, when called, will
43
+ * execute the `fn` function provided as an argument.
44
+ */
13
45
  export declare const toThunk: (fn: ToThunkFn) => Thunk;
46
+ /**
47
+ * The `trampoline` function in TypeScript enables tail call optimization by using thunks to avoid
48
+ * stack overflow.
49
+ * @param {TrlFn} fn - The `fn` parameter in the `trampoline` function is a function that takes any
50
+ * number of arguments and returns a value.
51
+ * @returns The `trampoline` function returns an object with two properties:
52
+ * 1. A function that executes the provided function `fn` and continues to execute any thunks returned
53
+ * by `fn` until a non-thunk value is returned.
54
+ * 2. A `cont` property that is a function which creates a thunk for the provided function `fn`.
55
+ */
14
56
  export declare const trampoline: (fn: TrlFn) => ((...args: [...Parameters<TrlFn>]) => any) & {
15
- cont: (...args: [...Parameters<TrlFn>]) => Thunk;
57
+ cont: (...args: [...Parameters<TrlFn>]) => ReturnType<TrlFn>;
16
58
  };
59
+ /**
60
+ * The `trampolineAsync` function in TypeScript allows for asynchronous trampolining of a given
61
+ * function.
62
+ * @param {TrlAsyncFn} fn - The `fn` parameter in the `trampolineAsync` function is expected to be a
63
+ * function that returns a Promise. This function will be called recursively until a non-thunk value is
64
+ * returned.
65
+ * @returns The `trampolineAsync` function returns an object with two properties:
66
+ * 1. An async function that executes the provided `TrlAsyncFn` function and continues to execute any
67
+ * thunks returned by the function until a non-thunk value is returned.
68
+ * 2. A `cont` property that is a function which wraps the provided `TrlAsyncFn` function in a thunk
69
+ * and returns it.
70
+ */
17
71
  export declare const trampolineAsync: (fn: TrlAsyncFn) => ((...args: [...Parameters<TrlAsyncFn>]) => Promise<any>) & {
18
- cont: (...args: [...Parameters<TrlAsyncFn>]) => Thunk;
72
+ cont: (...args: [...Parameters<TrlAsyncFn>]) => ReturnType<TrlAsyncFn>;
19
73
  };
74
+ /**
75
+ * The function `getMSB` returns the most significant bit of a given number.
76
+ * @param {number} value - The `value` parameter is a number for which we want to find the position of
77
+ * the Most Significant Bit (MSB). The function `getMSB` takes this number as input and calculates the
78
+ * position of the MSB in its binary representation.
79
+ * @returns The function `getMSB` returns the most significant bit (MSB) of the input `value`. If the
80
+ * input value is less than or equal to 0, it returns 0. Otherwise, it calculates the position of the
81
+ * MSB using the `Math.clz32` function and bitwise left shifts 1 to that position.
82
+ */
20
83
  export declare const getMSB: (value: number) => number;
84
+ /**
85
+ * The `rangeCheck` function in TypeScript is used to validate if an index is within a specified range
86
+ * and throws a `RangeError` with a custom message if it is out of bounds.
87
+ * @param {number} index - The `index` parameter represents the value that you want to check if it
88
+ * falls within a specified range.
89
+ * @param {number} min - The `min` parameter represents the minimum value that the `index` should be
90
+ * compared against in the `rangeCheck` function.
91
+ * @param {number} max - The `max` parameter in the `rangeCheck` function represents the maximum value
92
+ * that the `index` parameter is allowed to have. If the `index` is greater than this `max` value, a
93
+ * `RangeError` will be thrown.
94
+ * @param [message=Index out of bounds.] - The `message` parameter is a string that represents the
95
+ * error message to be thrown if the index is out of bounds. By default, if no message is provided when
96
+ * calling the `rangeCheck` function, the message "Index out of bounds." will be used.
97
+ */
21
98
  export declare const rangeCheck: (index: number, min: number, max: number, message?: string) => void;
99
+ /**
100
+ * The function `throwRangeError` throws a RangeError with a custom message if called.
101
+ * @param [message=The value is off-limits.] - The `message` parameter is a string that represents the
102
+ * error message to be displayed when a `RangeError` is thrown. If no message is provided, the default
103
+ * message is 'The value is off-limits.'.
104
+ */
22
105
  export declare const throwRangeError: (message?: string) => void;
106
+ /**
107
+ * The function `isWeakKey` checks if the input is an object or a function in TypeScript.
108
+ * @param {unknown} input - The `input` parameter in the `isWeakKey` function is of type `unknown`,
109
+ * which means it can be any type. The function checks if the `input` is an object (excluding `null`)
110
+ * or a function, and returns a boolean indicating whether the `input` is a weak
111
+ * @returns The function `isWeakKey` returns a boolean value indicating whether the input is an object
112
+ * or a function.
113
+ */
23
114
  export declare const isWeakKey: (input: unknown) => input is object;
115
+ /**
116
+ * The function `calcMinUnitsRequired` calculates the minimum number of units required to accommodate a
117
+ * given total quantity based on a specified unit size.
118
+ * @param {number} totalQuantity - The `totalQuantity` parameter represents the total quantity of items
119
+ * that need to be processed or handled.
120
+ * @param {number} unitSize - The `unitSize` parameter represents the size of each unit or package. It
121
+ * is used in the `calcMinUnitsRequired` function to calculate the minimum number of units required to
122
+ * accommodate a total quantity of items.
123
+ */
24
124
  export declare const calcMinUnitsRequired: (totalQuantity: number, unitSize: number) => number;
125
+ /**
126
+ * The `roundFixed` function in TypeScript rounds a number to a specified number of decimal places.
127
+ * @param {number} num - The `num` parameter is a number that you want to round to a certain number of
128
+ * decimal places.
129
+ * @param {number} [digit=10] - The `digit` parameter in the `roundFixed` function specifies the number
130
+ * of decimal places to round the number to. By default, it is set to 10 if not provided explicitly.
131
+ * @returns The function `roundFixed` returns a number that is rounded to the specified number of
132
+ * decimal places (default is 10 decimal places).
133
+ */
25
134
  export declare const roundFixed: (num: number, digit?: number) => number;
26
- export declare function isComparable(key: any): key is Comparable;
135
+ /**
136
+ * The function `isComparable` in TypeScript checks if a value is comparable, handling primitive values
137
+ * and objects with optional force comparison.
138
+ * @param {unknown} value - The `value` parameter in the `isComparable` function represents the value
139
+ * that you want to check if it is comparable. It can be of any type (`unknown`), and the function will
140
+ * determine if it is comparable based on certain conditions.
141
+ * @param [isForceObjectComparable=false] - The `isForceObjectComparable` parameter in the
142
+ * `isComparable` function is a boolean flag that determines whether to treat non-primitive values as
143
+ * comparable objects. When set to `true`, it forces the function to consider non-primitive values as
144
+ * comparable objects, regardless of their type.
145
+ * @returns The function `isComparable` returns a boolean value indicating whether the `value` is
146
+ * considered comparable or not.
147
+ */
148
+ export declare function isComparable(value: unknown, isForceObjectComparable?: boolean): value is Comparable;