graph-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 (74) hide show
  1. package/dist/data-structures/base/iterable-element-base.d.ts +1 -37
  2. package/dist/data-structures/base/iterable-element-base.js +1 -37
  3. package/dist/data-structures/base/iterable-entry-base.d.ts +2 -54
  4. package/dist/data-structures/base/iterable-entry-base.js +1 -49
  5. package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -32
  6. package/dist/data-structures/binary-tree/avl-tree-multi-map.js +9 -41
  7. package/dist/data-structures/binary-tree/avl-tree.d.ts +0 -46
  8. package/dist/data-structures/binary-tree/avl-tree.js +0 -46
  9. package/dist/data-structures/binary-tree/binary-tree.d.ts +82 -147
  10. package/dist/data-structures/binary-tree/binary-tree.js +299 -331
  11. package/dist/data-structures/binary-tree/bst.d.ts +1 -40
  12. package/dist/data-structures/binary-tree/bst.js +12 -44
  13. package/dist/data-structures/binary-tree/rb-tree.d.ts +0 -48
  14. package/dist/data-structures/binary-tree/rb-tree.js +2 -50
  15. package/dist/data-structures/binary-tree/tree-multi-map.d.ts +0 -32
  16. package/dist/data-structures/binary-tree/tree-multi-map.js +9 -41
  17. package/dist/data-structures/graph/abstract-graph.d.ts +0 -75
  18. package/dist/data-structures/graph/abstract-graph.js +0 -75
  19. package/dist/data-structures/graph/directed-graph.d.ts +0 -98
  20. package/dist/data-structures/graph/directed-graph.js +0 -98
  21. package/dist/data-structures/graph/undirected-graph.d.ts +0 -50
  22. package/dist/data-structures/graph/undirected-graph.js +0 -50
  23. package/dist/data-structures/hash/hash-map.d.ts +5 -92
  24. package/dist/data-structures/hash/hash-map.js +29 -115
  25. package/dist/data-structures/heap/heap.d.ts +0 -32
  26. package/dist/data-structures/heap/heap.js +0 -32
  27. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +5 -88
  28. package/dist/data-structures/linked-list/doubly-linked-list.js +5 -88
  29. package/dist/data-structures/linked-list/singly-linked-list.d.ts +1 -83
  30. package/dist/data-structures/linked-list/singly-linked-list.js +2 -84
  31. package/dist/data-structures/linked-list/skip-linked-list.d.ts +1 -35
  32. package/dist/data-structures/linked-list/skip-linked-list.js +1 -35
  33. package/dist/data-structures/queue/deque.d.ts +1 -98
  34. package/dist/data-structures/queue/deque.js +3 -99
  35. package/dist/data-structures/queue/queue.d.ts +5 -58
  36. package/dist/data-structures/queue/queue.js +4 -57
  37. package/dist/data-structures/stack/stack.d.ts +1 -34
  38. package/dist/data-structures/stack/stack.js +1 -34
  39. package/dist/data-structures/tree/tree.js +2 -1
  40. package/dist/data-structures/trie/trie.d.ts +0 -64
  41. package/dist/data-structures/trie/trie.js +0 -64
  42. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +8 -0
  43. package/dist/types/data-structures/binary-tree/binary-tree.js +6 -0
  44. package/dist/types/utils/utils.d.ts +13 -12
  45. package/dist/utils/number.d.ts +13 -0
  46. package/dist/utils/number.js +13 -0
  47. package/dist/utils/utils.d.ts +125 -3
  48. package/dist/utils/utils.js +177 -21
  49. package/package.json +2 -2
  50. package/src/data-structures/base/iterable-element-base.ts +2 -42
  51. package/src/data-structures/base/iterable-entry-base.ts +3 -62
  52. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +8 -48
  53. package/src/data-structures/binary-tree/avl-tree.ts +0 -57
  54. package/src/data-structures/binary-tree/binary-tree.ts +329 -358
  55. package/src/data-structures/binary-tree/bst.ts +11 -54
  56. package/src/data-structures/binary-tree/rb-tree.ts +2 -62
  57. package/src/data-structures/binary-tree/tree-multi-map.ts +8 -48
  58. package/src/data-structures/graph/abstract-graph.ts +0 -92
  59. package/src/data-structures/graph/directed-graph.ts +0 -122
  60. package/src/data-structures/graph/undirected-graph.ts +0 -62
  61. package/src/data-structures/hash/hash-map.ts +31 -139
  62. package/src/data-structures/heap/heap.ts +0 -40
  63. package/src/data-structures/linked-list/doubly-linked-list.ts +5 -112
  64. package/src/data-structures/linked-list/singly-linked-list.ts +2 -104
  65. package/src/data-structures/linked-list/skip-linked-list.ts +1 -44
  66. package/src/data-structures/queue/deque.ts +2 -125
  67. package/src/data-structures/queue/queue.ts +5 -72
  68. package/src/data-structures/stack/stack.ts +1 -43
  69. package/src/data-structures/tree/tree.ts +1 -1
  70. package/src/data-structures/trie/trie.ts +0 -80
  71. package/src/types/data-structures/binary-tree/binary-tree.ts +8 -1
  72. package/src/types/utils/utils.ts +17 -15
  73. package/src/utils/number.ts +13 -0
  74. package/src/utils/utils.ts +174 -18
