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
@@ -146,7 +146,7 @@ Optional configuration.
146
146
  get comparator(): Comparator<E>;
147
147
  ```
148
148
 
149
- Defined in: [data-structures/heap/heap.ts:1272](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1272)
149
+ Defined in: [data-structures/heap/heap.ts:211](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L211)
150
150
 
151
151
  Get the comparator used to order elements.
152
152
 
@@ -174,7 +174,7 @@ Comparator function.
174
174
  get elements(): E[];
175
175
  ```
176
176
 
177
- Defined in: [data-structures/heap/heap.ts:180](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L180)
177
+ Defined in: [data-structures/heap/heap.ts:175](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L175)
178
178
 
179
179
  Get the backing array of the heap.
180
180
 
@@ -202,7 +202,7 @@ Internal elements array.
202
202
  get leaf(): E | undefined;
203
203
  ```
204
204
 
205
- Defined in: [data-structures/heap/heap.ts:248](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L248)
205
+ Defined in: [data-structures/heap/heap.ts:202](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L202)
206
206
 
207
207
  Get the last leaf element.
208
208
 
@@ -230,7 +230,7 @@ Last element or undefined.
230
230
  get size(): number;
231
231
  ```
232
232
 
233
- Defined in: [data-structures/heap/heap.ts:238](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L238)
233
+ Defined in: [data-structures/heap/heap.ts:193](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L193)
234
234
 
235
235
  Get the number of elements.
236
236
 
@@ -257,8 +257,6 @@ Time O(1), Space O(1)
257
257
 
258
258
  Heap size.
259
259
 
260
- *
261
-
262
260
  #### Inherited from
263
261
 
