data-structure-typed 1.52.4 → 1.52.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) 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 +300 -332
  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 +2 -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 +299 -333
  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 +2 -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 +411 -1475
  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 +330 -359
  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/integration/avl-tree.test.ts +1 -1
  158. package/test/integration/bst.test.ts +2 -2
  159. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +13 -13
  160. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +18 -13
  161. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +577 -167
  162. package/test/unit/data-structures/binary-tree/bst.test.ts +167 -23
  163. package/test/unit/data-structures/binary-tree/overall.test.ts +1 -1
  164. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +136 -13
  165. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +18 -13
  166. package/test/unit/data-structures/graph/directed-graph.test.ts +46 -32
  167. package/test/unit/data-structures/graph/map-graph.test.ts +24 -2
  168. package/test/unit/data-structures/graph/undirected-graph.test.ts +24 -24
  169. package/test/unit/data-structures/hash/hash-map.test.ts +225 -35
  170. package/test/unit/data-structures/heap/heap.test.ts +47 -39
  171. package/test/unit/data-structures/heap/min-heap.test.ts +5 -5
  172. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +34 -4
  173. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +32 -0
  174. package/test/unit/data-structures/matrix/matrix.test.ts +35 -5
  175. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +31 -0
  176. package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +18 -0
  177. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +17 -0
  178. package/test/unit/data-structures/queue/deque.test.ts +288 -47
  179. package/test/unit/data-structures/queue/queue.test.ts +62 -37
  180. package/test/unit/data-structures/stack/stack.test.ts +30 -5
  181. package/test/unit/data-structures/tree/tree.test.ts +58 -0
  182. package/test/unit/data-structures/trie/trie.test.ts +46 -5
  183. 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)
@@ -137,8 +137,8 @@ export class HashMap extends IterableEntryBase {
137
137
  key = rawEle[0];
138
138
  value = rawEle[1];
139
139
  }