@@ -72,10 +72,6 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
72
72
  createEdge(v1, v2, weight, value) {
73
73
  return new UndirectedEdge(v1, v2, weight !== null && weight !== void 0 ? weight : 1, value);
74
74
  }
75
- /**
76
- * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
77
- * Space Complexity: O(1)
78
- */
79
75
  /**
80
76
  * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
81
77
  * Space Complexity: O(1)
@@ -99,10 +95,6 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
99
95
  }
100
96
  return edgeMap ? edgeMap[0] || undefined : undefined;
101
97
  }
102
- /**
103
- * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
104
- * Space Complexity: O(1)
105
- */
106
98
  /**
107
99
  * Time Complexity: O(|E|), where |E| is the number of edgeMap incident to the given vertex.
108
100
  * Space Complexity: O(1)
@@ -130,10 +122,6 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
130
122
  }
131
123
  return removed;
132
124
  }
133
- /**
134
- * Time Complexity: O(E), where E is the number of edgeMap incident to the given vertex.
135
- * Space Complexity: O(1)
136
- */
137
125
  /**
138
126
  * Time Complexity: O(E), where E is the number of edgeMap incident to the given vertex.
139
127
  * Space Complexity: O(1)
@@ -169,10 +157,6 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
169
157
  return;
170
158
  }
171
159
  }
172
- /**
173
- * Time Complexity: O(1) - Constant time for Map operations.
174
- * Space Complexity: O(1) - Constant space, as it creates only a few variables.
175
- */
176
160
  /**
177
161
  * Time Complexity: O(1) - Constant time for Map operations.
178
162
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
@@ -208,10 +192,6 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
208
192
  }
209
193
  return this._vertexMap.delete(vertexKey);
210
194
  }
211
- /**
212
- * Time Complexity: O(1)
213
- * Space Complexity: O(1)
214
- */
215
195
  /**
216
196
  * Time Complexity: O(1)
217
197
  * Space Complexity: O(1)
@@ -232,10 +212,6 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
232
212
  return 0;
233
213
  }
234
214
  }
235
- /**
236
- * Time Complexity: O(1)
237
- * Space Complexity: O(1)
238
- */
239
215
  /**
240
216
  * Time Complexity: O(1)
241
217
  * Space Complexity: O(1)
@@ -254,10 +230,6 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
254
230
  return [];
255
231
  }
256
232
  }
257
- /**
258
- * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
259
- * Space Complexity: O(|E|)
260
- */
261
233
  /**
262
234
  * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
263
235
  * Space Complexity: O(|E|)
@@ -274,10 +246,6 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
274
246
  });
275
247
  return [...edgeSet];
276
248
  }
277
- /**
278
- * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
279
- * Space Complexity: O(|E|)
280
- */
281
249
  /**
282
250
  * Time Complexity: O(|V| + |E|), where |V| is the number of vertexMap and |E| is the number of edgeMap.
283
251
  * Space Complexity: O(|E|)
@@ -301,10 +269,6 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
301
269
  }
302
270
  return neighbors;
303
271
  }
304
- /**
305
- * Time Complexity: O(1)
306
- * Space Complexity: O(1)
307
- */
308
272
  /**
309
273
  * Time Complexity: O(1)
310
274
  * Space Complexity: O(1)
@@ -335,10 +299,6 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
335
299
  isEmpty() {
336
300
  return this.vertexMap.size === 0 && this.edgeMap.size === 0;
337
301
  }
338
- /**
339
- * Time Complexity: O(1)
340
- * Space Complexity: O(1)
341
- */
342
302
  /**
343
303
  * Time Complexity: O(1)
344
304
  * Space Complexity: O(1)
@@ -364,10 +324,6 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
364
324
  cloned.edgeMap = new Map(this.edgeMap);
365
325
  return cloned;
366
326
  }
367
- /**
368
- * Time Complexity: O(1)
369
- * Space Complexity: O(1)
370
- */
371
327
  /**
372
328
  * Time Complexity: O(V + E)
373
329
  * Space Complexity: O(V)
@@ -428,12 +384,6 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
428
384
  cutVertices
429
385
  };
430
386
  }
431
- /**
432
- * Time Complexity: O(V + E)
433
- * Space Complexity: O(V)
434
- * Tarjan is an algorithm based on dfs,which is used to solve the connectivity problem of graphs.
435
- * 1. Tarjan can find the articulation points and bridges(critical edgeMap) of undirected graphs in linear time
436
- */
437
387
  /**
438
388
  * The function "getBridges" returns an array of bridges in a graph using the Tarjan's algorithm.
439
389
  * @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)
@@ -26,12 +26,10 @@ class HashMap extends base_1.IterableEntryBase {
26
26
  this._hashFn = (key) => String(key);
27
27
  if (options) {
28
28
  const { hashFn, toEntryFn } = options;
29
- if (hashFn) {
29
+ if (hashFn)
30
30
  this._hashFn = hashFn;
31
- }
32
- if (toEntryFn) {
31
+ if (toEntryFn)
33
32
  this._toEntryFn = toEntryFn;
34
- }
35
33
  }
36
34
  if (entryOrRawElements) {
37
35
  this.setMany(entryOrRawElements);
@@ -141,8 +139,8 @@ class HashMap extends base_1.IterableEntryBase {
141
139
  key = rawEle[0];
142
140
  value = rawEle[1];
143
141
  }
144
- else if (this.toEntryFn) {
145
- const item = this.toEntryFn(rawEle);
142
+ else if (this._toEntryFn) {
143
+ const item = this._toEntryFn(rawEle);
146
144
  key = item[0];
147
145
  value = item[1];
148
146
  }
@@ -211,8 +209,7 @@ class HashMap extends base_1.IterableEntryBase {
211
209
  /**
212
210
  * Time Complexity: O(n)
213
211
  * Space Complexity: O(n)
214
- */
215
- /**
212
+ *
216
213
  * The clone function creates a new HashMap with the same key-value pairs as
217
214
  * this one. The clone function is useful for creating a copy of an existing
218
215
  * HashMap, and then modifying that copy without affecting the original.
@@ -220,12 +217,8 @@ class HashMap extends base_1.IterableEntryBase {
220
217
  * @return A new hashmap with the same values as this one
221
218
  */
