data-structure-typed 2.6.1 → 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 (116) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/dist/cjs/binary-tree.cjs +2927 -23688
  3. package/dist/cjs/graph.cjs +845 -2634
  4. package/dist/cjs/hash.cjs +185 -616
  5. package/dist/cjs/heap.cjs +266 -818
  6. package/dist/cjs/index.cjs +5116 -31358
  7. package/dist/cjs/linked-list.cjs +644 -2615
  8. package/dist/cjs/matrix.cjs +220 -535
  9. package/dist/cjs/priority-queue.cjs +266 -818
  10. package/dist/cjs/queue.cjs +637 -2343
  11. package/dist/cjs/stack.cjs +124 -530
  12. package/dist/cjs/trie.cjs +145 -592
  13. package/dist/cjs-legacy/binary-tree.cjs +4352 -25113
  14. package/dist/cjs-legacy/graph.cjs +847 -2636
  15. package/dist/cjs-legacy/hash.cjs +181 -612
  16. package/dist/cjs-legacy/heap.cjs +266 -818
  17. package/dist/cjs-legacy/index.cjs +6657 -32899
  18. package/dist/cjs-legacy/linked-list.cjs +640 -2611
  19. package/dist/cjs-legacy/matrix.cjs +220 -535
  20. package/dist/cjs-legacy/priority-queue.cjs +266 -818
  21. package/dist/cjs-legacy/queue.cjs +634 -2340
  22. package/dist/cjs-legacy/stack.cjs +124 -530
  23. package/dist/cjs-legacy/trie.cjs +145 -592
  24. package/dist/esm/binary-tree.mjs +2927 -23688
  25. package/dist/esm/graph.mjs +845 -2634
  26. package/dist/esm/hash.mjs +185 -616
  27. package/dist/esm/heap.mjs +266 -818
  28. package/dist/esm/index.mjs +5116 -31358
  29. package/dist/esm/linked-list.mjs +644 -2615
  30. package/dist/esm/matrix.mjs +220 -535
  31. package/dist/esm/priority-queue.mjs +266 -818
  32. package/dist/esm/queue.mjs +637 -2343
  33. package/dist/esm/stack.mjs +124 -530
  34. package/dist/esm/trie.mjs +145 -592
  35. package/dist/esm-legacy/binary-tree.mjs +4352 -25113
  36. package/dist/esm-legacy/graph.mjs +847 -2636
  37. package/dist/esm-legacy/hash.mjs +181 -612
  38. package/dist/esm-legacy/heap.mjs +266 -818
  39. package/dist/esm-legacy/index.mjs +6657 -32899
  40. package/dist/esm-legacy/linked-list.mjs +640 -2611
  41. package/dist/esm-legacy/matrix.mjs +220 -535
  42. package/dist/esm-legacy/priority-queue.mjs +266 -818
  43. package/dist/esm-legacy/queue.mjs +634 -2340
  44. package/dist/esm-legacy/stack.mjs +124 -530
  45. package/dist/esm-legacy/trie.mjs +145 -592
  46. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +29 -500
  47. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +38 -563
  48. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +230 -1212
  49. package/dist/types/data-structures/binary-tree/bst.d.ts +124 -1063
  50. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +99 -854
  51. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +62 -314
  52. package/dist/types/data-structures/binary-tree/tree-map.d.ts +366 -5057
  53. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +277 -4885
  54. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +253 -3929
  55. package/dist/types/data-structures/binary-tree/tree-set.d.ts +261 -4782
  56. package/dist/types/data-structures/graph/abstract-graph.d.ts +44 -44
  57. package/dist/types/data-structures/graph/directed-graph.d.ts +130 -527
  58. package/dist/types/data-structures/graph/undirected-graph.d.ts +125 -482
  59. package/dist/types/data-structures/hash/hash-map.d.ts +132 -562
  60. package/dist/types/data-structures/heap/heap.d.ts +194 -746
  61. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +120 -809
  62. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +121 -733
  63. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +193 -863
  64. package/dist/types/data-structures/matrix/matrix.d.ts +159 -474
  65. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -6
  66. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +6 -11
  67. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
  68. package/dist/types/data-structures/queue/deque.d.ts +196 -804
  69. package/dist/types/data-structures/queue/queue.d.ts +99 -585
  70. package/dist/types/data-structures/stack/stack.d.ts +75 -481
  71. package/dist/types/data-structures/trie/trie.d.ts +98 -584
  72. package/dist/umd/data-structure-typed.js +6580 -32822
  73. package/dist/umd/data-structure-typed.min.js +3 -3
  74. package/docs-site-docusaurus/docs/api/classes/AVLTree.md +162 -215
  75. package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +9 -9
  76. package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +47 -47
  77. package/docs-site-docusaurus/docs/api/classes/BST.md +155 -208
  78. package/docs-site-docusaurus/docs/api/classes/BSTNode.md +7 -7
  79. package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +13 -29
  80. package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +104 -158
  81. package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
  82. package/docs-site-docusaurus/docs/api/classes/Deque.md +72 -104
  83. package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +60 -80
  84. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +67 -101
  85. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +6 -6
  86. package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +9 -9
  87. package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
  88. package/docs-site-docusaurus/docs/api/classes/HashMap.md +52 -48
  89. package/docs-site-docusaurus/docs/api/classes/Heap.md +40 -68
  90. package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +17 -17
  91. package/docs-site-docusaurus/docs/api/classes/LinearBase.md +38 -38
  92. package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +45 -45
  93. package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +23 -23
  94. package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +68 -96
  95. package/docs-site-docusaurus/docs/api/classes/MapGraph.md +60 -80
  96. package/docs-site-docusaurus/docs/api/classes/Matrix.md +57 -52
  97. package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +38 -66
  98. package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +41 -74
  99. package/docs-site-docusaurus/docs/api/classes/MinHeap.md +38 -66
  100. package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +46 -79
  101. package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +40 -68
  102. package/docs-site-docusaurus/docs/api/classes/Queue.md +54 -78
  103. package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +171 -225
  104. package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -22
  105. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +68 -98
  106. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +4 -4
  107. package/docs-site-docusaurus/docs/api/classes/SkipList.md +98 -75
  108. package/docs-site-docusaurus/docs/api/classes/Stack.md +33 -53
  109. package/docs-site-docusaurus/docs/api/classes/TreeMap.md +104 -129
  110. package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +57 -124
  111. package/docs-site-docusaurus/docs/api/classes/TreeSet.md +45 -116
  112. package/docs-site-docusaurus/docs/api/classes/Trie.md +37 -61
  113. package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
  114. package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +59 -77
  115. package/package.json +1 -1
  116. package/src/data-structures/binary-tree/tree-multi-set.ts +15 -11