140
- else if (this.toEntryFn) {
141
- const item = this.toEntryFn(rawEle);
140
+ else if (this._toEntryFn) {
141
+ const item = this._toEntryFn(rawEle);
142
142
  key = item[0];
143
143
  value = item[1];
144
144
  }
@@ -206,8 +206,7 @@ export class HashMap extends IterableEntryBase {
206
206
  /**
207
207
  * Time Complexity: O(n)
208
208
  * Space Complexity: O(n)
209
- */
210
- /**
209
+ *
211
210
  * The clone function creates a new HashMap with the same key-value pairs as
212
211
  * this one. The clone function is useful for creating a copy of an existing
213
212
  * HashMap, and then modifying that copy without affecting the original.
@@ -215,12 +214,8 @@ export class HashMap extends IterableEntryBase {
215
214
  * @return A new hashmap with the same values as this one
216
215
  */
217
216
  clone() {
218
- return new HashMap(this, { hashFn: this.hashFn, toEntryFn: this.toEntryFn });
217
+ return new HashMap(this, { hashFn: this._hashFn, toEntryFn: this._toEntryFn });
219
218
  }
220
- /**
221
- * Time Complexity: O(n)
222
- * Space Complexity: O(n)
223
- */
224
219
  /**
225
220
  * Time Complexity: O(n)
226
221
  * Space Complexity: O(n)
@@ -269,17 +264,6 @@ export class HashMap extends IterableEntryBase {
269
264
  }
270
265
  return filteredMap;
271
266
  }
272
- /**
273
- * The put function sets a value in a data structure using a specified key.
274
- * @param {K} key - The key parameter is of type K, which represents the type of the key being passed
275
- * to the function.
276
- * @param {V} value - The value parameter represents the value that you want to associate with the
277
- * specified key in the data structure.
278
- * @returns The method is returning a boolean value.
279
- */
280
- put(key, value) {
281
- return this.set(key, value);
282
- }
283
267
  /**
284
268
  * The function returns an iterator that yields key-value pairs from both an object store and an
285
269
  * object map.
@@ -312,7 +296,7 @@ export class HashMap extends IterableEntryBase {
312
296
  const keyType = typeof key;
313
297
  let strKey;
314
298
  if (keyType !== 'string' && keyType !== 'number' && keyType !== 'symbol') {
315
- strKey = this.hashFn(key);
299
+ strKey = this._hashFn(key);
316
300
  }
317
301
  else {
318
302
  if (keyType === 'number') {
@@ -357,10 +341,7 @@ export class LinkedHashMap extends IterableEntryBase {
357
341
  }
358
342
  }
359
343
  if (entryOrRawElements) {
360
- for (const el of entryOrRawElements) {
361
- const [key, value] = this.toEntryFn(el);
362
- this.set(key, value);
363
- }
344
+ this.setMany(entryOrRawElements);
364
345
  }
365
346
  }
366
347
  _hashFn = (key) => String(key);
@@ -438,10 +419,6 @@ export class LinkedHashMap extends IterableEntryBase {
438
419
  get size() {
439
420
  return this._size;
440
421
  }
441
- /**
442
- * Time Complexity: O(1)
443
- * Space Complexity: O(1)
444
- */
445
422
  /**
446
423
  * Time Complexity: O(1)
447
424
  * Space Complexity: O(1)
@@ -455,10 +432,6 @@ export class LinkedHashMap extends IterableEntryBase {
455
432
  return;
456
433
  return [this.head.key, this.head.value];
457
434
  }
458
- /**
459
- * Time Complexity: O(1)
460
- * Space Complexity: O(1)
461
- */
462
435
  /**
463
436
  * Time Complexity: O(1)
464
437
  * Space Complexity: O(1)
@@ -493,10 +466,6 @@ export class LinkedHashMap extends IterableEntryBase {
493
466
  node = node.prev;
494
467
  }
495
468
  }
496
- /**
497
- * Time Complexity: O(1)
498
- * Space Complexity: O(1)
499
- */
500
469
  /**
501
470
  * Time Complexity: O(1)
502
471
  * Space Complexity: O(1)
@@ -513,7 +482,7 @@ export class LinkedHashMap extends IterableEntryBase {
513
482
  let node;
514
483
  const isNewKey = !this.has(key); // Check if the key is new
515
484
  if (isWeakKey(key)) {
516
- const hash = this.objHashFn(key);
485
+ const hash = this._objHashFn(key);
517
486
  node = this.objMap.get(hash);
518
487
  if (!node && isNewKey) {
519
488
  // Create a new node
@@ -526,7 +495,7 @@ export class LinkedHashMap extends IterableEntryBase {
526
495
  }
527
496
  }
528
497
  else {
529
- const hash = this.hashFn(key);
498
+ const hash = this._hashFn(key);
530
499
  node = this.noObjMap[hash];
531
500
  if (!node && isNewKey) {
532
501
  this.noObjMap[hash] = node = { key, value, prev: this.tail, next: this._sentinel };
@@ -563,8 +532,18 @@ export class LinkedHashMap extends IterableEntryBase {
563
532
  setMany(entryOrRawElements) {
564
533
  const results = [];
565
534
  for (const rawEle of entryOrRawElements) {
566
- const [key, value] = this.toEntryFn(rawEle);
567
- 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));
568
547
  }
569
548
  return results;
570
549
  }
@@ -576,18 +555,14 @@ export class LinkedHashMap extends IterableEntryBase {
576
555
  */
577
556
  has(key) {
578
557
  if (isWeakKey(key)) {
579
- const hash = this.objHashFn(key);
558
+ const hash = this._objHashFn(key);
580
559
  return this.objMap.has(hash);
581
560
  }
582
561
  else {
583
- const hash = this.hashFn(key);
562
+ const hash = this._hashFn(key);
584
563
  return hash in this.noObjMap;
585
564
  }
586
565
  }
587
- /**
588
- * Time Complexity: O(1)
589
- * Space Complexity: O(1)
590
- */
591
566
  /**
592
567
  * Time Complexity: O(1)
593
568
  * Space Complexity: O(1)
@@ -603,20 +578,16 @@ export class LinkedHashMap extends IterableEntryBase {
603
578
  */
604
579
  get(key) {
605
580
  if (isWeakKey(key)) {
606
- const hash = this.objHashFn(key);
581
+ const hash = this._objHashFn(key);
607
582
  const node = this.objMap.get(hash);
608
583
  return node ? node.value : undefined;
609
584
  }
610
585
  else {
611
- const hash = this.hashFn(key);
586
+ const hash = this._hashFn(key);
612
587
  const node = this.noObjMap[hash];
613
588
  return node ? node.value : undefined;
614
589
  }
615
590
  }
616
- /**
617
- * Time Complexity: O(n)
618
- * Space Complexity: O(1)
619
- */
620
591
  /**
621
592
  * Time Complexity: O(n)
622
593
  * Space Complexity: O(1)
@@ -636,10 +607,6 @@ export class LinkedHashMap extends IterableEntryBase {
636
607
  }
637
608
  return node.value;
638
609
  }
639
- /**
640
- * Time Complexity: O(1)
641
- * Space Complexity: O(1)
642
- */
643
610
  /**
644
611
  * Time Complexity: O(1)
645
612
  * Space Complexity: O(1)
@@ -653,7 +620,7 @@ export class LinkedHashMap extends IterableEntryBase {
653
620
  delete(key) {
654
621
  let node;
655
622
  if (isWeakKey(key)) {
656
- const hash = this.objHashFn(key);
623
+ const hash = this._objHashFn(key);
657
624
  // Get nodes from WeakMap
658
625
  node = this.objMap.get(hash);
659
626
  if (!node) {
@@ -663,7 +630,7 @@ export class LinkedHashMap extends IterableEntryBase {
663
630
  this.objMap.delete(hash);
664
631
  }
665
632
  else {
666
- const hash = this.hashFn(key);
633
+ const hash = this._hashFn(key);
667
634
  // Get nodes from noObjMap
668
635
  node = this.noObjMap[hash];
669
636
  if (!node) {
@@ -676,10 +643,6 @@ export class LinkedHashMap extends IterableEntryBase {
676
643
  this._deleteNode(node);
677
644
  return true;
678
645
  }
679
- /**
680
- * Time Complexity: O(n)
681
- * Space Complexity: O(1)
682
- */
683
646
  /**
684
647
  * Time Complexity: O(n)
685
648
  * Space Complexity: O(1)
@@ -697,10 +660,6 @@ export class LinkedHashMap extends IterableEntryBase {
697
660
  }
698
661
  return this._deleteNode(node);
699
662
  }
700
- /**
701
- * Time Complexity: O(1)
702
- * Space Complexity: O(1)
703
- */
704
663
  /**
705
664
  * Time Complexity: O(1)
706
665
  * Space Complexity: O(1)
@@ -721,10 +680,6 @@ export class LinkedHashMap extends IterableEntryBase {
721
680
  isEntry(rawElement) {
722
681
  return Array.isArray(rawElement) && rawElement.length === 2;
723
682
  }
724
- /**
725
- * Time Complexity: O(1)
726
- * Space Complexity: O(1)
727
- */
728
683
  /**
729
684
  * Time Complexity: O(1)
730
685
  * Space Complexity: O(1)
@@ -736,10 +691,6 @@ export class LinkedHashMap extends IterableEntryBase {
736
691
  this._size = 0;
737
692
  this._head = this._tail = this._sentinel.prev = this._sentinel.next = this._sentinel;
738
693
  }
739
- /**
740
- * Time Complexity: O(n)
741
- * Space Complexity: O(n)
742
- */
743
694
  /**
744
695
  * Time Complexity: O(n)
745
696
  * Space Complexity: O(n)
@@ -750,17 +701,13 @@ export class LinkedHashMap extends IterableEntryBase {
750
701
  * of the original `LinkedHashMap` object.
751
702
  */
752
703
  clone() {
753
- const cloned = new LinkedHashMap([], { hashFn: this.hashFn, objHashFn: this.objHashFn });
704
+ const cloned = new LinkedHashMap([], { hashFn: this._hashFn, objHashFn: this._objHashFn });
754
705
  for (const entry of this) {
755
706
  const [key, value] = entry;
756
707
  cloned.set(key, value);
757
708
  }
758
709
  return cloned;
759
710
  }
760
- /**
761
- * Time Complexity: O(n)
762
- * Space Complexity: O(n)
763
- */
764
711
  /**
765
712
  * Time Complexity: O(n)
766
713
  * Space Complexity: O(n)
@@ -787,10 +734,6 @@ export class LinkedHashMap extends IterableEntryBase {
787
734
  }
788
735
  return filteredMap;
789
736
  }
790
- /**
791
- * Time Complexity: O(n)
792
- * Space Complexity: O(n)
793
- */
794
737
  /**
795
738
  * Time Complexity: O(n)
796
739
  * Space Complexity: O(n)
@@ -818,29 +761,6 @@ export class LinkedHashMap extends IterableEntryBase {
818
761
  }
819
762
  return mappedMap;
820
763
  }
821
- /**
822
- * Time Complexity: O(1)
823
- * Space Complexity: O(1)
824
- */
825
- /**
826
- * Time Complexity: O(1)
827
- * Space Complexity: O(1)
828
- *
829
- * The put function sets a value in a data structure using a specified key.
830
- * @param {K} key - The key parameter is of type K, which represents the type of the key being passed
831
- * to the function.
832
- * @param {V} value - The value parameter represents the value that you want to associate with the
833
- * specified key in the data structure.
834
- * @returns The method is returning a boolean value.
835
- */
836
- put(key, value) {
837
- return this.set(key, value);
838
- }
839
- /**
840
- * Time Complexity: O(n)
841
- * Space Complexity: O(1)
842
- * where n is the number of entries in the LinkedHashMap.
843
- */
844
764
  /**
845
765
  * Time Complexity: O(n)
846
766
  * Space Complexity: O(1)
@@ -855,10 +775,6 @@ export class LinkedHashMap extends IterableEntryBase {
855
775
  node = node.next;
856
776
  }
857
777
  }
858
- /**
859
- * Time Complexity: O(1)
860
- * Space Complexity: O(1)
861
- */
862
778
  /**
863
779
  * Time Complexity: O(1)
864
780
  * Space Complexity: O(1)