222
219
  clone() {
223
- return new HashMap(this, { hashFn: this.hashFn, toEntryFn: this.toEntryFn });
220
+ return new HashMap(this, { hashFn: this._hashFn, toEntryFn: this._toEntryFn });
224
221
  }
225
- /**
226
- * Time Complexity: O(n)
227
- * Space Complexity: O(n)
228
- */
229
222
  /**
230
223
  * Time Complexity: O(n)
231
224
  * Space Complexity: O(n)
@@ -274,17 +267,6 @@ class HashMap extends base_1.IterableEntryBase {
274
267
  }
275
268
  return filteredMap;
276
269
  }
277
- /**
278
- * The put function sets a value in a data structure using a specified key.
279
- * @param {K} key - The key parameter is of type K, which represents the type of the key being passed
280
- * to the function.
281
- * @param {V} value - The value parameter represents the value that you want to associate with the
282
- * specified key in the data structure.
283
- * @returns The method is returning a boolean value.
284
- */
285
- put(key, value) {
286
- return this.set(key, value);
287
- }
288
270
  /**
289
271
  * The function returns an iterator that yields key-value pairs from both an object store and an
290
272
  * object map.
@@ -317,7 +299,7 @@ class HashMap extends base_1.IterableEntryBase {
317
299
  const keyType = typeof key;
318
300
  let strKey;
319
301
  if (keyType !== 'string' && keyType !== 'number' && keyType !== 'symbol') {
320
- strKey = this.hashFn(key);
302
+ strKey = this._hashFn(key);
321
303
  }
322
304
  else {
323
305
  if (keyType === 'number') {
@@ -376,10 +358,7 @@ class LinkedHashMap extends base_1.IterableEntryBase {
376
358
  }
377
359
  }
378
360
  if (entryOrRawElements) {
379
- for (const el of entryOrRawElements) {
380
- const [key, value] = this.toEntryFn(el);
381
- this.set(key, value);
382
- }
361
+ this.setMany(entryOrRawElements);
383
362
  }
384
363
  }
385
364
  /**
@@ -441,10 +420,6 @@ class LinkedHashMap extends base_1.IterableEntryBase {
441
420
  get size() {
442
421
  return this._size;
443
422
  }
444
- /**
445
- * Time Complexity: O(1)
446
- * Space Complexity: O(1)
447
- */
448
423
  /**
449
424
  * Time Complexity: O(1)
450
425
  * Space Complexity: O(1)
@@ -458,10 +433,6 @@ class LinkedHashMap extends base_1.IterableEntryBase {
458
433
  return;
459
434
  return [this.head.key, this.head.value];
460
435
  }
461
- /**
462
- * Time Complexity: O(1)
463
- * Space Complexity: O(1)
464
- */
465
436
  /**
466
437
  * Time Complexity: O(1)
467
438
  * Space Complexity: O(1)
@@ -496,10 +467,6 @@ class LinkedHashMap extends base_1.IterableEntryBase {
496
467
  node = node.prev;
497
468
  }
498
469
  }
499
- /**
500
- * Time Complexity: O(1)
501
- * Space Complexity: O(1)
502
- */
503
470
  /**
504
471
  * Time Complexity: O(1)
505
472
  * Space Complexity: O(1)
@@ -516,7 +483,7 @@ class LinkedHashMap extends base_1.IterableEntryBase {
516
483
  let node;
517
484
  const isNewKey = !this.has(key); // Check if the key is new
518
485
  if ((0, utils_1.isWeakKey)(key)) {
519
- const hash = this.objHashFn(key);
486
+ const hash = this._objHashFn(key);
520
487
  node = this.objMap.get(hash);
521
488
  if (!node && isNewKey) {
522
489
  // Create a new node
@@ -529,7 +496,7 @@ class LinkedHashMap extends base_1.IterableEntryBase {
529
496
  }
530
497
  }
531
498
  else {
532
- const hash = this.hashFn(key);
499
+ const hash = this._hashFn(key);
533
500
  node = this.noObjMap[hash];
534
501
  if (!node && isNewKey) {
535
502
  this.noObjMap[hash] = node = { key, value, prev: this.tail, next: this._sentinel };
@@ -566,8 +533,18 @@ class LinkedHashMap extends base_1.IterableEntryBase {
566
533
  setMany(entryOrRawElements) {
567
534
  const results = [];
568
535
  for (const rawEle of entryOrRawElements) {
569
- const [key, value] = this.toEntryFn(rawEle);
570
- results.push(this.set(key, value));
536
+ let key, value;
537
+ if (this.isEntry(rawEle)) {
538
+ key = rawEle[0];
539
+ value = rawEle[1];
540
+ }
541
+ else if (this._toEntryFn) {
542
+ const item = this._toEntryFn(rawEle);
543
+ key = item[0];
544
+ value = item[1];
545
+ }
546
+ if (key !== undefined && value !== undefined)
547
+ results.push(this.set(key, value));
571
548
  }
572
549
  return results;
573
550
  }
@@ -579,18 +556,14 @@ class LinkedHashMap extends base_1.IterableEntryBase {
579
556
  */
