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
@@ -69,10 +69,6 @@ export class UndirectedGraph extends AbstractGraph {
69
69
  createEdge(v1, v2, weight, value) {
70
70
  return new UndirectedEdge(v1, v2, weight ?? 1, value);
71
71
  }
72
- /**
73
- * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
74
- * Space Complexity: O(1)
75
- */
76
72
  /**
77
73
  * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
78
74
  * Space Complexity: O(1)
@@ -95,10 +91,6 @@ export class UndirectedGraph extends AbstractGraph {
95
91
  }
96
92
  return edgeMap ? edgeMap[0] || undefined : undefined;
97
93
  }
98
- /**
99
- * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
100
- * Space Complexity: O(1)
101
- */
102
94
  /**
103
95
  * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
104
96
  * Space Complexity: O(1)
@@ -126,10 +118,6 @@ export class UndirectedGraph extends AbstractGraph {
126
118
  }
127
119
  return removed;
128
120
  }
129
- /**
130
- * Time Complexity: O(E), where E is the number of edgeMap incident to the given vertex.
131
- * Space Complexity: O(1)
132
- */
133
121
  /**
134
122
  * Time Complexity: O(E), where E is the number of edgeMap incident to the given vertex.
135
123
  * Space Complexity: O(1)
@@ -165,10 +153,6 @@ export class UndirectedGraph extends AbstractGraph {
165
153
  return;
166
154
  }
167
155
  }
168
- /**
169
- * Time Complexity: O(1) - Constant time for Map operations.
170
- * Space Complexity: O(1) - Constant space, as it creates only a few variables.
171
- */
172
156
  /**
173
157
  * Time Complexity: O(1) - Constant time for Map operations.
174
158
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
@@ -204,10 +188,6 @@ export class UndirectedGraph extends AbstractGraph {
204
188
  }
205
189
  return this._vertexMap.delete(vertexKey);
206
190
  }
207
- /**
208
- * Time Complexity: O(1)
209
- * Space Complexity: O(1)
210
- */
211
191
  /**
212
192
  * Time Complexity: O(1)
213
193
  * Space Complexity: O(1)
@@ -227,10 +207,6 @@ export class UndirectedGraph extends AbstractGraph {
227
207
  return 0;
228
208
  }
229
209
  }
230
- /**
231
- * Time Complexity: O(1)
232
- * Space Complexity: O(1)
233
- */
234
210
  /**
235
211
  * Time Complexity: O(1)
236
212
  * Space Complexity: O(1)
@@ -249,10 +225,6 @@ export class UndirectedGraph extends AbstractGraph {
249
225
  return [];
250
226
  }
251
227
  }
252
- /**
253
- * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
254
- * Space Complexity: O(|E|)
255
- */
256
228
  /**
257
229
  * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
258
230
  * Space Complexity: O(|E|)
@@ -269,10 +241,6 @@ export class UndirectedGraph extends AbstractGraph {
269
241
  });
270
242
  return [...edgeSet];
271
243
  }
272
- /**
273
- * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
274
- * Space Complexity: O(|E|)
275
- */
276
244
  /**
277
245
  * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
278
246
  * Space Complexity: O(|E|)
@@ -296,10 +264,6 @@ export class UndirectedGraph extends AbstractGraph {
296
264
  }
297
265
  return neighbors;
298
266
  }
299
- /**
300
- * Time Complexity: O(1)
301
- * Space Complexity: O(1)
302
- */
303
267
  /**
304
268
  * Time Complexity: O(1)
305
269
  * Space Complexity: O(1)
@@ -330,10 +294,6 @@ export class UndirectedGraph extends AbstractGraph {
330
294
  isEmpty() {
331
295
  return this.vertexMap.size === 0 && this.edgeMap.size === 0;
332
296
  }
333
- /**
334
- * Time Complexity: O(1)
335
- * Space Complexity: O(1)
336
- */
337
297
  /**
338
298
  * Time Complexity: O(1)
339
299
  * Space Complexity: O(1)
@@ -359,10 +319,6 @@ export class UndirectedGraph extends AbstractGraph {
359
319
  cloned.edgeMap = new Map(this.edgeMap);
360
320
  return cloned;
361
321
  }
362
- /**
363
- * Time Complexity: O(1)
364
- * Space Complexity: O(1)
365
- */
366
322
  /**
367
323
  * Time Complexity: O(V + E)
368
324
  * Space Complexity: O(V)
@@ -423,12 +379,6 @@ export class UndirectedGraph extends AbstractGraph {
423
379
  cutVertices
424
380
  };
425
381
  }
426
- /**
427
- * Time Complexity: O(V + E)
428
- * Space Complexity: O(V)
429
- * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
430
- * 1. Tarjan can find the articulation points and bridges(critical edgeMap) of undirected graphs in linear time
431
- */
432
382
  /**
433
383
  * The function "getBridges" returns an array of bridges in a graph using the Tarjan's algorithm.
434
384
  * @returns The function `getBridges()` is returning the bridges found using the Tarjan's algorithm.
@@ -123,8 +123,7 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
123
123
  /**
124
124
  * Time Complexity: O(n)
125
125
  * Space Complexity: O(n)
126
- */
127
- /**
126
+ *
128
127
  * The clone function creates a new HashMap with the same key-value pairs as
129
128
  * this one. The clone function is useful for creating a copy of an existing
130
129
  * HashMap, and then modifying that copy without affecting the original.
@@ -132,10 +131,6 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
132
131
  * @return A new hashmap with the same values as this one
133
132
  */
134
133
  clone(): HashMap<K, V, R>;
135
- /**
136
- * Time Complexity: O(n)
137
- * Space Complexity: O(n)
138
- */
139
134
  /**
140
135
  * Time Complexity: O(n)
141
136
  * Space Complexity: O(n)
@@ -168,15 +163,6 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
168
163
  * from the original `HashMap` that pass the provided `predicate` function.
169
164
  */
170
165
  filter(predicate: EntryCallback<K, V, boolean>, thisArg?: any): HashMap<K, V>;
171
- /**
172
- * The put function sets a value in a data structure using a specified key.
173
- * @param {K} key - The key parameter is of type K, which represents the type of the key being passed
174
- * to the function.
175
- * @param {V} value - The value parameter represents the value that you want to associate with the
176
- * specified key in the data structure.
177
- * @returns The method is returning a boolean value.
178
- */
179
- put(key: K, value: V): boolean;
180
166
  /**
181
167
  * The function returns an iterator that yields key-value pairs from both an object store and an
182
168
  * object map.
@@ -213,7 +199,7 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
213
199
  * @param [options] - The `options` parameter is an optional object that can contain the following
214
200
  * properties:
215
201
  */
216
- constructor(entryOrRawElements?: Iterable<R>, options?: LinkedHashMapOptions<K, V, R>);
202
+ constructor(entryOrRawElements?: Iterable<R | [K, V]>, options?: LinkedHashMapOptions<K, V, R>);
217
203
  protected _hashFn: (key: K) => string;
218
204
  /**
219
205
  * The function returns the hash function used for generating a hash value for a given key.
@@ -253,22 +239,18 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
253
239
  * @returns The `_tail` property of type `HashMapLinkedNode<K, V | undefined>` is being returned.
254
240
  */
255
241
  get tail(): HashMapLinkedNode<K, V | undefined>;
256
- protected _toEntryFn: (rawElement: R) => [K, V];
242
+ protected _toEntryFn?: (rawElement: R) => [K, V];
257
243
  /**
258
244
  * The function returns the value of the _toEntryFn property.
259
245
  * @returns The function being returned is `this._toEntryFn`.
260
246
  */
261
- get toEntryFn(): (rawElement: R) => [K, V];
247
+ get toEntryFn(): ((rawElement: R) => [K, V]) | undefined;
262
248
  protected _size: number;
263
249
  /**
264
250
  * The function returns the size of an object.
265
251
  * @returns The size of the object.
266
252
  */
267
253
  get size(): number;
268
- /**
269
- * Time Complexity: O(1)
270
- * Space Complexity: O(1)
271
- */
272
254
  /**
273
255
  * Time Complexity: O(1)
274
256
  * Space Complexity: O(1)
@@ -278,10 +260,6 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
278
260
  * value (V).
279
261
  */
280
262
  get first(): [K, V] | undefined;
281
- /**
282
- * Time Complexity: O(1)
283
- * Space Complexity: O(1)
284
- */
285
263
  /**
286
264
  * Time Complexity: O(1)
287
265
  * Space Complexity: O(1)
@@ -300,10 +278,6 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
300
278
  * key and value.
301
279
  */
302
280
  reverseBegin(): Generator<(K | V | undefined)[], void, unknown>;
303
- /**
304
- * Time Complexity: O(1)
305
- * Space Complexity: O(1)
306
- */
307
281
  /**
308
282
  * Time Complexity: O(1)
309
283
  * Space Complexity: O(1)
@@ -325,7 +299,7 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
325
299
  * R.
326
300
  * @returns The `setMany` function returns an array of booleans.
327
301
  */
328
- setMany(entryOrRawElements: Iterable<R>): boolean[];
302
+ setMany(entryOrRawElements: Iterable<R | [K, V]>): boolean[];
329
303
  /**
330
304
  * The function checks if a given key exists in a map, using different logic depending on whether the
331
305
  * key is a weak key or not.
@@ -333,10 +307,6 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
333
307
  * @returns The method `has` is returning a boolean value.
334
308
  */
335
309
  has(key: K): boolean;
336
- /**
337
- * Time Complexity: O(1)
338
- * Space Complexity: O(1)
339
- */
340
310
  /**
341
311
  * Time Complexity: O(1)
342
312
  * Space Complexity: O(1)
@@ -351,10 +321,6 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
351
321
  * using the key itself. If the key is not found, `undefined` is
352
322
  */
353
323
  get(key: K): V | undefined;
354
- /**
355
- * Time Complexity: O(n)
356
- * Space Complexity: O(1)
357
- */
358
324
  /**
359
325
  * Time Complexity: O(n)
360
326
  * Space Complexity: O(1)
@@ -367,10 +333,6 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
367
333
  * where `K` is the key and `V` is the value.
368
334
  */
369
335
  at(index: number): V | undefined;
370
- /**
371
- * Time Complexity: O(1)
372
- * Space Complexity: O(1)
373
- */
374
336
  /**
375
337
  * Time Complexity: O(1)
376
338
  * Space Complexity: O(1)
@@ -382,10 +344,6 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
382
344
  * was not found.
383
345
  */
384
346
  delete(key: K): boolean;
385
- /**
386
- * Time Complexity: O(n)
387
- * Space Complexity: O(1)
388
- */
389
347
  /**
390
348
  * Time Complexity: O(n)
391
349
  * Space Complexity: O(1)
@@ -396,10 +354,6 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
396
354
  * @returns The size of the list after deleting the element at the specified index.
397
355
  */
398
356
  deleteAt(index: number): boolean;
399
- /**
400
- * Time Complexity: O(1)
401
- * Space Complexity: O(1)
402
- */
403
357
  /**
404
358
  * Time Complexity: O(1)
405
359
  * Space Complexity: O(1)
@@ -416,10 +370,6 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
416
370
  * @returns a boolean value.
417
371
  */
418
372
  isEntry(rawElement: any): rawElement is [K, V];
419
- /**
420
- * Time Complexity: O(1)
421
- * Space Complexity: O(1)
422
- */
423
373
  /**
424
374
  * Time Complexity: O(1)
425
375
  * Space Complexity: O(1)
@@ -427,10 +377,6 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
427
377
  * The `clear` function clears all the entries in a data structure and resets its properties.
428
378
  */
429
379
  clear(): void;
430
- /**
431
- * Time Complexity: O(n)
432
- * Space Complexity: O(n)
433
- */
434
380
  /**
435
381
  * Time Complexity: O(n)
436
382
  * Space Complexity: O(n)
@@ -441,10 +387,6 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
441
387
  * of the original `LinkedHashMap` object.
442
388
  */
443
389
  clone(): LinkedHashMap<K, V>;
444
- /**
445
- * Time Complexity: O(n)
446
- * Space Complexity: O(n)
447
- */
448
390
  /**
449
391
  * Time Complexity: O(n)
450
392
  * Space Complexity: O(n)
@@ -461,10 +403,6 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
461
403
  * `LinkedHashMap` object that satisfy the given predicate function.
462
404
  */
463
405
  filter(predicate: EntryCallback<K, V, boolean>, thisArg?: any): LinkedHashMap<K, V>;
464
- /**
465
- * Time Complexity: O(n)
466
- * Space Complexity: O(n)
467
- */
468
406
  /**
469
407
  * Time Complexity: O(n)
470
408
  * Space Complexity: O(n)
@@ -483,27 +421,6 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
483
421
  * function.
484
422
  */
485
423
  map<VM>(callback: EntryCallback<K, V, VM>, thisArg?: any): LinkedHashMap<K, VM>;
486
- /**
487
- * Time Complexity: O(1)
488
- * Space Complexity: O(1)
489
- */
490
- /**
491
- * Time Complexity: O(1)
492
- * Space Complexity: O(1)
493
- *
494
- * The put function sets a value in a data structure using a specified key.
495
- * @param {K} key - The key parameter is of type K, which represents the type of the key being passed
496
- * to the function.
497
- * @param {V} value - The value parameter represents the value that you want to associate with the
498
- * specified key in the data structure.
499
- * @returns The method is returning a boolean value.
500
- */
501
- put(key: K, value: V): boolean;
502
- /**
503
- * Time Complexity: O(n)
504
- * Space Complexity: O(1)
505
- * where n is the number of entries in the LinkedHashMap.
506
- */
507
424
  /**
508
425
  * Time Complexity: O(n)
509
426
  * Space Complexity: O(1)
@@ -512,10 +429,6 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
512
429
  * The above function is an iterator that yields key-value pairs from a linked list.
513
430
  */
514
431
  protected _getIterator(): Generator<[K, V], void, unknown>;
515
- /**
516
- * Time Complexity: O(1)
517
- * Space Complexity: O(1)
518
- */
519
432
  /**
520
433
  * Time Complexity: O(1)
521
434
  * Space Complexity: O(1)
@@ -19,12 +19,10 @@ export class HashMap extends IterableEntryBase {
19
19
  super();
20
20
  if (options) {
21
21
  const { hashFn, toEntryFn } = options;
22
- if (hashFn) {
22
+ if (hashFn)
23
23
  this._hashFn = hashFn;
24
- }
25
- if (toEntryFn) {
24
+ if (toEntryFn)
26
25
  this._toEntryFn = toEntryFn;
27
- }
28
26
  }
29
27
  if (entryOrRawElements) {
30
28
  this.setMany(entryOrRawElements);
@@ -139,8 +137,8 @@ export class HashMap extends IterableEntryBase {
139
137
  key = rawEle[0];
140
138
  value = rawEle[1];
141
139
  }
142
- else if (this.toEntryFn) {
143
- const item = this.toEntryFn(rawEle);
140
+ else if (this._toEntryFn) {
141
+ const item = this._toEntryFn(rawEle);
144
142
  key = item[0];
145
143
  value = item[1];
146
144
  }
@@ -208,8 +206,7 @@ export class HashMap extends IterableEntryBase {
208
206
  /**
209
207
  * Time Complexity: O(n)
210
208
  * Space Complexity: O(n)
211
- */
212
- /**
209
+ *
213
210
  * The clone function creates a new HashMap with the same key-value pairs as
214
211
  * this one. The clone function is useful for creating a copy of an existing
215
212
  * HashMap, and then modifying that copy without affecting the original.
@@ -217,12 +214,8 @@ export class HashMap extends IterableEntryBase {
217
214
  * @return A new hashmap with the same values as this one
218
215
  */
219
216
  clone() {
220
- return new HashMap(this, { hashFn: this.hashFn, toEntryFn: this.toEntryFn });
217
+ return new HashMap(this, { hashFn: this._hashFn, toEntryFn: this._toEntryFn });
221
218
  }
222
- /**
223
- * Time Complexity: O(n)
224
- * Space Complexity: O(n)
225
- */
226
219
  /**
227
220
  * Time Complexity: O(n)
228
221
  * Space Complexity: O(n)
@@ -271,17 +264,6 @@ export class HashMap extends IterableEntryBase {
271
264
  }
272
265
  return filteredMap;
273
266
  }
274
- /**
275
- * The put function sets a value in a data structure using a specified key.
276
- * @param {K} key - The key parameter is of type K, which represents the type of the key being passed
277
- * to the function.
278
- * @param {V} value - The value parameter represents the value that you want to associate with the
279
- * specified key in the data structure.
280
- * @returns The method is returning a boolean value.
281
- */
282
- put(key, value) {
283
- return this.set(key, value);
284
- }
285
267
  /**
286
268
  * The function returns an iterator that yields key-value pairs from both an object store and an
287
269
  * object map.
@@ -314,7 +296,7 @@ export class HashMap extends IterableEntryBase {
314
296
  const keyType = typeof key;
315
297
  let strKey;
316
298
  if (keyType !== 'string' && keyType !== 'number' && keyType !== 'symbol') {
317
- strKey = this.hashFn(key);
299
+ strKey = this._hashFn(key);
318
300
  }
319
301
  else {
320
302
  if (keyType === 'number') {
@@ -359,10 +341,7 @@ export class LinkedHashMap extends IterableEntryBase {
359
341
  }
360
342
  }
361
343
  if (entryOrRawElements) {
362
- for (const el of entryOrRawElements) {
363
- const [key, value] = this.toEntryFn(el);
364
- this.set(key, value);
365
- }
344
+ this.setMany(entryOrRawElements);
366
345
  }
367
346
  }
368
347
  _hashFn = (key) => String(key);
@@ -440,10 +419,6 @@ export class LinkedHashMap extends IterableEntryBase {
440
419
  get size() {
441
420
  return this._size;
442
421
  }
443
- /**
444
- * Time Complexity: O(1)
445
- * Space Complexity: O(1)
446
- */
447
422
  /**
448
423
  * Time Complexity: O(1)
449
424
  * Space Complexity: O(1)
@@ -457,10 +432,6 @@ export class LinkedHashMap extends IterableEntryBase {
457
432
  return;
458
433
  return [this.head.key, this.head.value];
459
434
  }
460
- /**
461
- * Time Complexity: O(1)
462
- * Space Complexity: O(1)
463
- */
464
435
  /**
465
436
  * Time Complexity: O(1)
466
437
  * Space Complexity: O(1)
@@ -495,10 +466,6 @@ export class LinkedHashMap extends IterableEntryBase {
495
466
  node = node.prev;
496
467
  }
497
468
  }
498
- /**
499
- * Time Complexity: O(1)
500
- * Space Complexity: O(1)
501
- */
502
469
  /**
503
470
  * Time Complexity: O(1)
504
471
  * Space Complexity: O(1)
@@ -515,7 +482,7 @@ export class LinkedHashMap extends IterableEntryBase {
515
482
  let node;
516
483
  const isNewKey = !this.has(key); // Check if the key is new
517
484
  if (isWeakKey(key)) {
518
- const hash = this.objHashFn(key);
485
+ const hash = this._objHashFn(key);
519
486
  node = this.objMap.get(hash);
520
487
  if (!node && isNewKey) {
521
488
  // Create a new node
@@ -528,7 +495,7 @@ export class LinkedHashMap extends IterableEntryBase {
528
495
  }
529
496
  }
530
497
  else {
531
- const hash = this.hashFn(key);
498
+ const hash = this._hashFn(key);
532
499
  node = this.noObjMap[hash];
533
500
  if (!node && isNewKey) {
534
501
  this.noObjMap[hash] = node = { key, value, prev: this.tail, next: this._sentinel };
@@ -565,8 +532,18 @@ export class LinkedHashMap extends IterableEntryBase {
565
532
  setMany(entryOrRawElements) {
566
533
  const results = [];
567
534
  for (const rawEle of entryOrRawElements) {
568
- const [key, value] = this.toEntryFn(rawEle);
569
- results.push(this.set(key, value));
535
+ let key, value;
536
+ if (this.isEntry(rawEle)) {
537
+ key = rawEle[0];
538
+ value = rawEle[1];
539
+ }
540
+ else if (this._toEntryFn) {
541
+ const item = this._toEntryFn(rawEle);
542
+ key = item[0];
543
+ value = item[1];
544
+ }
545
+ if (key !== undefined && value !== undefined)
546
+ results.push(this.set(key, value));
570
547
  }
571
548
  return results;
572
549
  }
@@ -578,18 +555,14 @@ export class LinkedHashMap extends IterableEntryBase {
578
555
  */
579
556
  has(key) {
580
557
  if (isWeakKey(key)) {
581
- const hash = this.objHashFn(key);
558
+ const hash = this._objHashFn(key);
582
559
  return this.objMap.has(hash);
583
560
  }
584
561
  else {
585
- const hash = this.hashFn(key);
562
+ const hash = this._hashFn(key);
586
563
  return hash in this.noObjMap;
587
564
  }
588
565
  }
589
- /**
590
- * Time Complexity: O(1)
591
- * Space Complexity: O(1)
592
- */
593
566
  /**
594
567
  * Time Complexity: O(1)
595
568
  * Space Complexity: O(1)
@@ -605,20 +578,16 @@ export class LinkedHashMap extends IterableEntryBase {
605
578
  */
606
579
  get(key) {
607
580
  if (isWeakKey(key)) {
608
- const hash = this.objHashFn(key);
581
+ const hash = this._objHashFn(key);
609
582
  const node = this.objMap.get(hash);
610
583
  return node ? node.value : undefined;
611
584
  }
612
585
  else {
613
- const hash = this.hashFn(key);
586
+ const hash = this._hashFn(key);
614
587
  const node = this.noObjMap[hash];
615
588
  return node ? node.value : undefined;
616
589
  }
617
590
  }
618
- /**
619
- * Time Complexity: O(n)
620
- * Space Complexity: O(1)
621
- */
622
591
  /**
623
592
  * Time Complexity: O(n)
624
593
  * Space Complexity: O(1)
@@ -638,10 +607,6 @@ export class LinkedHashMap extends IterableEntryBase {
638
607
  }
639
608
  return node.value;
640
609
  }
641
- /**
642
- * Time Complexity: O(1)
643
- * Space Complexity: O(1)
644
- */
645
610
  /**
646
611
  * Time Complexity: O(1)
647
612
  * Space Complexity: O(1)
@@ -655,7 +620,7 @@ export class LinkedHashMap extends IterableEntryBase {
655
620
  delete(key) {
656
621
  let node;
657
622
  if (isWeakKey(key)) {
658
- const hash = this.objHashFn(key);
623
+ const hash = this._objHashFn(key);
659
624
  // Get nodes from WeakMap
660
625
  node = this.objMap.get(hash);
661
626
  if (!node) {
@@ -665,7 +630,7 @@ export class LinkedHashMap extends IterableEntryBase {
665
630
  this.objMap.delete(hash);
666
631
  }
667
632
  else {
668
- const hash = this.hashFn(key);
633
+ const hash = this._hashFn(key);
669
634
  // Get nodes from noObjMap
670
635
  node = this.noObjMap[hash];
671
636
  if (!node) {
@@ -678,10 +643,6 @@ export class LinkedHashMap extends IterableEntryBase {
678
643
  this._deleteNode(node);
679
644
  return true;
680
645
  }
681
- /**
682
- * Time Complexity: O(n)
683
- * Space Complexity: O(1)
684
- */
685
646
  /**
686
647
  * Time Complexity: O(n)
687
648
  * Space Complexity: O(1)
@@ -699,10 +660,6 @@ export class LinkedHashMap extends IterableEntryBase {
699
660
  }
700
661
  return this._deleteNode(node);
701
662
  }
702
- /**
703
- * Time Complexity: O(1)
704
- * Space Complexity: O(1)
705
- */
706
663
  /**
707
664
  * Time Complexity: O(1)
708
665
  * Space Complexity: O(1)
@@ -723,10 +680,6 @@ export class LinkedHashMap extends IterableEntryBase {
723
680
  isEntry(rawElement) {
724
681
  return Array.isArray(rawElement) && rawElement.length === 2;
725
682
  }
726
- /**
727
- * Time Complexity: O(1)
728
- * Space Complexity: O(1)
729
- */
730
683
  /**
731
684
  * Time Complexity: O(1)
732
685
  * Space Complexity: O(1)
@@ -738,10 +691,6 @@ export class LinkedHashMap extends IterableEntryBase {
738
691
  this._size = 0;
739
692
  this._head = this._tail = this._sentinel.prev = this._sentinel.next = this._sentinel;
740
693
  }
741
- /**
742
- * Time Complexity: O(n)
743
- * Space Complexity: O(n)
744
- */
745
694
  /**
746
695
  * Time Complexity: O(n)
747
696
  * Space Complexity: O(n)
@@ -752,17 +701,13 @@ export class LinkedHashMap extends IterableEntryBase {
752
701
  * of the original `LinkedHashMap` object.
753
702
  */
754
703
  clone() {
755
- const cloned = new LinkedHashMap([], { hashFn: this.hashFn, objHashFn: this.objHashFn });
704
+ const cloned = new LinkedHashMap([], { hashFn: this._hashFn, objHashFn: this._objHashFn });
756
705
  for (const entry of this) {
757
706
  const [key, value] = entry;
758
707
  cloned.set(key, value);
759
708
  }
760
709
  return cloned;
761
710
  }
762
- /**
763
- * Time Complexity: O(n)
764
- * Space Complexity: O(n)
765
- */
766
711
  /**
767
712
  * Time Complexity: O(n)
768
713
  * Space Complexity: O(n)
@@ -789,10 +734,6 @@ export class LinkedHashMap extends IterableEntryBase {
789
734
  }
790
735
  return filteredMap;
791
736
  }
792
- /**
793
- * Time Complexity: O(n)
794
- * Space Complexity: O(n)
795
- */
796
737
  /**
797
738
  * Time Complexity: O(n)
798
739
  * Space Complexity: O(n)
@@ -820,29 +761,6 @@ export class LinkedHashMap extends IterableEntryBase {
820
761
  }
821
762
  return mappedMap;
822
763
  }
823
- /**
824
- * Time Complexity: O(1)
825
- * Space Complexity: O(1)
826
- */
827
- /**
828
- * Time Complexity: O(1)
829
- * Space Complexity: O(1)
830
- *
831
- * The put function sets a value in a data structure using a specified key.
832
- * @param {K} key - The key parameter is of type K, which represents the type of the key being passed
833
- * to the function.
834
- * @param {V} value - The value parameter represents the value that you want to associate with the
835
- * specified key in the data structure.
836
- * @returns The method is returning a boolean value.
837
- */
838
- put(key, value) {
839
- return this.set(key, value);
840
- }
841
- /**
842
- * Time Complexity: O(n)
843
- * Space Complexity: O(1)
844
- * where n is the number of entries in the LinkedHashMap.
845
- */
846
764
  /**
847
765
  * Time Complexity: O(n)
848
766
  * Space Complexity: O(1)
@@ -857,10 +775,6 @@ export class LinkedHashMap extends IterableEntryBase {
857
775
  node = node.next;
858
776
  }
859
777
  }
860
- /**
861
- * Time Complexity: O(1)
862
- * Space Complexity: O(1)
863
- */
864
778
  /**
865
779
  * Time Complexity: O(1)
866
780
  * Space Complexity: O(1)