data-structure-typed 2.5.3 → 2.6.1

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 (158) hide show
  1. package/.github/workflows/ci.yml +7 -2
  2. package/.github/workflows/release-package.yml +9 -2
  3. package/.husky/pre-commit +3 -0
  4. package/CHANGELOG.md +1 -1
  5. package/MIGRATION.md +48 -0
  6. package/README.md +20 -2
  7. package/README_CN.md +20 -2
  8. package/SPECIFICATION.md +24 -0
  9. package/SPECIFICATION.zh-CN.md +24 -0
  10. package/dist/cjs/binary-tree.cjs +1897 -19
  11. package/dist/cjs/graph.cjs +174 -0
  12. package/dist/cjs/hash.cjs +33 -0
  13. package/dist/cjs/heap.cjs +71 -0
  14. package/dist/cjs/index.cjs +2383 -3
  15. package/dist/cjs/linked-list.cjs +224 -2
  16. package/dist/cjs/matrix.cjs +24 -0
  17. package/dist/cjs/priority-queue.cjs +71 -0
  18. package/dist/cjs/queue.cjs +221 -1
  19. package/dist/cjs/stack.cjs +59 -0
  20. package/dist/cjs/trie.cjs +62 -0
  21. package/dist/cjs-legacy/binary-tree.cjs +1897 -19
  22. package/dist/cjs-legacy/graph.cjs +174 -0
  23. package/dist/cjs-legacy/hash.cjs +33 -0
  24. package/dist/cjs-legacy/heap.cjs +71 -0
  25. package/dist/cjs-legacy/index.cjs +2383 -3
  26. package/dist/cjs-legacy/linked-list.cjs +224 -2
  27. package/dist/cjs-legacy/matrix.cjs +24 -0
  28. package/dist/cjs-legacy/priority-queue.cjs +71 -0
  29. package/dist/cjs-legacy/queue.cjs +221 -1
  30. package/dist/cjs-legacy/stack.cjs +59 -0
  31. package/dist/cjs-legacy/trie.cjs +62 -0
  32. package/dist/esm/binary-tree.mjs +1897 -19
  33. package/dist/esm/graph.mjs +174 -0
  34. package/dist/esm/hash.mjs +33 -0
  35. package/dist/esm/heap.mjs +71 -0
  36. package/dist/esm/index.mjs +2383 -3
  37. package/dist/esm/linked-list.mjs +224 -2
  38. package/dist/esm/matrix.mjs +24 -0
  39. package/dist/esm/priority-queue.mjs +71 -0
  40. package/dist/esm/queue.mjs +221 -1
  41. package/dist/esm/stack.mjs +59 -0
  42. package/dist/esm/trie.mjs +62 -0
  43. package/dist/esm-legacy/binary-tree.mjs +1897 -19
  44. package/dist/esm-legacy/graph.mjs +174 -0
  45. package/dist/esm-legacy/hash.mjs +33 -0
  46. package/dist/esm-legacy/heap.mjs +71 -0
  47. package/dist/esm-legacy/index.mjs +2383 -3
  48. package/dist/esm-legacy/linked-list.mjs +224 -2
  49. package/dist/esm-legacy/matrix.mjs +24 -0
  50. package/dist/esm-legacy/priority-queue.mjs +71 -0
  51. package/dist/esm-legacy/queue.mjs +221 -1
  52. package/dist/esm-legacy/stack.mjs +59 -0
  53. package/dist/esm-legacy/trie.mjs +62 -0
  54. package/dist/types/data-structures/base/iterable-element-base.d.ts +17 -0
  55. package/dist/types/data-structures/base/linear-base.d.ts +6 -0
  56. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +36 -0
  57. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +42 -0
  58. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +75 -0
  59. package/dist/types/data-structures/binary-tree/bst.d.ts +72 -0
  60. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +57 -0
  61. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +18 -0
  62. package/dist/types/data-structures/binary-tree/tree-map.d.ts +375 -0
  63. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +389 -0
  64. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +330 -0
  65. package/dist/types/data-structures/binary-tree/tree-set.d.ts +438 -0
  66. package/dist/types/data-structures/graph/directed-graph.d.ts +30 -0
  67. package/dist/types/data-structures/graph/undirected-graph.d.ts +27 -0
  68. package/dist/types/data-structures/hash/hash-map.d.ts +33 -0
  69. package/dist/types/data-structures/heap/heap.d.ts +42 -0
  70. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +75 -2
  71. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +45 -0
  72. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +54 -0
  73. package/dist/types/data-structures/matrix/matrix.d.ts +24 -0
  74. package/dist/types/data-structures/queue/deque.d.ts +90 -1
  75. package/dist/types/data-structures/queue/queue.d.ts +36 -0
  76. package/dist/types/data-structures/stack/stack.d.ts +30 -0
  77. package/dist/types/data-structures/trie/trie.d.ts +36 -0
  78. package/dist/umd/data-structure-typed.js +2383 -3
  79. package/dist/umd/data-structure-typed.min.js +3 -3
  80. package/docs-site-docusaurus/docs/api/classes/AVLTree.md +108 -108
  81. package/docs-site-docusaurus/docs/api/classes/BST.md +101 -101
  82. package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +13 -13
  83. package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +66 -66
  84. package/docs-site-docusaurus/docs/api/classes/Deque.md +235 -51
  85. package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +21 -21
  86. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +231 -67
  87. package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +9 -9
  88. package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
  89. package/docs-site-docusaurus/docs/api/classes/HashMap.md +14 -14
  90. package/docs-site-docusaurus/docs/api/classes/Heap.md +117 -34
  91. package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +83 -13
  92. package/docs-site-docusaurus/docs/api/classes/LinearBase.md +124 -20
  93. package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +140 -32
  94. package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +30 -26
  95. package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +159 -51
  96. package/docs-site-docusaurus/docs/api/classes/MapGraph.md +20 -20
  97. package/docs-site-docusaurus/docs/api/classes/Matrix.md +23 -23
  98. package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +117 -34
  99. package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +117 -34
  100. package/docs-site-docusaurus/docs/api/classes/MinHeap.md +117 -34
  101. package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +117 -34
  102. package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +117 -34
  103. package/docs-site-docusaurus/docs/api/classes/Queue.md +142 -34
  104. package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +117 -117
  105. package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +8 -8
  106. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +158 -50
  107. package/docs-site-docusaurus/docs/api/classes/SkipList.md +21 -21
  108. package/docs-site-docusaurus/docs/api/classes/Stack.md +108 -26
  109. package/docs-site-docusaurus/docs/api/classes/TreeMap.md +33 -33
  110. package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +75 -39
  111. package/docs-site-docusaurus/docs/api/classes/TreeSet.md +301 -39
  112. package/docs-site-docusaurus/docs/api/classes/Trie.md +110 -28
  113. package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +20 -20
  114. package/jest.integration.config.js +1 -2
  115. package/package.json +51 -50
  116. package/src/common/error.ts +15 -32
  117. package/src/common/index.ts +0 -3
  118. package/src/data-structures/base/iterable-element-base.ts +32 -3
  119. package/src/data-structures/base/linear-base.ts +13 -36
  120. package/src/data-structures/binary-tree/avl-tree.ts +31 -493
  121. package/src/data-structures/binary-tree/binary-indexed-tree.ts +47 -530
  122. package/src/data-structures/binary-tree/binary-tree.ts +326 -1236
  123. package/src/data-structures/binary-tree/bst.ts +158 -1010
  124. package/src/data-structures/binary-tree/red-black-tree.ts +451 -1233
  125. package/src/data-structures/binary-tree/segment-tree.ts +73 -333
  126. package/src/data-structures/binary-tree/tree-map.ts +462 -4749
  127. package/src/data-structures/binary-tree/tree-multi-map.ts +310 -4530
  128. package/src/data-structures/binary-tree/tree-multi-set.ts +300 -3652
  129. package/src/data-structures/binary-tree/tree-set.ts +437 -4443
  130. package/src/data-structures/graph/abstract-graph.ts +98 -167
  131. package/src/data-structures/graph/directed-graph.ts +137 -532
  132. package/src/data-structures/graph/map-graph.ts +0 -3
  133. package/src/data-structures/graph/undirected-graph.ts +132 -484
  134. package/src/data-structures/hash/hash-map.ts +154 -549
  135. package/src/data-structures/heap/heap.ts +200 -753
  136. package/src/data-structures/linked-list/doubly-linked-list.ts +153 -809
  137. package/src/data-structures/linked-list/singly-linked-list.ts +122 -749
  138. package/src/data-structures/linked-list/skip-linked-list.ts +211 -864
  139. package/src/data-structures/matrix/matrix.ts +179 -494
  140. package/src/data-structures/matrix/navigator.ts +0 -1
  141. package/src/data-structures/priority-queue/max-priority-queue.ts +1 -6
  142. package/src/data-structures/priority-queue/min-priority-queue.ts +6 -11
  143. package/src/data-structures/priority-queue/priority-queue.ts +1 -2
  144. package/src/data-structures/queue/deque.ts +241 -807
  145. package/src/data-structures/queue/queue.ts +102 -589
  146. package/src/data-structures/stack/stack.ts +76 -475
  147. package/src/data-structures/trie/trie.ts +98 -592
  148. package/src/types/common.ts +0 -10
  149. package/src/types/data-structures/binary-tree/bst.ts +0 -7
  150. package/src/types/data-structures/binary-tree/red-black-tree.ts +0 -1
  151. package/src/types/data-structures/graph/abstract-graph.ts +0 -2
  152. package/src/types/data-structures/hash/hash-map.ts +0 -3
  153. package/src/types/data-structures/hash/index.ts +0 -1
  154. package/src/types/data-structures/matrix/navigator.ts +0 -2
  155. package/src/types/utils/utils.ts +0 -7
  156. package/src/types/utils/validate-type.ts +0 -7
  157. package/src/utils/number.ts +0 -2
  158. package/src/utils/utils.ts +0 -5