580
557
  has(key) {
581
558
  if ((0, utils_1.isWeakKey)(key)) {
582
- const hash = this.objHashFn(key);
559
+ const hash = this._objHashFn(key);
583
560
  return this.objMap.has(hash);
584
561
  }
585
562
  else {
586
- const hash = this.hashFn(key);
563
+ const hash = this._hashFn(key);
587
564
  return hash in this.noObjMap;
588
565
  }
589
566
  }
590
- /**
591
- * Time Complexity: O(1)
592
- * Space Complexity: O(1)
593
- */
594
567
  /**
595
568
  * Time Complexity: O(1)
596
569
  * Space Complexity: O(1)
@@ -606,20 +579,16 @@ class LinkedHashMap extends base_1.IterableEntryBase {
606
579
  */
607
580
  get(key) {
608
581
  if ((0, utils_1.isWeakKey)(key)) {
609
- const hash = this.objHashFn(key);
582
+ const hash = this._objHashFn(key);
610
583
  const node = this.objMap.get(hash);
611
584
  return node ? node.value : undefined;
612
585
  }
613
586
  else {
614
- const hash = this.hashFn(key);
587
+ const hash = this._hashFn(key);
615
588
  const node = this.noObjMap[hash];
616
589
  return node ? node.value : undefined;
617
590
  }
618
591
  }
