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
@@ -239,9 +239,9 @@ var _HashMap = class _HashMap extends IterableEntryBase {
239
239
  */
240
240
  constructor(entryOrRawElements = [], options) {
241
241
  super();
242
+ __publicField(this, "_toEntryFn");
242
243
  __publicField(this, "_store", {});
243
244
  __publicField(this, "_objMap", /* @__PURE__ */ new Map());
244
- __publicField(this, "_toEntryFn");
245
245
  __publicField(this, "_size", 0);
246
246
  __publicField(this, "_hashFn", /* @__PURE__ */ __name((key) => String(key), "_hashFn"));
247
247
  if (options) {
@@ -292,107 +292,30 @@ var _HashMap = class _HashMap 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 _HashMap 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 _HashMap 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,74 +395,32 @@ var _HashMap = class _HashMap 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
  var _a;
665
426
  if (this._isObjKey(key)) return this.objMap.get(key);
@@ -667,119 +428,42 @@ var _HashMap = class _HashMap extends IterableEntryBase {
667
428
  return (_a = this._store[strKey]) == null ? void 0 : _a.value;
668
429
  }
669
430
  /**
670
- * Check if a key exists.
671
- * @remarks Time O(1), Space O(1)
672
- * @param key - Key to test.
673
- * @returns True if present.
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
-
716
- * @example
717
- * // Check key existence
718
- * const map = new HashMap<string, number>([['a', 1], ['b', 2]]);
719
- *
720
- * console.log(map.has('a')); // true;
721
- * console.log(map.has('z')); // false;
722
- */
431
+ * Check if a key exists.
432
+ * @remarks Time O(1), Space O(1)
433
+ * @param key - Key to test.
434
+ * @returns True if present.
435
+ * @example
436
+ * // Check key existence
437
+ * const map = new HashMap<string, number>([
438
+ * ['a', 1],
439
+ * ['b', 2]
440
+ * ]);
441
+ *
442
+ * console.log(map.has('a')); // true;
443
+ * console.log(map.has('z')); // false;
444
+ */
723
445
  has(key) {
724
446
  if (this._isObjKey(key)) return this.objMap.has(key);
725
447
  const strKey = this._getNoObjKey(key);
726
448
  return strKey in this.store;
727
449
  }
728
450
  /**
729
- * Delete an entry by key.
730
- * @remarks Time O(1), Space O(1)
731
- * @param key - Key to delete.
732
- * @returns True if the key was found and removed.
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
-
775
- * @example
776
- * // Remove entries by key
777
- * const map = new HashMap<string, number>([['x', 10], ['y', 20], ['z', 30]]);
778
- *
779
- * console.log(map.delete('y')); // true;
780
- * console.log(map.has('y')); // false;
781
- * console.log(map.size); // 2;
782
- */
451
+ * Delete an entry by key.
452
+ * @remarks Time O(1), Space O(1)
453
+ * @param key - Key to delete.
454
+ * @returns True if the key was found and removed.
455
+ * @example
456
+ * // Remove entries by key
457
+ * const map = new HashMap<string, number>([
458
+ * ['x', 10],
459
+ * ['y', 20],
460
+ * ['z', 30]
461
+ * ]);
462
+ *
463
+ * console.log(map.delete('y')); // true;
464
+ * console.log(map.has('y')); // false;
465
+ * console.log(map.size); // 2;
466
+ */
783
467
  delete(key) {
784
468
  if (this._isObjKey(key)) {
785
469
  if (this.objMap.has(key)) this._size--;
@@ -806,117 +490,38 @@ var _HashMap = class _HashMap extends IterableEntryBase {
806
490
  return this;
807
491
  }
808
492
  /**
809
- * Deep clone this map, preserving hashing behavior.
810
- * @remarks Time O(N), Space O(N)
811
- * @returns A new map with the same content.
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
-
852
- * @example
853
- * // Create independent copy
854
- * const map = new HashMap<string, number>([['a', 1]]);
855
- * const copy = map.clone();
856
- * copy.set('a', 99);
857
- * console.log(map.get('a')); // 1;
858
- */
493
+ * Deep clone this map, preserving hashing behavior.
494
+ * @remarks Time O(N), Space O(N)
495
+ * @returns A new map with the same content.
496
+ * @example
497
+ * // Create independent copy
498
+ * const map = new HashMap<string, number>([['a', 1]]);
499
+ * const copy = map.clone();
500
+ * copy.set('a', 99);
501
+ * console.log(map.get('a')); // 1;
502
+ */
859
503
  clone() {
860
504
  const opts = { hashFn: this._hashFn, toEntryFn: this._toEntryFn };
861
505
  return this._createLike(this, opts);
862
506
  }
863
507
  /**
864
- * Map values to a new map with the same keys.
865
- * @remarks Time O(N), Space O(N)
866
- * @template VM
867
- * @param callbackfn - Mapping function (key, value, index, map) → newValue.
868
- * @param [thisArg] - Value for `this` inside the callback.
869
- * @returns A new map with transformed values.
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
-
912
- * @example
913
- * // Transform all values
914
- * const prices = new HashMap<string, number>([['apple', 1], ['banana', 2]]);
915
- *
916
- * const doubled = prices.map(v => (v ?? 0) * 2);
917
- * console.log(doubled.get('apple')); // 2;
918
- * console.log(doubled.get('banana')); // 4;
919
- */
508
+ * Map values to a new map with the same keys.
509
+ * @remarks Time O(N), Space O(N)
510
+ * @template VM
511
+ * @param callbackfn - Mapping function (key, value, index, map) → newValue.
512
+ * @param [thisArg] - Value for `this` inside the callback.
513
+ * @returns A new map with transformed values.
514
+ * @example
515
+ * // Transform all values
516
+ * const prices = new HashMap<string, number>([
517
+ * ['apple', 1],
518
+ * ['banana', 2]
519
+ * ]);
520
+ *
521
+ * const doubled = prices.map(v => (v ?? 0) * 2);
522
+ * console.log(doubled.get('apple')); // 2;
523
+ * console.log(doubled.get('banana')); // 4;
524
+ */
920
525
  map(callbackfn, thisArg) {
921
526
  const out = this._createLike();
922
527
  let index = 0;
@@ -924,79 +529,37 @@ var _HashMap = class _HashMap extends IterableEntryBase {
924
529
  return out;
925
530
  }
926
531
  /**
927
- * Filter entries into a new map.
928
- * @remarks Time O(N), Space O(N)
929
- * @param predicate - Predicate (key, value, index, map) → boolean.
930
- * @param [thisArg] - Value for `this` inside the predicate.
931
- * @returns A new map containing entries that satisfied the predicate.
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
-
974
- * @example
975
- * // HashMap iteration and filter operations
976
- * const map = new HashMap<number, string>([
977
- * [1, 'Alice'],
978
- * [2, 'Bob'],
979
- * [3, 'Charlie'],
980
- * [4, 'Diana'],
981
- * [5, 'Eve']
982
- * ]);
983
- *
984
- * // Iterate through entries
985
- * const entries: [number, string][] = [];
986
- * for (const [key, value] of map) {
987
- * entries.push([key, value]);
988
- * }
989
- * console.log(entries); // length: 5;
990
- *
991
- * // Filter operation (for iteration with collection methods)
992
- * const filtered = [...map].filter(([key]) => key > 2);
993
- * console.log(filtered.length); // 3;
994
- *
995
- * // Map operation
996
- * const values = [...map.values()].map(v => v.length);
997
- * console.log(values); // contains 3; // 'Bob', 'Eve'
998
- * console.log(values); // contains 7;
999
- */
532
+ * Filter entries into a new map.
533
+ * @remarks Time O(N), Space O(N)
534
+ * @param predicate - Predicate (key, value, index, map) → boolean.
535
+ * @param [thisArg] - Value for `this` inside the predicate.
536
+ * @returns A new map containing entries that satisfied the predicate.
537
+ * @example
538
+ * // HashMap iteration and filter operations
539
+ * const map = new HashMap<number, string>([
540
+ * [1, 'Alice'],
541
+ * [2, 'Bob'],
542
+ * [3, 'Charlie'],
543
+ * [4, 'Diana'],
544
+ * [5, 'Eve']
545
+ * ]);
546
+ *
547
+ * // Iterate through entries
548
+ * const entries: [number, string][] = [];
549
+ * for (const [key, value] of map) {
550
+ * entries.push([key, value]);
551
+ * }
552
+ * console.log(entries); // length: 5;
553
+ *
554
+ * // Filter operation (for iteration with collection methods)
555
+ * const filtered = [...map].filter(([key]) => key > 2);
556
+ * console.log(filtered.length); // 3;
557
+ *
558
+ * // Map operation
559
+ * const values = [...map.values()].map(v => v.length);
560
+ * console.log(values); // contains 3; // 'Bob', 'Eve'
561
+ * console.log(values); // contains 7;
562
+ */
1000
563
  filter(predicate, thisArg) {
1001
564
  const out = this._createLike();
1002
565
  let index = 0;
@@ -1067,13 +630,19 @@ var _LinkedHashMap = class _LinkedHashMap extends IterableEntryBase {
1067
630
  __publicField(this, "_objMap", /* @__PURE__ */ new WeakMap());
1068
631
  __publicField(this, "_head");
1069
632
  __publicField(this, "_tail");
633
+ __publicField(this, "_size", 0);
1070
634
  __publicField(this, "_toEntryFn", /* @__PURE__ */ __name((rawElement) => {
1071
635
  if (this.isEntry(rawElement)) {
1072
636
  return rawElement;
1073
637
  }
1074
- raise(TypeError, ERR.invalidArgument("If elements do not adhere to [key, value], provide options.toEntryFn to transform raw records.", "HashMap"));
638
+ raise(
639
+ TypeError,
640
+ ERR.invalidArgument(
641
+ "If elements do not adhere to [key, value], provide options.toEntryFn to transform raw records.",
642
+ "HashMap"
643
+ )
644
+ );
1075
645
  }, "_toEntryFn"));
1076
- __publicField(this, "_size", 0);
1077
646
  this._sentinel = {};
1078
647
  this._sentinel.prev = this._sentinel.next = this._head = this._tail = this._sentinel;
1079
648
  if (options) {