264
262
  [`Heap`](Heap.md).[`size`](Heap.md#size)
@@ -333,7 +331,7 @@ Producing the iterator is O(1); consuming the entire iterator is Time O(n) with
333
331
  add(element): boolean;
334
332
  ```
335
333
 
336
- Defined in: [data-structures/heap/heap.ts:346](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L346)
334
+ Defined in: [data-structures/heap/heap.ts:267](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L267)
337
335
 
338
336
  Insert an element.
339
337
 
@@ -351,8 +349,6 @@ Element to insert.
351
349
 
352
350
  True.
353
351
 
354
- *
355
-
356
352
  #### Remarks
357
353
 
358
354
  Time O(log N) amortized, Space O(1)
@@ -388,7 +384,7 @@ Time O(log N) amortized, Space O(1)
388
384
  addMany(elements): boolean[];
389
385
  ```
390
386
 
391
- Defined in: [data-structures/heap/heap.ts:400](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L400)
387
+ Defined in: [data-structures/heap/heap.ts:284](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L284)
392
388
 
393
389
  Insert many elements from an iterable.
394
390
 
@@ -406,8 +402,6 @@ Iterable of elements or raw values.
406
402
 
407
403
  Array of per-element success flags.
408
404
 
409
- *
410
-
411
405
  #### Remarks
412
406
 
413
407
  Time O(N log N), Space O(1)
@@ -434,7 +428,7 @@ Time O(N log N), Space O(1)
434
428
  clear(): void;
435
429
  ```
436
430
 
437
- Defined in: [data-structures/heap/heap.ts:740](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L740)
431
+ Defined in: [data-structures/heap/heap.ts:469](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L469)
438
432
 
439
433
  Remove all elements.
440
434
 
@@ -444,8 +438,6 @@ Remove all elements.
444
438
 
445
439
  void
446
440
 
447
- *
448
-
449
441
  #### Remarks
450
442
 
451
443
  Time O(1), Space O(1)
@@ -471,7 +463,7 @@ Time O(1), Space O(1)
471
463
  clone(): this;
472
464
  ```
473
465
 
474
- Defined in: [data-structures/heap/heap.ts:1100](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1100)
466
+ Defined in: [data-structures/heap/heap.ts:648](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L648)
475
467
 
476
468
  Deep clone this heap.
477
469
 
@@ -481,8 +473,6 @@ Deep clone this heap.
481
473
 
482
474
  A new heap with the same elements.
483
475
 
484
- *
485
-
486
476
  #### Remarks
487
477
 
488
478
  Time O(N), Space O(N)
@@ -510,7 +500,7 @@ Time O(N), Space O(N)
510
500
  delete(element): boolean;
511
501
  ```
512
502
 
513
- Defined in: [data-structures/heap/heap.ts:841](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L841)
503
+ Defined in: [data-structures/heap/heap.ts:500](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L500)
514
504
 
515
505
  Delete one occurrence of an element.
516
506
 
@@ -528,8 +518,6 @@ Element to delete.
528
518
 
529
519
  True if an element was removed.
530
520
 
531
- *
532
-
533
521
  #### Remarks
534
522
 
535
523
  Time O(N), Space O(1)
@@ -555,7 +543,7 @@ Time O(N), Space O(1)
555
543
  deleteBy(predicate): boolean;
556
544
  ```
557
545
 
558
- Defined in: [data-structures/heap/heap.ts:865](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L865)
546
+ Defined in: [data-structures/heap/heap.ts:524](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L524)
559
547
 
560
548
  #### Parameters
561
549
 
@@ -583,7 +571,7 @@ Use `deleteWhere` instead. Will be removed in a future major version.
583
571
  deleteWhere(predicate): boolean;
584
572
  ```
585
573
 
586
- Defined in: [data-structures/heap/heap.ts:875](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L875)
574
+ Defined in: [data-structures/heap/heap.ts:534](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L534)
587
575
 
588
576
  Delete the first element that matches a predicate.
589
577
 
@@ -617,7 +605,7 @@ Time O(N), Space O(1)
617
605
  dfs(order?): E[];
618
606
  ```
619
607
 
620
- Defined in: [data-structures/heap/heap.ts:950](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L950)
608
+ Defined in: [data-structures/heap/heap.ts:577](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L577)
621
609
 
622
610
  Traverse the binary heap as a complete binary tree and collect elements.
623
611
 
@@ -635,8 +623,6 @@ Traversal order: 'PRE' | 'IN' | 'POST'.
635
623
 
636
624
  Array of visited elements.
637
625
 
638
- *
639
-
640
626
  #### Remarks
641
627
 
642
628
  Time O(N), Space O(H)
@@ -656,6 +642,30 @@ Time O(N), Space O(H)
656
642
 
657
643
  ***
658
644
 
645
+ ### entries()
646
+
647
+ ```ts
648
+ entries(): IterableIterator<[number, E]>;
649
+ ```
650
+
651
+ Defined in: [data-structures/base/iterable-element-base.ts:207](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L207)
652
+
653
+ Return an iterator of `[index, value]` pairs (Array-compatible).
654
+
655
+ #### Returns
656
+
657
+ `IterableIterator`\<\[`number`, `E`\]\>
658
+
659
+ #### Remarks
660
+
661
+ Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
662
+
663
+ #### Inherited from
664
+
665
+ [`Heap`](Heap.md).[`entries`](Heap.md#entries)
666
+
667
+ ***
668
+
659
669
  ### every()
660
670
 
661
671
  ```ts
@@ -702,7 +712,7 @@ Time O(n) in the worst case; may exit early when the first failure is found. Spa
702
712
  filter(callback, thisArg?): this;
703
713
  ```
704
714
 
705
- Defined in: [data-structures/heap/heap.ts:1156](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1156)
715
+ Defined in: [data-structures/heap/heap.ts:666](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L666)
706
716
 
707
717
  Filter elements into a new heap of the same class.
708
718
 
@@ -726,8 +736,6 @@ Value for `this` inside the callback.
726
736
 
727
737
  A new heap with the kept elements.
728
738
 
729
- *
730
-
731
739
  #### Remarks
732
740
 
733
741
  Time O(N log N), Space O(N)
@@ -843,7 +851,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
843
851
  fix(): boolean[];
844
852
  ```
845
853
 
846
- Defined in: [data-structures/heap/heap.ts:981](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L981)
854
+ Defined in: [data-structures/heap/heap.ts:607](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L607)
847
855
 
848
856
  Restore heap order bottom-up (heapify in-place).
849
857
 
@@ -909,7 +917,7 @@ Time O(n), Space O(1).
909
917
  has(element): boolean;
910
918
  ```
911
919
 
912
- Defined in: [data-structures/heap/heap.ts:788](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L788)
920
+ Defined in: [data-structures/heap/heap.ts:484](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L484)
913
921
 
914
922
  Check if an equal element exists in the heap.
915
923
 
@@ -927,8 +935,6 @@ Element to search for.
927
935
 
928
936
  True if found.
929
937
 
930
- *
931
-
932
938
  #### Remarks
933
939
 
934
940
  Time O(N), Space O(1)
@@ -948,13 +954,47 @@ Time O(N), Space O(1)
948
954
 
949
955
  ***
950
956
 
957
+ ### includes()
958
+
959
+ ```ts
960
+ includes(element): boolean;
961
+ ```
962
+
963
+ Defined in: [data-structures/base/iterable-element-base.ts:199](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L199)
964
+
965
+ Check whether a value exists (Array-compatible alias for `has`).
966
+
967
+ #### Parameters
968
+
969
+ ##### element
970
+
971
+ `E`
972
+
973
+ Element to search for (uses `===`).
974
+
975
+ #### Returns
976
+
977
+ `boolean`
978
+
979
+ `true` if found.
980
+
981
+ #### Remarks
982
+
983
+ Provided for familiarity when migrating from Array. Time O(n), Space O(1).
984
+
985
+ #### Inherited from
986
+
987
+ [`Heap`](Heap.md).[`includes`](Heap.md#includes)
988
+
989
+ ***
990
+
951
991
  ### isEmpty()
952
992
 
953
993
  ```ts
954
994
  isEmpty(): boolean;
955
995
  ```
956
996
 
957
- Defined in: [data-structures/heap/heap.ts:688](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L688)
997
+ Defined in: [data-structures/heap/heap.ts:455](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L455)
958
998
 
959
999
  Check whether the heap is empty.
960
1000
 
@@ -964,8 +1004,6 @@ Check whether the heap is empty.
964
1004
 
965
1005
  True if size is 0.
966
1006
 
967
- *
968
-
969
1007
  #### Remarks
970
1008
 
971
1009
  Time O(1), Space O(1)
@@ -986,6 +1024,30 @@ Time O(1), Space O(1)
986
1024
 
987
1025
  ***
988
1026
 
1027
+ ### keys()
1028
+
1029
+ ```ts
1030
+ keys(): IterableIterator<number>;
1031
+ ```
1032
+
1033
+ Defined in: [data-structures/base/iterable-element-base.ts:218](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L218)
1034
+
1035
+ Return an iterator of numeric indices (Array-compatible).
1036
+
1037
+ #### Returns
1038
+
1039
+ `IterableIterator`\<`number`\>
1040
+
1041
+ #### Remarks
1042
+
1043
+ Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
1044
+
1045
+ #### Inherited from
1046
+
1047
+ [`Heap`](Heap.md).[`keys`](Heap.md#keys)
1048
+
1049
+ ***
1050
+
989
1051
  ### map()
990
1052
 
991
1053
  ```ts
@@ -995,7 +1057,7 @@ map<EM, RM>(
995
1057
  thisArg?): Heap<EM, RM>;
996
1058
  ```
997
1059
 
998
- Defined in: [data-structures/heap/heap.ts:1221](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1221)
1060
+ Defined in: [data-structures/heap/heap.ts:694](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L694)
999
1061
 
1000
1062
  Map elements into a new heap of possibly different element type.
1001
1063
 
@@ -1035,8 +1097,6 @@ Value for `this` inside the callback.
1035
1097
 
1036
1098
  A new heap with mapped elements.
1037
1099
 
1038
- *
1039
-
1040
1100
  #### Remarks
1041
1101
 
1042
1102
  Time O(N log N), Space O(N)
@@ -1062,7 +1122,7 @@ Time O(N log N), Space O(N)
1062
1122
  mapSame(callback, thisArg?): this;
1063
1123
  ```
1064
1124
 
1065
- Defined in: [data-structures/heap/heap.ts:1245](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1245)
1125
+ Defined in: [data-structures/heap/heap.ts:717](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L717)
1066
1126
 
1067
1127
  Map elements into a new heap of the same element type.
1068
1128
 
@@ -1102,7 +1162,7 @@ Time O(N log N), Space O(N)
1102
1162
  peek(): E | undefined;
1103
1163
  ```
1104
1164
 
1105
- Defined in: [data-structures/heap/heap.ts:635](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L635)
1165
+ Defined in: [data-structures/heap/heap.ts:440](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L440)
1106
1166
 
1107
1167
  Get the current top element without removing it.
1108
1168
 
@@ -1112,8 +1172,6 @@ Get the current top element without removing it.
1112
1172
 
1113
1173
  Top element or undefined.
1114
1174
 
1115
- *
1116
-
1117
1175
  #### Remarks
1118
1176
 
1119
1177
  Time O(1), Space O(1)
@@ -1193,7 +1251,7 @@ Time O(1), Space O(1)
1193
1251
  poll(): E | undefined;
1194
1252
  ```
1195
1253
 
1196
- Defined in: [data-structures/heap/heap.ts:511](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L511)
1254
+ Defined in: [data-structures/heap/heap.ts:356](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L356)
1197
1255
 
1198
1256
  #### Returns
1199
1257
 
@@ -1202,7 +1260,6 @@ Defined in: [data-structures/heap/heap.ts:511](https://github.com/zrwusa/data-st
1202
1260
  #### Deprecated
1203
1261
 
1204
1262
  Use `pop` instead. Will be removed in a future major version.
1205
- *
1206
1263
 
1207
1264
  #### Example
1208
1265
 
@@ -1245,7 +1302,7 @@ Use `pop` instead. Will be removed in a future major version.
1245
1302
  pop(): E | undefined;
1246
1303
  ```
1247
1304
 
1248
- Defined in: [data-structures/heap/heap.ts:520](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L520)
1305
+ Defined in: [data-structures/heap/heap.ts:365](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L365)
1249
1306
 
1250
1307
  Remove and return the top element (min or max depending on comparator).
1251
1308
 
@@ -1271,7 +1328,7 @@ Time O(log N) amortized, Space O(1)
1271
1328
  print(): void;
1272
1329
  ```
1273
1330
 
1274
- Defined in: [data-structures/base/iterable-element-base.ts:269](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L269)
1331
+ Defined in: [data-structures/base/iterable-element-base.ts:298](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L298)
1275
1332
 
1276
1333
  Prints `toVisual()` to the console. Intended for quick debugging.
1277
1334
 
@@ -1329,7 +1386,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
1329
1386
  reduce(callbackfn): E;
1330
1387
  ```
1331
1388
 
1332
- Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L194)
1389
+ Defined in: [data-structures/base/iterable-element-base.ts:225](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L225)
1333
1390
 
1334
1391
  ##### Parameters
1335
1392
 
@@ -1351,7 +1408,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
1351
1408
  reduce(callbackfn, initialValue): E;
1352
1409
  ```
1353
1410
 
1354
- Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L195)
1411
+ Defined in: [data-structures/base/iterable-element-base.ts:226](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L226)
1355
1412
 
1356
1413
  ##### Parameters
1357
1414
 
@@ -1377,7 +1434,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
1377
1434
  reduce<U>(callbackfn, initialValue): U;
1378
1435
  ```
1379
1436
 
1380
- Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L196)
1437
+ Defined in: [data-structures/base/iterable-element-base.ts:227](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L227)
1381
1438
 
1382
1439
  ##### Type Parameters
1383
1440
 
@@ -1411,7 +1468,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.c
1411
1468
  setEquality(equals): this;
1412
1469
  ```
1413
1470
 
1414
- Defined in: [data-structures/heap/heap.ts:903](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L903)
1471
+ Defined in: [data-structures/heap/heap.ts:561](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L561)
1415
1472
 
1416
1473
  Set the equality comparator used by has/delete operations.
1417
1474
 
@@ -1485,7 +1542,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
1485
1542
  sort(): E[];
1486
1543
  ```
1487
1544
 
1488
- Defined in: [data-structures/heap/heap.ts:1039](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1039)
1545
+ Defined in: [data-structures/heap/heap.ts:625](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L625)
1489
1546
 
1490
1547
  Return all elements in ascending order by repeatedly polling.
1491
1548
 
@@ -1495,8 +1552,6 @@ Return all elements in ascending order by repeatedly polling.
1495
1552
 
1496
1553
  Sorted array of elements.
1497
1554
 
1498
- *
1499
-
1500
1555
  #### Remarks
1501
1556
 
1502
1557
  Time O(N log N), Space O(N)
@@ -1522,7 +1577,7 @@ Time O(N log N), Space O(N)
1522
1577
  toArray(): E[];
1523
1578
  ```
1524
1579
 
1525
- Defined in: [data-structures/base/iterable-element-base.ts:246](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L246)
1580
+ Defined in: [data-structures/base/iterable-element-base.ts:275](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L275)
1526
1581
 
1527
1582
  Materializes the elements into a new array.
1528
1583
 
@@ -1548,7 +1603,7 @@ Time O(n), Space O(n).
1548
1603
  toVisual(): E[];
1549
1604
  ```
1550
1605
 
1551
- Defined in: [data-structures/base/iterable-element-base.ts:258](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L258)
1606
+ Defined in: [data-structures/base/iterable-element-base.ts:287](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L287)
1552
1607
 
1553
1608
  Returns a representation of the structure suitable for quick visualization.
1554
1609
  Defaults to an array of elements; subclasses may override to provide richer visuals.
@@ -1604,7 +1659,7 @@ static from<T, R, S>(
1604
1659
  options?): S;
1605
1660
  ```
1606
1661
 
1607
- Defined in: [data-structures/heap/heap.ts:263](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L263)
1662
+ Defined in: [data-structures/heap/heap.ts:225](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L225)
1608
1663
 
1609
1664
  Create a heap of the same class from an iterable.
1610
1665
 
@@ -1662,7 +1717,7 @@ Time O(N), Space O(N)
1662
1717
  static heapify<EE, RR>(elements, options): Heap<EE, RR>;
1663
1718
  ```
1664
1719
 
1665
- Defined in: [data-structures/heap/heap.ts:281](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L281)
1720
+ Defined in: [data-structures/heap/heap.ts:242](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L242)
1666
1721
 
1667
1722
  Build a Heap from an iterable in linear time given a comparator.
1668
1723
 
@@ -1745,7 +1800,7 @@ Time O(1), Space O(1).
1745
1800
  protected _createInstance(options?): this;
1746
1801
  ```
1747
1802
 
1748
- Defined in: [data-structures/heap/heap.ts:1318](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1318)
1803
+ Defined in: [data-structures/heap/heap.ts:779](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L779)
1749
1804
 
1750
1805
  (Protected) Create an empty instance of the same concrete class.
1751
1806
 
@@ -1779,7 +1834,7 @@ Time O(1), Space O(1)
1779
1834
  protected _createLike<EM, RM>(elements?, options?): Heap<EM, RM>;
1780
1835
  ```
1781
1836
 
1782
- Defined in: [data-structures/heap/heap.ts:1336](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1336)
1837
+ Defined in: [data-structures/heap/heap.ts:793](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L793)
1783
1838
 
1784
1839
  (Protected) Create a like-kind instance seeded by elements.
1785
1840
 
@@ -1829,7 +1884,7 @@ Time O(N log N), Space O(N)
1829
1884
  protected _getIterator(): IterableIterator<E>;
1830
1885
  ```
1831
1886
 
1832
- Defined in: [data-structures/heap/heap.ts:1276](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1276)
1887
+ Defined in: [data-structures/heap/heap.ts:738](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L738)
1833
1888
 
1834
1889
  Internal iterator factory used by the default iterator.
1835
1890
 
@@ -1855,7 +1910,7 @@ Implementations should yield in O(1) per element with O(1) extra space when poss
1855
1910
  protected _spawnLike<EM, RM>(options?): Heap<EM, RM>;
1856
1911
  ```
1857
1912
 
1858
- Defined in: [data-structures/heap/heap.ts:1356](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1356)
1913
+ Defined in: [data-structures/heap/heap.ts:812](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L812)
1859
1914
 
1860
1915
  (Protected) Spawn an empty like-kind heap instance.
1861
1916