@@ -106,7 +106,7 @@ Defined in: [data-structures/priority-queue/priority-queue.ts:75](https://github
106
106
  get comparator(): Comparator<E>;
107
107
  ```
108
108
 
109
- Defined in: [data-structures/heap/heap.ts:1272](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1272)
109
+ Defined in: [data-structures/heap/heap.ts:1314](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1314)
110
110
 
111
111
  Get the comparator used to order elements.
112
112
 
@@ -162,7 +162,7 @@ Internal elements array.
162
162
  get leaf(): E | undefined;
163
163
  ```
164
164
 
165
- Defined in: [data-structures/heap/heap.ts:248](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L248)
165
+ Defined in: [data-structures/heap/heap.ts:251](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L251)
166
166
 
167
167
  Get the last leaf element.
168
168
 
@@ -190,7 +190,7 @@ Last element or undefined.
190
190
  get size(): number;
191
191
  ```
192
192
 
193
- Defined in: [data-structures/heap/heap.ts:238](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L238)
193
+ Defined in: [data-structures/heap/heap.ts:241](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L241)
194
194
 
195
195
  Get the number of elements.
196
196
 
@@ -293,7 +293,7 @@ Producing the iterator is O(1); consuming the entire iterator is Time O(n) with
293
293
  add(element): boolean;
294
294
  ```
295
295
 
296
- Defined in: [data-structures/heap/heap.ts:346](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L346)
296
+ Defined in: [data-structures/heap/heap.ts:352](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L352)
297
297
 
298
298
  Insert an element.
299
299
 
@@ -348,7 +348,7 @@ Time O(log N) amortized, Space O(1)
348
348
  addMany(elements): boolean[];
349
349
  ```
350
350
 
351
- Defined in: [data-structures/heap/heap.ts:400](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L400)
351
+ Defined in: [data-structures/heap/heap.ts:409](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L409)
352
352
 
353
353
  Insert many elements from an iterable.
354
354
 
@@ -394,7 +394,7 @@ Time O(N log N), Space O(1)
394
394
  clear(): void;
395
395
  ```
396
396
 
397
- Defined in: [data-structures/heap/heap.ts:740](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L740)
397
+ Defined in: [data-structures/heap/heap.ts:761](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L761)
398
398
 
399
399
  Remove all elements.
400
400
 
@@ -431,7 +431,7 @@ Time O(1), Space O(1)
431
431
  clone(): this;
432
432
  ```
433
433
 
434
- Defined in: [data-structures/heap/heap.ts:1100](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1100)
434
+ Defined in: [data-structures/heap/heap.ts:1136](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1136)
435
435
 
436
436
  Deep clone this heap.
437
437
 
@@ -470,7 +470,7 @@ Time O(N), Space O(N)
470
470
  delete(element): boolean;
471
471
  ```
472
472
 
473
- Defined in: [data-structures/heap/heap.ts:841](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L841)
473
+ Defined in: [data-structures/heap/heap.ts:868](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L868)
474
474
 
475
475
  Delete one occurrence of an element.
476
476
 
@@ -515,7 +515,7 @@ Time O(N), Space O(1)
515
515
  deleteBy(predicate): boolean;
516
516
  ```
517
517
 
518
- Defined in: [data-structures/heap/heap.ts:865](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L865)
518
+ Defined in: [data-structures/heap/heap.ts:892](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L892)
519
519
 
520
520
  #### Parameters
521
521
 
@@ -543,7 +543,7 @@ Use `deleteWhere` instead. Will be removed in a future major version.
543
543
  deleteWhere(predicate): boolean;
544
544
  ```
545
545
 
546
- Defined in: [data-structures/heap/heap.ts:875](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L875)
546
+ Defined in: [data-structures/heap/heap.ts:902](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L902)
547
547
 
548
548
  Delete the first element that matches a predicate.
549
549
 
@@ -577,7 +577,7 @@ Time O(N), Space O(1)
577
577
  dfs(order?): E[];
578
578
  ```
579
579
 
580
- Defined in: [data-structures/heap/heap.ts:950](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L950)
580
+ Defined in: [data-structures/heap/heap.ts:980](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L980)
581
581
 
582
582
  Traverse the binary heap as a complete binary tree and collect elements.
583
583
 
@@ -616,6 +616,30 @@ Time O(N), Space O(H)
616
616
 
617
617
  ***
618
618
 
619
+ ### entries()
620
+
621
+ ```ts
622
+ entries(): IterableIterator<[number, E]>;
623
+ ```
624
+
625
+ Defined in: [data-structures/base/iterable-element-base.ts:208](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L208)
626
+
627
+ Return an iterator of `[index, value]` pairs (Array-compatible).
628
+
629
+ #### Returns
630
+
631
+ `IterableIterator`\<\[`number`, `E`\]\>
632
+
633
+ #### Remarks
634
+
635
+ Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
636
+
637
+ #### Inherited from
638
+
639
+ [`Heap`](Heap.md).[`entries`](Heap.md#entries)
640
+
641
+ ***
642
+
619
643
  ### every()
620
644
 
621
645
  ```ts
@@ -662,7 +686,7 @@ Time O(n) in the worst case; may exit early when the first failure is found. Spa
662
686
  filter(callback, thisArg?): this;
663
687
  ```
664
688
 
665
- Defined in: [data-structures/heap/heap.ts:1156](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1156)
689
+ Defined in: [data-structures/heap/heap.ts:1195](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1195)
666
690
 
667
691
  Filter elements into a new heap of the same class.
668
692
 
@@ -803,7 +827,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
803
827
  fix(): boolean[];
804
828
  ```
805
829
 
806
- Defined in: [data-structures/heap/heap.ts:981](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L981)
830
+ Defined in: [data-structures/heap/heap.ts:1011](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1011)
807
831
 
808
832
  Restore heap order bottom-up (heapify in-place).
809
833
 
@@ -869,7 +893,7 @@ Time O(n), Space O(1).
869
893
  has(element): boolean;
870
894
  ```
871
895
 
872
- Defined in: [data-structures/heap/heap.ts:788](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L788)
896
+ Defined in: [data-structures/heap/heap.ts:812](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L812)
873
897
 
874
898
  Check if an equal element exists in the heap.
875
899
 
@@ -908,13 +932,47 @@ Time O(N), Space O(1)
908
932
 
909
933
  ***
910
934
 
935
+ ### includes()
936
+
937
+ ```ts
938
+ includes(element): boolean;
939
+ ```
940
+
941
+ Defined in: [data-structures/base/iterable-element-base.ts:200](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L200)
942
+
943
+ Check whether a value exists (Array-compatible alias for `has`).
944
+
945
+ #### Parameters
946
+
947
+ ##### element
948
+
949
+ `E`
950
+
951
+ Element to search for (uses `===`).
952
+
953
+ #### Returns
954
+
955
+ `boolean`
956
+
957
+ `true` if found.
958
+
959
+ #### Remarks
960
+
961
+ Provided for familiarity when migrating from Array. Time O(n), Space O(1).
962
+
963
+ #### Inherited from
964
+
965
+ [`Heap`](Heap.md).[`includes`](Heap.md#includes)
966
+
967
+ ***
968
+
911
969
  ### isEmpty()
912
970
 
913
971
  ```ts
914
972
  isEmpty(): boolean;
915
973
  ```
916
974
 
917
- Defined in: [data-structures/heap/heap.ts:688](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L688)
975
+ Defined in: [data-structures/heap/heap.ts:706](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L706)
918
976
 
919
977
  Check whether the heap is empty.
920
978
 
@@ -946,6 +1004,30 @@ Time O(1), Space O(1)
946
1004
 
947
1005
  ***
948
1006
 
1007
+ ### keys()
1008
+
1009
+ ```ts
1010
+ keys(): IterableIterator<number>;
1011
+ ```
1012
+
1013
+ Defined in: [data-structures/base/iterable-element-base.ts:219](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L219)
1014
+
1015
+ Return an iterator of numeric indices (Array-compatible).
1016
+
1017
+ #### Returns
1018
+
1019
+ `IterableIterator`\<`number`\>
1020
+
1021
+ #### Remarks
1022
+
1023
+ Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
1024
+
1025
+ #### Inherited from
1026
+
1027
+ [`Heap`](Heap.md).[`keys`](Heap.md#keys)
1028
+
1029
+ ***
1030
+
949
1031
  ### map()
950
1032
 
951
1033
  ```ts
@@ -955,7 +1037,7 @@ map<EM, RM>(
955
1037
  thisArg?): Heap<EM, RM>;
956
1038
  ```
957
1039
 
958
- Defined in: [data-structures/heap/heap.ts:1221](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1221)
1040
+ Defined in: [data-structures/heap/heap.ts:1263](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1263)
959
1041
 
960
1042
  Map elements into a new heap of possibly different element type.
961
1043
 
@@ -1022,7 +1104,7 @@ Time O(N log N), Space O(N)
1022
1104
  mapSame(callback, thisArg?): this;
1023
1105
  ```
1024
1106
 
1025
- Defined in: [data-structures/heap/heap.ts:1245](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1245)
1107
+ Defined in: [data-structures/heap/heap.ts:1287](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1287)
1026
1108
 
1027
1109
  Map elements into a new heap of the same element type.
1028
1110
 
@@ -1062,7 +1144,7 @@ Time O(N log N), Space O(N)
1062
1144
  peek(): E | undefined;
1063
1145
  ```
1064
1146
 
1065
- Defined in: [data-structures/heap/heap.ts:635](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L635)
1147
+ Defined in: [data-structures/heap/heap.ts:650](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L650)
1066
1148
 
1067
1149
  Get the current top element without removing it.
1068
1150
 
@@ -1153,7 +1235,7 @@ Time O(1), Space O(1)
1153
1235
  poll(): E | undefined;
1154
1236
  ```
1155
1237
 
1156
- Defined in: [data-structures/heap/heap.ts:511](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L511)
1238
+ Defined in: [data-structures/heap/heap.ts:523](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L523)
1157
1239
 
1158
1240
  #### Returns
1159
1241
 
@@ -1162,6 +1244,7 @@ Defined in: [data-structures/heap/heap.ts:511](https://github.com/zrwusa/data-st
1162
1244
  #### Deprecated
1163
1245
 
1164
1246
  Use `pop` instead. Will be removed in a future major version.
1247
+
1165
1248
  *
1166
1249
 
1167
1250
  #### Example
@@ -1205,7 +1288,7 @@ Use `pop` instead. Will be removed in a future major version.
1205
1288
  pop(): E | undefined;
1206
1289
  ```
1207
1290
 
1208
- Defined in: [data-structures/heap/heap.ts:520](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L520)
1291
+ Defined in: [data-structures/heap/heap.ts:532](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L532)
1209
1292
 
1210
1293
  Remove and return the top element (min or max depending on comparator).
1211
1294
 
@@ -1231,7 +1314,7 @@ Time O(log N) amortized, Space O(1)
1231
1314
  print(): void;
1232
1315
  ```
1233
1316
 
1234
- 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)
1317
+ Defined in: [data-structures/base/iterable-element-base.ts:301](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L301)
1235
1318
 
1236
1319
  Prints `toVisual()` to the console. Intended for quick debugging.
1237
1320
 
@@ -1289,7 +1372,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
1289
1372
  reduce(callbackfn): E;
1290
1373
  ```
1291
1374
 
1292
- 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)
1375
+ 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)
1293
1376
 
1294
1377
  ##### Parameters
1295
1378
 
@@ -1311,7 +1394,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
1311
1394
  reduce(callbackfn, initialValue): E;
1312
1395
  ```
1313
1396
 
1314
- 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)
1397
+ 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)
1315
1398
 
