data-structure-typed 2.6.0 → 2.6.2

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 (160) hide show
  1. package/.github/workflows/ci.yml +7 -2
  2. package/.github/workflows/release-package.yml +9 -2
  3. package/CHANGELOG.md +9 -1
  4. package/dist/cjs/binary-tree.cjs +2927 -23688
  5. package/dist/cjs/graph.cjs +845 -2634
  6. package/dist/cjs/hash.cjs +185 -616
  7. package/dist/cjs/heap.cjs +266 -818
  8. package/dist/cjs/index.cjs +5116 -31358
  9. package/dist/cjs/linked-list.cjs +644 -2615
  10. package/dist/cjs/matrix.cjs +220 -535
  11. package/dist/cjs/priority-queue.cjs +266 -818
  12. package/dist/cjs/queue.cjs +637 -2343
  13. package/dist/cjs/stack.cjs +124 -530
  14. package/dist/cjs/trie.cjs +145 -592
  15. package/dist/cjs-legacy/binary-tree.cjs +4352 -25113
  16. package/dist/cjs-legacy/graph.cjs +847 -2636
  17. package/dist/cjs-legacy/hash.cjs +181 -612
  18. package/dist/cjs-legacy/heap.cjs +266 -818
  19. package/dist/cjs-legacy/index.cjs +6657 -32899
  20. package/dist/cjs-legacy/linked-list.cjs +640 -2611
  21. package/dist/cjs-legacy/matrix.cjs +220 -535
  22. package/dist/cjs-legacy/priority-queue.cjs +266 -818
  23. package/dist/cjs-legacy/queue.cjs +634 -2340
  24. package/dist/cjs-legacy/stack.cjs +124 -530
  25. package/dist/cjs-legacy/trie.cjs +145 -592
  26. package/dist/esm/binary-tree.mjs +2927 -23688
  27. package/dist/esm/graph.mjs +845 -2634
  28. package/dist/esm/hash.mjs +185 -616
  29. package/dist/esm/heap.mjs +266 -818
  30. package/dist/esm/index.mjs +5116 -31358
  31. package/dist/esm/linked-list.mjs +644 -2615
  32. package/dist/esm/matrix.mjs +220 -535
  33. package/dist/esm/priority-queue.mjs +266 -818
  34. package/dist/esm/queue.mjs +637 -2343
  35. package/dist/esm/stack.mjs +124 -530
  36. package/dist/esm/trie.mjs +145 -592
  37. package/dist/esm-legacy/binary-tree.mjs +4352 -25113
  38. package/dist/esm-legacy/graph.mjs +847 -2636
  39. package/dist/esm-legacy/hash.mjs +181 -612
  40. package/dist/esm-legacy/heap.mjs +266 -818
  41. package/dist/esm-legacy/index.mjs +6657 -32899
  42. package/dist/esm-legacy/linked-list.mjs +640 -2611
  43. package/dist/esm-legacy/matrix.mjs +220 -535
  44. package/dist/esm-legacy/priority-queue.mjs +266 -818
  45. package/dist/esm-legacy/queue.mjs +634 -2340
  46. package/dist/esm-legacy/stack.mjs +124 -530
  47. package/dist/esm-legacy/trie.mjs +145 -592
  48. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +29 -500
  49. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +38 -563
  50. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +230 -1212
  51. package/dist/types/data-structures/binary-tree/bst.d.ts +124 -1063
  52. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +99 -854
  53. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +62 -314
  54. package/dist/types/data-structures/binary-tree/tree-map.d.ts +366 -5057
  55. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +277 -4885
  56. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +253 -3929
  57. package/dist/types/data-structures/binary-tree/tree-set.d.ts +261 -4782
  58. package/dist/types/data-structures/graph/abstract-graph.d.ts +44 -44
  59. package/dist/types/data-structures/graph/directed-graph.d.ts +130 -527
  60. package/dist/types/data-structures/graph/undirected-graph.d.ts +125 -482
  61. package/dist/types/data-structures/hash/hash-map.d.ts +132 -562
  62. package/dist/types/data-structures/heap/heap.d.ts +194 -746
  63. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +120 -809
  64. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +121 -733
  65. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +193 -863
  66. package/dist/types/data-structures/matrix/matrix.d.ts +159 -474
  67. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -6
  68. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +6 -11
  69. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
  70. package/dist/types/data-structures/queue/deque.d.ts +196 -804
  71. package/dist/types/data-structures/queue/queue.d.ts +99 -585
  72. package/dist/types/data-structures/stack/stack.d.ts +75 -481
  73. package/dist/types/data-structures/trie/trie.d.ts +98 -584
  74. package/dist/umd/data-structure-typed.js +6580 -32822
  75. package/dist/umd/data-structure-typed.min.js +3 -3
  76. package/docs-site-docusaurus/docs/api/classes/AVLTree.md +162 -215
  77. package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +9 -9
  78. package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +47 -47
  79. package/docs-site-docusaurus/docs/api/classes/BST.md +155 -208
  80. package/docs-site-docusaurus/docs/api/classes/BSTNode.md +7 -7
  81. package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +13 -29
  82. package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +104 -158
  83. package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
  84. package/docs-site-docusaurus/docs/api/classes/Deque.md +253 -101
  85. package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +60 -80
  86. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +244 -114
  87. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +6 -6
  88. package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +9 -9
  89. package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
  90. package/docs-site-docusaurus/docs/api/classes/HashMap.md +52 -48
  91. package/docs-site-docusaurus/docs/api/classes/Heap.md +119 -64
  92. package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +84 -14
  93. package/docs-site-docusaurus/docs/api/classes/LinearBase.md +138 -34
  94. package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +149 -41
  95. package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +23 -23
  96. package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +172 -92
  97. package/docs-site-docusaurus/docs/api/classes/MapGraph.md +60 -80
  98. package/docs-site-docusaurus/docs/api/classes/Matrix.md +57 -52
  99. package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +117 -62
  100. package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +120 -70
  101. package/docs-site-docusaurus/docs/api/classes/MinHeap.md +117 -62
  102. package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +125 -75
  103. package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +119 -64
  104. package/docs-site-docusaurus/docs/api/classes/Queue.md +158 -74
  105. package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +171 -225
  106. package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -22
  107. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +172 -94
  108. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +4 -4
  109. package/docs-site-docusaurus/docs/api/classes/SkipList.md +98 -75
  110. package/docs-site-docusaurus/docs/api/classes/Stack.md +112 -50
  111. package/docs-site-docusaurus/docs/api/classes/TreeMap.md +104 -129
  112. package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +90 -121
  113. package/docs-site-docusaurus/docs/api/classes/TreeSet.md +298 -107
  114. package/docs-site-docusaurus/docs/api/classes/Trie.md +116 -58
  115. package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
  116. package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +59 -77
  117. package/package.json +45 -46
  118. package/src/common/error.ts +15 -32
  119. package/src/common/index.ts +0 -3
  120. package/src/data-structures/base/iterable-element-base.ts +0 -3
  121. package/src/data-structures/base/linear-base.ts +2 -36
  122. package/src/data-structures/binary-tree/avl-tree.ts +31 -529
  123. package/src/data-structures/binary-tree/binary-indexed-tree.ts +47 -572
  124. package/src/data-structures/binary-tree/binary-tree.ts +326 -1311
  125. package/src/data-structures/binary-tree/bst.ts +158 -1082
  126. package/src/data-structures/binary-tree/red-black-tree.ts +451 -1290
  127. package/src/data-structures/binary-tree/segment-tree.ts +73 -351
  128. package/src/data-structures/binary-tree/tree-map.ts +462 -5124
  129. package/src/data-structures/binary-tree/tree-multi-map.ts +302 -4914
  130. package/src/data-structures/binary-tree/tree-multi-set.ts +299 -3983
  131. package/src/data-structures/binary-tree/tree-set.ts +338 -4836
  132. package/src/data-structures/graph/abstract-graph.ts +98 -167
  133. package/src/data-structures/graph/directed-graph.ts +137 -562
  134. package/src/data-structures/graph/map-graph.ts +0 -3
  135. package/src/data-structures/graph/undirected-graph.ts +132 -511
  136. package/src/data-structures/hash/hash-map.ts +154 -582
  137. package/src/data-structures/heap/heap.ts +200 -795
  138. package/src/data-structures/linked-list/doubly-linked-list.ts +121 -865
  139. package/src/data-structures/linked-list/singly-linked-list.ts +122 -794
  140. package/src/data-structures/linked-list/skip-linked-list.ts +211 -918
  141. package/src/data-structures/matrix/matrix.ts +179 -518
  142. package/src/data-structures/matrix/navigator.ts +0 -1
  143. package/src/data-structures/priority-queue/max-priority-queue.ts +1 -6
  144. package/src/data-structures/priority-queue/min-priority-queue.ts +6 -11
  145. package/src/data-structures/priority-queue/priority-queue.ts +1 -2
  146. package/src/data-structures/queue/deque.ts +214 -882
  147. package/src/data-structures/queue/queue.ts +102 -625
  148. package/src/data-structures/stack/stack.ts +76 -505
  149. package/src/data-structures/trie/trie.ts +98 -628
  150. package/src/types/common.ts +0 -10
  151. package/src/types/data-structures/binary-tree/bst.ts +0 -7
  152. package/src/types/data-structures/binary-tree/red-black-tree.ts +0 -1
  153. package/src/types/data-structures/graph/abstract-graph.ts +0 -2
  154. package/src/types/data-structures/hash/hash-map.ts +0 -3
  155. package/src/types/data-structures/hash/index.ts +0 -1
  156. package/src/types/data-structures/matrix/navigator.ts +0 -2
  157. package/src/types/utils/utils.ts +0 -7
  158. package/src/types/utils/validate-type.ts +0 -7
  159. package/src/utils/number.ts +0 -2
  160. package/src/utils/utils.ts +0 -5