@@ -237,9 +237,9 @@ var _HashMap = class _HashMap extends IterableEntryBase {
237
237
  */
238
238
  constructor(entryOrRawElements = [], options) {
239
239
  super();
240
+ __publicField(this, "_toEntryFn");
240
241
  __publicField(this, "_store", {});
241
242
  __publicField(this, "_objMap", /* @__PURE__ */ new Map());
242
- __publicField(this, "_toEntryFn");
243
243
  __publicField(this, "_size", 0);
244
244
  __publicField(this, "_hashFn", /* @__PURE__ */ __name((key) => String(key), "_hashFn"));
245
245
  if (options) {
@@ -290,107 +290,30 @@ var _HashMap = class _HashMap extends IterableEntryBase {
290
290
  return this._hashFn;
291
291
  }
292
292
  /**
293
- * Check whether the map is empty.
294
- * @remarks Time O(1), Space O(1)
295
- * @returns True if size is 0.
296
-
297
-
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
- * @example
337
- * // Check if empty
338
- * const map = new HashMap();
339
- * console.log(map.isEmpty()); // true;
340
- */
293
+ * Check whether the map is empty.
294
+ * @remarks Time O(1), Space O(1)
295
+ * @returns True if size is 0.
296
+ * @example
297
+ * // Check if empty
298
+ * const map = new HashMap();
299
+ * console.log(map.isEmpty()); // true;
300
+ */
341
301
  isEmpty() {
342
302
  return this._size === 0;
343
303
  }
344
304
  /**
345
- * Remove all entries and reset counters.
346
- * @remarks Time O(N), Space O(1)
347
- * @returns void
348
-
349
-
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
- * @example
389
- * // Remove all entries
390
- * const map = new HashMap<string, number>([['a', 1], ['b', 2]]);
391
- * map.clear();
392
- * console.log(map.isEmpty()); // true;
393
- */
305
+ * Remove all entries and reset counters.
306
+ * @remarks Time O(N), Space O(1)
307
+ * @returns void
308
+ * @example
309
+ * // Remove all entries
310
+ * const map = new HashMap<string, number>([
311
+ * ['a', 1],
312
+ * ['b', 2]
313
+ * ]);
314
+ * map.clear();
315
+ * console.log(map.isEmpty()); // true;
316
+ */
394
317
  clear() {
395
318
  this._store = {};
396
319
  this._objMap.clear();
@@ -405,114 +328,30 @@ var _HashMap = class _HashMap extends IterableEntryBase {
405
328
  return Array.isArray(rawElement) && rawElement.length === 2;
406
329
  }
407
330
  /**
408
- * Insert or replace a single entry.
409
- * @remarks Time O(1), Space O(1)
410
- * @param key - Key.
411
- * @param value - Value.
412
- * @returns True when the operation succeeds.
413
-
414
-
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
- * @example
498
- * // basic HashMap creation and set operation
499
- * // Create a simple HashMap with key-value pairs
500
- * const map = new HashMap<number, string>([
501
- * [1, 'one'],
502
- * [2, 'two'],
503
- * [3, 'three']
504
- * ]);
505
- *
506
- * // Verify size
507
- * console.log(map.size); // 3;
508
- *
509
- * // Set a new key-value pair
510
- * map.set(4, 'four');
511
- * console.log(map.size); // 4;
512
- *
513
- * // Verify entries
514
- * console.log([...map.entries()]); // length: 4;
515
- */
331
+ * Insert or replace a single entry.
332
+ * @remarks Time O(1), Space O(1)
333
+ * @param key - Key.
334
+ * @param value - Value.
335
+ * @returns True when the operation succeeds.
336
+ * @example
337
+ * // basic HashMap creation and set operation
338
+ * // Create a simple HashMap with key-value pairs
339
+ * const map = new HashMap<number, string>([
340
+ * [1, 'one'],
341
+ * [2, 'two'],
342
+ * [3, 'three']
343
+ * ]);
344
+ *
345
+ * // Verify size
346
+ * console.log(map.size); // 3;
347
+ *
348
+ * // Set a new key-value pair
349
+ * map.set(4, 'four');
350
+ * console.log(map.size); // 4;
351
+ *
352
+ * // Verify entries
353
+ * console.log([...map.entries()]); // length: 4;
354
+ */
516
355
  set(key, value) {
517
356
  if (this._isObjKey(key)) {
518
357
  if (!this.objMap.has(key)) this._size++;
@@ -525,56 +364,20 @@ var _HashMap = class _HashMap extends IterableEntryBase {
525
364
  return this;
526
365
  }
527
366
  /**
528
- * Insert many entries from an iterable.
529
- * @remarks Time O(N), Space O(N)
530
- * @param entryOrRawElements - Iterable of entries or raw elements to insert.
531
- * @returns Array of per-entry results.
532
-
533
-
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
- * @example
573
- * // Add multiple entries
574
- * const map = new HashMap<string, number>();
575
- * map.setMany([['a', 1], ['b', 2], ['c', 3]]);
576
- * console.log(map.size); // 3;
577
- */
367
+ * Insert many entries from an iterable.
368
+ * @remarks Time O(N), Space O(N)
369
+ * @param entryOrRawElements - Iterable of entries or raw elements to insert.
370
+ * @returns Array of per-entry results.
371
+ * @example
372
+ * // Add multiple entries
373
+ * const map = new HashMap<string, number>();
374
+ * map.setMany([
375
+ * ['a', 1],
376
+ * ['b', 2],
377
+ * ['c', 3]
378
+ * ]);
379
+ * console.log(map.size); // 3;
380
+ */
578
381
  setMany(entryOrRawElements) {
579
382
  const results = [];
580
383
  for (const rawEle of entryOrRawElements) {
@@ -590,74 +393,32 @@ var _HashMap = class _HashMap extends IterableEntryBase {
590
393
  return results;
591
394
  }
592
395
  /**
593
- * Get the value for a key.
594
- * @remarks Time O(1), Space O(1)
595
- * @param key - Key to look up.
596
- * @returns Value or undefined.
597
-
598
-
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
- * @example
640
- * // HashMap get and has operations
641
- * const map = new HashMap<string, number>([
642
- * ['apple', 1],
643
- * ['banana', 2],
644
- * ['cherry', 3]
645
- * ]);
646
- *
647
- * // Check if key exists
648
- * console.log(map.has('apple')); // true;
649
- * console.log(map.has('date')); // false;
650
- *
651
- * // Get value by key
652
- * console.log(map.get('banana')); // 2;
653
- * console.log(map.get('grape')); // undefined;
654
- *
655
- * // Get all keys and values
656
- * const keys = [...map.keys()];
657
- * const values = [...map.values()];
658
- * console.log(keys); // contains 'apple';
659
- * console.log(values); // contains 3;
660
- */
396
+ * Get the value for a key.
397
+ * @remarks Time O(1), Space O(1)
398
+ * @param key - Key to look up.
399
+ * @returns Value or undefined.
400
+ * @example
401
+ * // HashMap get and has operations
402
+ * const map = new HashMap<string, number>([
403
+ * ['apple', 1],
404
+ * ['banana', 2],
405
+ * ['cherry', 3]
406
+ * ]);
407
+ *
408
+ * // Check if key exists
409
+ * console.log(map.has('apple')); // true;
410
+ * console.log(map.has('date')); // false;
411
+ *
412
+ * // Get value by key
413
+ * console.log(map.get('banana')); // 2;
414
+ * console.log(map.get('grape')); // undefined;
415
+ *
416
+ * // Get all keys and values
417
+ * const keys = [...map.keys()];
418
+ * const values = [...map.values()];
419
+ * console.log(keys); // contains 'apple';
420
+ * console.log(values); // contains 3;
421
+ */
661
422
  get(key) {
662
423
  var _a;
663
424
  if (this._isObjKey(key)) return this.objMap.get(key);
@@ -665,119 +426,42 @@ var _HashMap = class _HashMap extends IterableEntryBase {
665
426
  return (_a = this._store[strKey]) == null ? void 0 : _a.value;
666
427
  }
667
428
  /**
668
- * Check if a key exists.
669
- * @remarks Time O(1), Space O(1)
670
- * @param key - Key to test.
671
- * @returns True if present.
672
-
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
- * @example
715
- * // Check key existence
716
- * const map = new HashMap<string, number>([['a', 1], ['b', 2]]);
717
- *
718
- * console.log(map.has('a')); // true;
719
- * console.log(map.has('z')); // false;
720
- */
429
+ * Check if a key exists.
430
+ * @remarks Time O(1), Space O(1)
431
+ * @param key - Key to test.
432
+ * @returns True if present.
433
+ * @example
434
+ * // Check key existence
435
+ * const map = new HashMap<string, number>([
436
+ * ['a', 1],
437
+ * ['b', 2]
438
+ * ]);
439
+ *
440
+ * console.log(map.has('a')); // true;
441
+ * console.log(map.has('z')); // false;
442
+ */
721
443
  has(key) {
722
444
  if (this._isObjKey(key)) return this.objMap.has(key);
723
445
  const strKey = this._getNoObjKey(key);
724
446
  return strKey in this.store;
725
447
  }
726
448
  /**
727
- * Delete an entry by key.
728
- * @remarks Time O(1), Space O(1)
729
- * @param key - Key to delete.
730
- * @returns True if the key was found and removed.
731
-
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
- * @example
774
- * // Remove entries by key
775
- * const map = new HashMap<string, number>([['x', 10], ['y', 20], ['z', 30]]);
776
- *
777
- * console.log(map.delete('y')); // true;
778
- * console.log(map.has('y')); // false;
779
- * console.log(map.size); // 2;
780
- */
449
+ * Delete an entry by key.
450
+ * @remarks Time O(1), Space O(1)
451
+ * @param key - Key to delete.
452
+ * @returns True if the key was found and removed.
453
+ * @example
454
+ * // Remove entries by key
455
+ * const map = new HashMap<string, number>([
456
+ * ['x', 10],
457
+ * ['y', 20],
458
+ * ['z', 30]
459
+ * ]);
460
+ *
461
+ * console.log(map.delete('y')); // true;
462
+ * console.log(map.has('y')); // false;
463
+ * console.log(map.size); // 2;
464
+ */
781
465
  delete(key) {
782
466
  if (this._isObjKey(key)) {
783
467
  if (this.objMap.has(key)) this._size--;
@@ -804,117 +488,38 @@ var _HashMap = class _HashMap extends IterableEntryBase {
804
488
  return this;
805
489
  }
806
490
  /**
807
- * Deep clone this map, preserving hashing behavior.
808
- * @remarks Time O(N), Space O(N)
809
- * @returns A new map with the same content.
810
-
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
- * @example
851
- * // Create independent copy
852
- * const map = new HashMap<string, number>([['a', 1]]);
853
- * const copy = map.clone();
854
- * copy.set('a', 99);
855
- * console.log(map.get('a')); // 1;
856
- */
491
+ * Deep clone this map, preserving hashing behavior.
492
+ * @remarks Time O(N), Space O(N)
493
+ * @returns A new map with the same content.
494
+ * @example
495
+ * // Create independent copy
496
+ * const map = new HashMap<string, number>([['a', 1]]);
497
+ * const copy = map.clone();
498
+ * copy.set('a', 99);
499
+ * console.log(map.get('a')); // 1;
500
+ */
857
501
  clone() {
858
502
  const opts = { hashFn: this._hashFn, toEntryFn: this._toEntryFn };
859
503
  return this._createLike(this, opts);
860
504
  }
861
505
  /**
862
- * Map values to a new map with the same keys.
863
- * @remarks Time O(N), Space O(N)
864
- * @template VM
865
- * @param callbackfn - Mapping function (key, value, index, map) → newValue.
866
- * @param [thisArg] - Value for `this` inside the callback.
867
- * @returns A new map with transformed values.
868
-
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
- * @example
911
- * // Transform all values
912
- * const prices = new HashMap<string, number>([['apple', 1], ['banana', 2]]);
913
- *
914
- * const doubled = prices.map(v => (v ?? 0) * 2);
915
- * console.log(doubled.get('apple')); // 2;
916
- * console.log(doubled.get('banana')); // 4;
917
- */
506
+ * Map values to a new map with the same keys.
507
+ * @remarks Time O(N), Space O(N)
508
+ * @template VM
509
+ * @param callbackfn - Mapping function (key, value, index, map) → newValue.
510
+ * @param [thisArg] - Value for `this` inside the callback.
511
+ * @returns A new map with transformed values.
512
+ * @example
513
+ * // Transform all values
514
+ * const prices = new HashMap<string, number>([
515
+ * ['apple', 1],
516
+ * ['banana', 2]
517
+ * ]);
518
+ *
519
+ * const doubled = prices.map(v => (v ?? 0) * 2);
520
+ * console.log(doubled.get('apple')); // 2;
521
+ * console.log(doubled.get('banana')); // 4;
522
+ */
918
523
  map(callbackfn, thisArg) {
919
524
  const out = this._createLike();
920
525
  let index = 0;
@@ -922,79 +527,37 @@ var _HashMap = class _HashMap extends IterableEntryBase {
922
527
  return out;
923
528
  }
924
529
  /**
925
- * Filter entries into a new map.
926
- * @remarks Time O(N), Space O(N)
927
- * @param predicate - Predicate (key, value, index, map) → boolean.
928
- * @param [thisArg] - Value for `this` inside the predicate.
929
- * @returns A new map containing entries that satisfied the predicate.
930
-
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
- * @example
973
- * // HashMap iteration and filter operations
974
- * const map = new HashMap<number, string>([
975
- * [1, 'Alice'],
976
- * [2, 'Bob'],
977
- * [3, 'Charlie'],
978
- * [4, 'Diana'],
979
- * [5, 'Eve']
980
- * ]);
981
- *
982
- * // Iterate through entries
983
- * const entries: [number, string][] = [];
984
- * for (const [key, value] of map) {
985
- * entries.push([key, value]);
986
- * }
987
- * console.log(entries); // length: 5;
988
- *
989
- * // Filter operation (for iteration with collection methods)
990
- * const filtered = [...map].filter(([key]) => key > 2);
991
- * console.log(filtered.length); // 3;
992
- *
993
- * // Map operation
994
- * const values = [...map.values()].map(v => v.length);
995
- * console.log(values); // contains 3; // 'Bob', 'Eve'
996
- * console.log(values); // contains 7;
997
- */
530
+ * Filter entries into a new map.
531
+ * @remarks Time O(N), Space O(N)
532
+ * @param predicate - Predicate (key, value, index, map) → boolean.
533
+ * @param [thisArg] - Value for `this` inside the predicate.
534
+ * @returns A new map containing entries that satisfied the predicate.
535
+ * @example
536
+ * // HashMap iteration and filter operations
537
+ * const map = new HashMap<number, string>([
538
+ * [1, 'Alice'],
539
+ * [2, 'Bob'],
540
+ * [3, 'Charlie'],
541
+ * [4, 'Diana'],
542
+ * [5, 'Eve']
543
+ * ]);
544
+ *
545
+ * // Iterate through entries
546
+ * const entries: [number, string][] = [];
547
+ * for (const [key, value] of map) {
548
+ * entries.push([key, value]);
549
+ * }
550
+ * console.log(entries); // length: 5;
551
+ *
552
+ * // Filter operation (for iteration with collection methods)
553
+ * const filtered = [...map].filter(([key]) => key > 2);
554
+ * console.log(filtered.length); // 3;
555
+ *
556
+ * // Map operation
557
+ * const values = [...map.values()].map(v => v.length);
558
+ * console.log(values); // contains 3; // 'Bob', 'Eve'
559
+ * console.log(values); // contains 7;
560
+ */
998
561
  filter(predicate, thisArg) {
999
562
  const out = this._createLike();
1000
563
  let index = 0;
@@ -1065,13 +628,19 @@ var _LinkedHashMap = class _LinkedHashMap extends IterableEntryBase {
1065
628
  __publicField(this, "_objMap", /* @__PURE__ */ new WeakMap());
1066
629
  __publicField(this, "_head");
1067
630
  __publicField(this, "_tail");
631
+ __publicField(this, "_size", 0);
1068
632
  __publicField(this, "_toEntryFn", /* @__PURE__ */ __name((rawElement) => {
1069
633
  if (this.isEntry(rawElement)) {
1070
634
  return rawElement;
1071
635
  }
1072
- raise(TypeError, ERR.invalidArgument("If elements do not adhere to [key, value], provide options.toEntryFn to transform raw records.", "HashMap"));
636
+ raise(
637
+ TypeError,
638
+ ERR.invalidArgument(
639
+ "If elements do not adhere to [key, value], provide options.toEntryFn to transform raw records.",
640
+ "HashMap"
641
+ )
642
+ );
1073
643
  }, "_toEntryFn"));
1074
- __publicField(this, "_size", 0);
1075
644
  this._sentinel = {};
1076
645
  this._sentinel.prev = this._sentinel.next = this._head = this._tail = this._sentinel;
1077
646
  if (options) {