1316
1399
  ##### Parameters
1317
1400
 
@@ -1337,7 +1420,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
1337
1420
  reduce<U>(callbackfn, initialValue): U;
1338
1421
  ```
1339
1422
 
1340
- 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)
1423
+ Defined in: [data-structures/base/iterable-element-base.ts:228](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L228)
1341
1424
 
1342
1425
  ##### Type Parameters
1343
1426
 
@@ -1371,7 +1454,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.c
1371
1454
  setEquality(equals): this;
1372
1455
  ```
1373
1456
 
1374
- Defined in: [data-structures/heap/heap.ts:903](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L903)
1457
+ Defined in: [data-structures/heap/heap.ts:930](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L930)
1375
1458
 
1376
1459
  Set the equality comparator used by has/delete operations.
1377
1460
 
@@ -1445,7 +1528,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
1445
1528
  sort(): E[];
1446
1529
  ```
1447
1530
 
1448
- Defined in: [data-structures/heap/heap.ts:1039](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1039)
1531
+ Defined in: [data-structures/heap/heap.ts:1072](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1072)
1449
1532
 
1450
1533
  Return all elements in ascending order by repeatedly polling.
1451
1534
 
@@ -1482,7 +1565,7 @@ Time O(N log N), Space O(N)
1482
1565
  toArray(): E[];
1483
1566
  ```