package/dist/esm/hash.mjs CHANGED
@@ -230,6 +230,7 @@ var HashMap = class extends IterableEntryBase {
230
230
  static {
231
231
  __name(this, "HashMap");
232
232
  }
233
+ _toEntryFn;
233
234
  /**
234
235
  * Create a HashMap and optionally bulk-insert entries.
235
236
  * @remarks Time O(N), Space O(N)
@@ -264,7 +265,6 @@ var HashMap = class extends IterableEntryBase {
264
265
  get objMap() {
265
266
  return this._objMap;
266
267
  }
267
- _toEntryFn;
268
268
  /**
269
269
  * Get the raw→entry converter function if present.
270
270
  * @remarks Time O(1), Space O(1)
@@ -292,107 +292,30 @@ var HashMap = class extends IterableEntryBase {
292
292
  return this._hashFn;
293
293
  }
294
294
  /**
295
- * Check whether the map is empty.
296
- * @remarks Time O(1), Space O(1)
297
- * @returns True if size is 0.
298
-
299
-
300
-
301
-
302
-
303
-
304
-
305
-
306
-
307
-
308
-
309
-
310
-
311
-
312
-
313
-
314
-
315
-
316
-
317
-
318
-
319
-
320
-
321
-
322
-
323
-
324
-
325
-
326
-
327
-
328
-
329
-
330
-
331
-
332
-
333
-
334
-
335
-
336
-
337
-
338
- * @example
339
- * // Check if empty
340
- * const map = new HashMap();
341
- * console.log(map.isEmpty()); // true;
342
- */
295
+ * Check whether the map is empty.
296
+ * @remarks Time O(1), Space O(1)
297
+ * @returns True if size is 0.
298
+ * @example
299
+ * // Check if empty
300
+ * const map = new HashMap();
301
+ * console.log(map.isEmpty()); // true;
302
+ */
343
303
  isEmpty() {
344
304
  return this._size === 0;
345
305
  }
346
306
  /**
347
- * Remove all entries and reset counters.
348
- * @remarks Time O(N), Space O(1)
349
- * @returns void
350
-
351
-
352
-
353
-
354
-
355
-
356
-
357
-
358
-
359
-
360
-
361
-
362
-
363
-
364
-
365
-
366
-
367
-
368
-
369
-
370
-
371
-
372
-
373
-
374
-
375
-
376
-
377
-
378
-
379
-
380
-
381
-
382
-
383
-
384
-
385
-
386
-
387
-
388
-
389
-
390
- * @example
391
- * // Remove all entries
392
- * const map = new HashMap<string, number>([['a', 1], ['b', 2]]);
393
- * map.clear();
394
- * console.log(map.isEmpty()); // true;
395
- */
307
+ * Remove all entries and reset counters.
308
+ * @remarks Time O(N), Space O(1)
309
+ * @returns void
310
+ * @example
311
+ * // Remove all entries
312
+ * const map = new HashMap<string, number>([
313
+ * ['a', 1],
314
+ * ['b', 2]
315
+ * ]);
316
+ * map.clear();
317
+ * console.log(map.isEmpty()); // true;
318
+ */
396
319
  clear() {
397
320
  this._store = {};
398
321
  this._objMap.clear();
@@ -407,114 +330,30 @@ var HashMap = class extends IterableEntryBase {
407
330
  return Array.isArray(rawElement) && rawElement.length === 2;
408
331
  }
409
332
  /**
410
- * Insert or replace a single entry.
411
- * @remarks Time O(1), Space O(1)
412
- * @param key - Key.
413
- * @param value - Value.
414
- * @returns True when the operation succeeds.
415
-
416
-
417
-
418
-
419
-
420
-
421
-
422
-
423
-
424
-
425
-
426
-
427
-
428
-
429
-
430
-
431
-
432
-
433
-
434
-
435
-
436
-
437
-
438
-
439
-
440
-
441
-
442
-
443
-
444
-
445
-
446
-
447
-
448
-
449
-
450
-
451
-
452
-
453
-
454
-
455
-
456
-
457
-
458
-
459
-
460
-
461
-
462
-
463
-
464
-
465
-
466
-
467
-
468
-
469
-
470
-
471
-
472
-
473
-
474
-
475
-
476
-
477
-
478
-
479
-
480
-
481
-
482
-
483
-
484
-
485
-
486
-
487
-
488
-
489
-
490
-
491
-
492
-
493
-
494
-
495
-
496
-
497
-
498
-
499
- * @example
500
- * // basic HashMap creation and set operation
501
- * // Create a simple HashMap with key-value pairs
502
- * const map = new HashMap<number, string>([
503
- * [1, 'one'],
504
- * [2, 'two'],
505
- * [3, 'three']
506
- * ]);
507
- *
508
- * // Verify size
509
- * console.log(map.size); // 3;
510
- *
511
- * // Set a new key-value pair
512
- * map.set(4, 'four');
513
- * console.log(map.size); // 4;
514
- *
515
- * // Verify entries
516
- * console.log([...map.entries()]); // length: 4;
517
- */
333
+ * Insert or replace a single entry.
334
+ * @remarks Time O(1), Space O(1)
335
+ * @param key - Key.
336
+ * @param value - Value.
337
+ * @returns True when the operation succeeds.
338
+ * @example
339
+ * // basic HashMap creation and set operation
340
+ * // Create a simple HashMap with key-value pairs
341
+ * const map = new HashMap<number, string>([
342
+ * [1, 'one'],
343
+ * [2, 'two'],
344
+ * [3, 'three']
345
+ * ]);
346
+ *
347
+ * // Verify size
348
+ * console.log(map.size); // 3;
349
+ *
350
+ * // Set a new key-value pair
351
+ * map.set(4, 'four');
352
+ * console.log(map.size); // 4;
353
+ *
354
+ * // Verify entries
355
+ * console.log([...map.entries()]); // length: 4;
356
+ */
518
357
  set(key, value) {
519
358
  if (this._isObjKey(key)) {
520
359
  if (!this.objMap.has(key)) this._size++;
@@ -527,56 +366,20 @@ var HashMap = class extends IterableEntryBase {
527
366
  return this;
528
367
  }
529
368
  /**
530
- * Insert many entries from an iterable.
531
- * @remarks Time O(N), Space O(N)
532
- * @param entryOrRawElements - Iterable of entries or raw elements to insert.
533
- * @returns Array of per-entry results.
534
-
535
-
536
-
537
-
538
-
539
-
540
-
541
-
542
-
543
-
544
-
545
-
546
-
547
-
548
-
549
-
550
-
551
-
552
-
553
-
554
-
555
-
556
-
557
-
558
-
559
-
560
-
561
-
562
-
563
-
564
-
565
-
566
-
567
-
568
-
569
-
570
-
571
-
572
-
573
-
574
- * @example
575
- * // Add multiple entries
576
- * const map = new HashMap<string, number>();
577
- * map.setMany([['a', 1], ['b', 2], ['c', 3]]);
578
- * console.log(map.size); // 3;
579
- */
369
+ * Insert many entries from an iterable.
370
+ * @remarks Time O(N), Space O(N)
371
+ * @param entryOrRawElements - Iterable of entries or raw elements to insert.
372
+ * @returns Array of per-entry results.
373
+ * @example
374
+ * // Add multiple entries
375
+ * const map = new HashMap<string, number>();
376
+ * map.setMany([
377
+ * ['a', 1],
378
+ * ['b', 2],
379
+ * ['c', 3]
380
+ * ]);
381
+ * console.log(map.size); // 3;
382
+ */
580
383
  setMany(entryOrRawElements) {
581
384
  const results = [];
582
385
  for (const rawEle of entryOrRawElements) {
@@ -592,193 +395,74 @@ var HashMap = class extends IterableEntryBase {
592
395
  return results;
593
396
  }
594
397
  /**
595
- * Get the value for a key.
596
- * @remarks Time O(1), Space O(1)
597
- * @param key - Key to look up.
598
- * @returns Value or undefined.
599
-
600
-
601
-
602
-
603
-
604
-
605
-
606
-
607
-
608
-
609
-
610
-
611
-
612
-
613
-
614
-
615
-
616
-
617
-
618
-
619
-
620
-
621
-
622
-
623
-
624
-
625
-
626
-
627
-
628
-
629
-
630
-
631
-
632
-
633
-
634
-
635
-
636
-
637
-
638
-
639
-
640
-
641
- * @example
642
- * // HashMap get and has operations
643
- * const map = new HashMap<string, number>([
644
- * ['apple', 1],
645
- * ['banana', 2],
646
- * ['cherry', 3]
647
- * ]);
648
- *
649
- * // Check if key exists
650
- * console.log(map.has('apple')); // true;
651
- * console.log(map.has('date')); // false;
652
- *
653
- * // Get value by key
654
- * console.log(map.get('banana')); // 2;
655
- * console.log(map.get('grape')); // undefined;
656
- *
657
- * // Get all keys and values
658
- * const keys = [...map.keys()];
659
- * const values = [...map.values()];
660
- * console.log(keys); // contains 'apple';
661
- * console.log(values); // contains 3;
662
- */
398
+ * Get the value for a key.
399
+ * @remarks Time O(1), Space O(1)
400
+ * @param key - Key to look up.
401
+ * @returns Value or undefined.
402
+ * @example
403
+ * // HashMap get and has operations
404
+ * const map = new HashMap<string, number>([
405
+ * ['apple', 1],
406
+ * ['banana', 2],
407
+ * ['cherry', 3]
408
+ * ]);
409
+ *
410
+ * // Check if key exists
411
+ * console.log(map.has('apple')); // true;
412
+ * console.log(map.has('date')); // false;
413
+ *
414
+ * // Get value by key
415
+ * console.log(map.get('banana')); // 2;
416
+ * console.log(map.get('grape')); // undefined;
417
+ *
418
+ * // Get all keys and values
419
+ * const keys = [...map.keys()];
420
+ * const values = [...map.values()];
421
+ * console.log(keys); // contains 'apple';
422
+ * console.log(values); // contains 3;
423
+ */
663
424
  get(key) {
664
425
  if (this._isObjKey(key)) return this.objMap.get(key);
665
426
  const strKey = this._getNoObjKey(key);
666
427
  return this._store[strKey]?.value;
667
428
  }
668
429
  /**
669
- * Check if a key exists.
670
- * @remarks Time O(1), Space O(1)
671
- * @param key - Key to test.
672
- * @returns True if present.
673
-
674
-
675
-
676
-
677
-
678
-
679
-
680
-
681
-
682
-
683
-
684
-
685
-
686
-
687
-
688
-
689
-
690
-
691
-
692
-
693
-
694
-
695
-
696
-
697
-
698
-
699
-
700
-
701
-
702
-
703
-
704
-
705
-
706
-
707
-
708
-
709
-
710
-
711
-
712
-
713
-
714
-
715
- * @example
716
- * // Check key existence
717
- * const map = new HashMap<string, number>([['a', 1], ['b', 2]]);
718
- *
719
- * console.log(map.has('a')); // true;
720
- * console.log(map.has('z')); // false;
721
- */
430
+ * Check if a key exists.
431
+ * @remarks Time O(1), Space O(1)
432
+ * @param key - Key to test.
433
+ * @returns True if present.
434
+ * @example
435
+ * // Check key existence
436
+ * const map = new HashMap<string, number>([
437
+ * ['a', 1],
438
+ * ['b', 2]
439
+ * ]);
440
+ *
441
+ * console.log(map.has('a')); // true;
442
+ * console.log(map.has('z')); // false;
443
+ */
722
444
  has(key) {
723
445
  if (this._isObjKey(key)) return this.objMap.has(key);
724
446
  const strKey = this._getNoObjKey(key);
725
447
  return strKey in this.store;
726
448
  }
727
449
  /**
728
- * Delete an entry by key.
729
- * @remarks Time O(1), Space O(1)
730
- * @param key - Key to delete.
731
- * @returns True if the key was found and removed.
732
-
733
-
734
-
735
-
736
-
737
-
738
-
739
-
740
-
741
-
742
-
743
-
744
-
745
-
746
-
747
-
748
-
749
-
750
-
751
-
752
-
753
-
754
-
755
-
756
-
757
-
758
-
759
-
760
-
761
-
762
-
763
-
764
-
765
-
766
-
767
-
768
-
769
-
770
-
771
-
772
-
773
-
774
- * @example
775
- * // Remove entries by key
776
- * const map = new HashMap<string, number>([['x', 10], ['y', 20], ['z', 30]]);
777
- *
778
- * console.log(map.delete('y')); // true;
779
- * console.log(map.has('y')); // false;
780
- * console.log(map.size); // 2;
781
- */
450
+ * Delete an entry by key.
451
+ * @remarks Time O(1), Space O(1)
452
+ * @param key - Key to delete.
453
+ * @returns True if the key was found and removed.
454
+ * @example
455
+ * // Remove entries by key
456
+ * const map = new HashMap<string, number>([
457
+ * ['x', 10],
458
+ * ['y', 20],
459
+ * ['z', 30]
460
+ * ]);
461
+ *
462
+ * console.log(map.delete('y')); // true;
463
+ * console.log(map.has('y')); // false;
464
+ * console.log(map.size); // 2;
465
+ */
782
466
  delete(key) {
783
467
  if (this._isObjKey(key)) {
784
468
  if (this.objMap.has(key)) this._size--;
@@ -805,117 +489,38 @@ var HashMap = class extends IterableEntryBase {
805
489
  return this;
806
490
  }
807
491
  /**
808
- * Deep clone this map, preserving hashing behavior.
809
- * @remarks Time O(N), Space O(N)
810
- * @returns A new map with the same content.
811
-
812
-
813
-
814
-
815
-
816
-
817
-
818
-
819
-
820
-
821
-
822
-
823
-
824
-
825
-
826
-
827
-
828
-
829
-
830
-
831
-
832
-
833
-
834
-
835
-
836
-
837
-
838
-
839
-
840
-
841
-
842
-
843
-
844
-
845
-
846
-
847
-
848
-
849
-
850
-
851
- * @example
852
- * // Create independent copy
853
- * const map = new HashMap<string, number>([['a', 1]]);
854
- * const copy = map.clone();
855
- * copy.set('a', 99);
856
- * console.log(map.get('a')); // 1;
857
- */
492
+ * Deep clone this map, preserving hashing behavior.
493
+ * @remarks Time O(N), Space O(N)
494
+ * @returns A new map with the same content.
495
+ * @example
496
+ * // Create independent copy
497
+ * const map = new HashMap<string, number>([['a', 1]]);
498
+ * const copy = map.clone();
499
+ * copy.set('a', 99);
500
+ * console.log(map.get('a')); // 1;
501
+ */
858
502
  clone() {
859
503
  const opts = { hashFn: this._hashFn, toEntryFn: this._toEntryFn };
860
504
  return this._createLike(this, opts);
861
505
  }
862
506
  /**
863
- * Map values to a new map with the same keys.
864
- * @remarks Time O(N), Space O(N)
865
- * @template VM
866
- * @param callbackfn - Mapping function (key, value, index, map) → newValue.
867
- * @param [thisArg] - Value for `this` inside the callback.
868
- * @returns A new map with transformed values.
869
-
870
-
871
-
872
-
873
-
874
-
875
-
876
-
877
-
878
-
879
-
880
-
881
-
882
-
883
-
884
-
885
-
886
-
887
-
888
-
889
-
890
-
891
-
892
-
893
-
894
-
895
-
896
-
897
-
898
-
899
-
900
-
901
-
902
-
903
-
904
-
905
-
906
-
907
-
908
-
909
-
910
-
911
- * @example
912
- * // Transform all values
913
- * const prices = new HashMap<string, number>([['apple', 1], ['banana', 2]]);
914
- *
915
- * const doubled = prices.map(v => (v ?? 0) * 2);
916
- * console.log(doubled.get('apple')); // 2;
917
- * console.log(doubled.get('banana')); // 4;
918
- */
507
+ * Map values to a new map with the same keys.
508
+ * @remarks Time O(N), Space O(N)
509
+ * @template VM
510
+ * @param callbackfn - Mapping function (key, value, index, map) → newValue.
511
+ * @param [thisArg] - Value for `this` inside the callback.
512
+ * @returns A new map with transformed values.
513
+ * @example
514
+ * // Transform all values
515
+ * const prices = new HashMap<string, number>([
516
+ * ['apple', 1],
517
+ * ['banana', 2]
518
+ * ]);
519
+ *
520
+ * const doubled = prices.map(v => (v ?? 0) * 2);
521
+ * console.log(doubled.get('apple')); // 2;
522
+ * console.log(doubled.get('banana')); // 4;
523
+ */
919
524
  map(callbackfn, thisArg) {
920
525
  const out = this._createLike();
921
526
  let index = 0;
@@ -923,79 +528,37 @@ var HashMap = class extends IterableEntryBase {
923
528
  return out;
924
529
  }
925
530
  /**
926
- * Filter entries into a new map.
927
- * @remarks Time O(N), Space O(N)
928
- * @param predicate - Predicate (key, value, index, map) → boolean.
929
- * @param [thisArg] - Value for `this` inside the predicate.
930
- * @returns A new map containing entries that satisfied the predicate.
931
-
932
-
933
-
934
-
935
-
936
-
937
-
938
-
939
-
940
-
941
-
942
-
943
-
944
-
945
-
946
-
947
-
948
-
949
-
950
-
951
-
952
-
953
-
954
-
955
-
956
-
957
-
958
-
959
-
960
-
961
-
962
-
963
-
964
-
965
-
966
-
967
-
968
-
969
-
970
-
971
-
972
-
973
- * @example
974
- * // HashMap iteration and filter operations
975
- * const map = new HashMap<number, string>([
976
- * [1, 'Alice'],
977
- * [2, 'Bob'],
978
- * [3, 'Charlie'],
979
- * [4, 'Diana'],
980
- * [5, 'Eve']
981
- * ]);
982
- *
983
- * // Iterate through entries
984
- * const entries: [number, string][] = [];
985
- * for (const [key, value] of map) {
986
- * entries.push([key, value]);
987
- * }
988
- * console.log(entries); // length: 5;
989
- *
990
- * // Filter operation (for iteration with collection methods)
991
- * const filtered = [...map].filter(([key]) => key > 2);
992
- * console.log(filtered.length); // 3;
993
- *
994
- * // Map operation
995
- * const values = [...map.values()].map(v => v.length);
996
- * console.log(values); // contains 3; // 'Bob', 'Eve'
997
- * console.log(values); // contains 7;
998
- */
531
+ * Filter entries into a new map.
532
+ * @remarks Time O(N), Space O(N)
533
+ * @param predicate - Predicate (key, value, index, map) → boolean.
534
+ * @param [thisArg] - Value for `this` inside the predicate.
535
+ * @returns A new map containing entries that satisfied the predicate.
536
+ * @example
537
+ * // HashMap iteration and filter operations
538
+ * const map = new HashMap<number, string>([
539
+ * [1, 'Alice'],
540
+ * [2, 'Bob'],
541
+ * [3, 'Charlie'],
542
+ * [4, 'Diana'],
543
+ * [5, 'Eve']
544
+ * ]);
545
+ *
546
+ * // Iterate through entries
547
+ * const entries: [number, string][] = [];
548
+ * for (const [key, value] of map) {
549
+ * entries.push([key, value]);
550
+ * }
551
+ * console.log(entries); // length: 5;
552
+ *
553
+ * // Filter operation (for iteration with collection methods)
554
+ * const filtered = [...map].filter(([key]) => key > 2);
555
+ * console.log(filtered.length); // 3;
556
+ *
557
+ * // Map operation
558
+ * const values = [...map.values()].map(v => v.length);
559
+ * console.log(values); // contains 3; // 'Bob', 'Eve'
560
+ * console.log(values); // contains 7;
561
+ */
999
562
  filter(predicate, thisArg) {
1000
563
  const out = this._createLike();
1001
564
  let index = 0;
@@ -1115,12 +678,6 @@ var LinkedHashMap = class extends IterableEntryBase {
1115
678
  get tail() {
1116
679
  return this._tail;
1117
680
  }
1118
- _toEntryFn = /* @__PURE__ */ __name((rawElement) => {
1119
- if (this.isEntry(rawElement)) {
1120
- return rawElement;
1121
- }
1122
- raise(TypeError, ERR.invalidArgument("If elements do not adhere to [key, value], provide options.toEntryFn to transform raw records.", "HashMap"));
1123
- }, "_toEntryFn");
1124
681
  get toEntryFn() {
1125
682
  return this._toEntryFn;
1126
683
  }
@@ -1354,6 +911,18 @@ var LinkedHashMap = class extends IterableEntryBase {
1354
911
  }
1355
912
  return out;
1356
913
  }
914
+ _toEntryFn = /* @__PURE__ */ __name((rawElement) => {
915
+ if (this.isEntry(rawElement)) {
916
+ return rawElement;
917
+ }
918
+ raise(
919
+ TypeError,
920
+ ERR.invalidArgument(
921
+ "If elements do not adhere to [key, value], provide options.toEntryFn to transform raw records.",
922
+ "HashMap"
923
+ )
924
+ );
925
+ }, "_toEntryFn");
1357
926
  *_getIterator() {
1358
927
  let node = this.head;
1359
928
  while (node !== this._sentinel) {