619
- /**
620
- * Time Complexity: O(n)
621
- * Space Complexity: O(1)
622
- */
623
592
  /**
624
593
  * Time Complexity: O(n)
625
594
  * Space Complexity: O(1)
@@ -639,10 +608,6 @@ class LinkedHashMap extends base_1.IterableEntryBase {
639
608
  }
640
609
  return node.value;
641
610
  }
642
- /**
643
- * Time Complexity: O(1)
644
- * Space Complexity: O(1)
645
- */
646
611
  /**
647
612
  * Time Complexity: O(1)
648
613
  * Space Complexity: O(1)
@@ -656,7 +621,7 @@ class LinkedHashMap extends base_1.IterableEntryBase {
656
621
  delete(key) {
657
622
  let node;
658
623
  if ((0, utils_1.isWeakKey)(key)) {
659
- const hash = this.objHashFn(key);
624
+ const hash = this._objHashFn(key);
660
625
  // Get nodes from WeakMap
661
626
  node = this.objMap.get(hash);
662
627
  if (!node) {
@@ -666,7 +631,7 @@ class LinkedHashMap extends base_1.IterableEntryBase {
666
631
  this.objMap.delete(hash);
667
632
  }
668
633
  else {
669
- const hash = this.hashFn(key);
634
+ const hash = this._hashFn(key);
670
635
  // Get nodes from noObjMap
671
636
  node = this.noObjMap[hash];
672
637
  if (!node) {
@@ -679,10 +644,6 @@ class LinkedHashMap extends base_1.IterableEntryBase {
679
644
  this._deleteNode(node);
680
645
  return true;
681
646
  }
682
- /**
683
- * Time Complexity: O(n)
684
- * Space Complexity: O(1)
685
- */
686
647
  /**
687
648
  * Time Complexity: O(n)
688
649
  * Space Complexity: O(1)
@@ -700,10 +661,6 @@ class LinkedHashMap extends base_1.IterableEntryBase {
700
661
  }
701
662
  return this._deleteNode(node);
702
663
  }
703
- /**
704
- * Time Complexity: O(1)
705
- * Space Complexity: O(1)
706
- */
707
664
  /**
708
665
  * Time Complexity: O(1)
709
666
  * Space Complexity: O(1)
@@ -724,10 +681,6 @@ class LinkedHashMap extends base_1.IterableEntryBase {
724
681
  isEntry(rawElement) {
725
682
  return Array.isArray(rawElement) && rawElement.length === 2;
726
683
  }
727
- /**
728
- * Time Complexity: O(1)
729
- * Space Complexity: O(1)
730
- */
731
684
  /**
732
685
  * Time Complexity: O(1)
733
686
  * Space Complexity: O(1)
@@ -739,10 +692,6 @@ class LinkedHashMap extends base_1.IterableEntryBase {
739
692
  this._size = 0;
740
693
  this._head = this._tail = this._sentinel.prev = this._sentinel.next = this._sentinel;
741
694
  }
742
- /**
743
- * Time Complexity: O(n)
744
- * Space Complexity: O(n)
745
- */
746
695
  /**
747
696
  * Time Complexity: O(n)
748
697
  * Space Complexity: O(n)
@@ -753,17 +702,13 @@ class LinkedHashMap extends base_1.IterableEntryBase {
753
702
  * of the original `LinkedHashMap` object.
754
703
  */