1484
1567
 
1485
- 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)
1568
+ Defined in: [data-structures/base/iterable-element-base.ts:278](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L278)
1486
1569
 
1487
1570
  Materializes the elements into a new array.
1488
1571
 
@@ -1508,7 +1591,7 @@ Time O(n), Space O(n).
1508
1591
  toVisual(): E[];
1509
1592
  ```
1510
1593
 
1511
- 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)
1594
+ Defined in: [data-structures/base/iterable-element-base.ts:290](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L290)
1512
1595
 
1513
1596
  Returns a representation of the structure suitable for quick visualization.
1514
1597
  Defaults to an array of elements; subclasses may override to provide richer visuals.
@@ -1564,7 +1647,7 @@ static from<T, R, S>(
1564
1647
  options?): S;
1565
1648
  ```
1566
1649
 
1567
- Defined in: [data-structures/heap/heap.ts:263](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L263)
1650
+ Defined in: [data-structures/heap/heap.ts:266](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L266)
1568
1651
 
1569
1652
  Create a heap of the same class from an iterable.
1570
1653
 
@@ -1622,7 +1705,7 @@ Time O(N), Space O(N)
1622
1705
  static heapify<EE, RR>(elements, options): Heap<EE, RR>;
1623
1706
  ```
1624
1707
 
1625
- Defined in: [data-structures/heap/heap.ts:281](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L281)
1708
+ Defined in: [data-structures/heap/heap.ts:284](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L284)
1626
1709
 
1627
1710
  Build a Heap from an iterable in linear time given a comparator.
1628
1711
 
@@ -1705,7 +1788,7 @@ Time O(1), Space O(1).
1705
1788
  protected _createInstance(options?): this;
1706
1789
  ```
