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
@@ -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) {