755
704
  clone() {
756
- const cloned = new LinkedHashMap([], { hashFn: this.hashFn, objHashFn: this.objHashFn });
705
+ const cloned = new LinkedHashMap([], { hashFn: this._hashFn, objHashFn: this._objHashFn });
757
706
  for (const entry of this) {
758
707
  const [key, value] = entry;
759
708
  cloned.set(key, value);
760
709
  }
761
710
  return cloned;
762
711
  }
763
- /**
764
- * Time Complexity: O(n)
765
- * Space Complexity: O(n)
766
- */
767
712
  /**
768
713
  * Time Complexity: O(n)
769
714
  * Space Complexity: O(n)
@@ -790,10 +735,6 @@ class LinkedHashMap extends base_1.IterableEntryBase {
790
735
  }
791
736
  return filteredMap;
792
737
  }
793
- /**
794
- * Time Complexity: O(n)
795
- * Space Complexity: O(n)
796
- */
797
738
  /**
798
739
  * Time Complexity: O(n)
799
740
  * Space Complexity: O(n)
@@ -821,29 +762,6 @@ class LinkedHashMap extends base_1.IterableEntryBase {
821
762
  }
822
763
  return mappedMap;
823
764
  }
824
- /**
825
- * Time Complexity: O(1)
826
- * Space Complexity: O(1)
827
- */
828
- /**
829
- * Time Complexity: O(1)
830
- * Space Complexity: O(1)
831
- *
832
- * The put function sets a value in a data structure using a specified key.
833
- * @param {K} key - The key parameter is of type K, which represents the type of the key being passed
834
- * to the function.
835
- * @param {V} value - The value parameter represents the value that you want to associate with the
836
- * specified key in the data structure.
837
- * @returns The method is returning a boolean value.
838
- */
839
- put(key, value) {
840
- return this.set(key, value);
841
- }
842
- /**
843
- * Time Complexity: O(n)
844
- * Space Complexity: O(1)
845
- * where n is the number of entries in the LinkedHashMap.
846
- */
847
765
  /**
848
766
  * Time Complexity: O(n)
849
767
  * Space Complexity: O(1)
@@ -858,10 +776,6 @@ class LinkedHashMap extends base_1.IterableEntryBase {
858
776
  node = node.next;
859
777
  }
860
778
  }
861
- /**
862
- * Time Complexity: O(1)
863
- * Space Complexity: O(1)
864
- */
865
779
  /**
866
780
  * Time Complexity: O(1)
867
781
  * Space Complexity: O(1)