1707
1790
 
1708
- Defined in: [data-structures/heap/heap.ts:1318](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1318)
1791
+ Defined in: [data-structures/heap/heap.ts:1360](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1360)
1709
1792
 
1710
1793
  (Protected) Create an empty instance of the same concrete class.
1711
1794
 
@@ -1739,7 +1822,7 @@ Time O(1), Space O(1)
1739
1822
  protected _createLike<EM, RM>(elements?, options?): Heap<EM, RM>;
1740
1823
  ```
1741
1824
 
1742
- Defined in: [data-structures/heap/heap.ts:1336](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1336)
1825
+ Defined in: [data-structures/heap/heap.ts:1378](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1378)
1743
1826
 
1744
1827
  (Protected) Create a like-kind instance seeded by elements.
1745
1828
 
@@ -1789,7 +1872,7 @@ Time O(N log N), Space O(N)
1789
1872
  protected _getIterator(): IterableIterator<E>;
1790
1873
  ```
1791
1874
 
1792
- Defined in: [data-structures/heap/heap.ts:1276](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1276)
1875
+ Defined in: [data-structures/heap/heap.ts:1318](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1318)
1793
1876
 
1794
1877
  Internal iterator factory used by the default iterator.
1795
1878
 
@@ -1815,7 +1898,7 @@ Implementations should yield in O(1) per element with O(1) extra space when poss
1815
1898
  protected _spawnLike<EM, RM>(options?): Heap<EM, RM>;
1816
1899
  ```
1817
1900
 
1818
- Defined in: [data-structures/heap/heap.ts:1356](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1356)
1901
+ Defined in: [data-structures/heap/heap.ts:1398](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1398)
1819
1902
 
1820
1903
  (Protected) Spawn an empty like-kind heap instance.
1821
1904