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
@@ -149,7 +149,7 @@ PriorityQueue<E, R>.constructor
149
149
  get comparator(): Comparator<E>;
150
150
  ```
151
151
 
152
- Defined in: [data-structures/heap/heap.ts:1272](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1272)
152
+ Defined in: [data-structures/heap/heap.ts:1314](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1314)
153
153
 
154
154
  Get the comparator used to order elements.
155
155
 
@@ -205,7 +205,7 @@ Internal elements array.
205
205
  get leaf(): E | undefined;
206
206
  ```
207
207
 
208
- Defined in: [data-structures/heap/heap.ts:248](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L248)
208
+ Defined in: [data-structures/heap/heap.ts:251](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L251)
209
209
 
210
210
  Get the last leaf element.
211
211
 
@@ -233,7 +233,7 @@ Last element or undefined.
233
233
  get size(): number;
234
234
  ```
235
235
 
236
- Defined in: [data-structures/heap/heap.ts:238](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L238)
236
+ Defined in: [data-structures/heap/heap.ts:241](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L241)
237
237
 
238
238
  Get the number of elements.
239
239
 
@@ -336,7 +336,7 @@ Producing the iterator is O(1); consuming the entire iterator is Time O(n) with
336
336
  add(element): boolean;
337
337
  ```
338
338
 
339
- Defined in: [data-structures/heap/heap.ts:346](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L346)
339
+ Defined in: [data-structures/heap/heap.ts:352](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L352)
340
340
 
341
341
  Insert an element.
342
342
 
@@ -391,7 +391,7 @@ Time O(log N) amortized, Space O(1)
391
391
  addMany(elements): boolean[];
392
392
  ```
393
393
 
394
- Defined in: [data-structures/heap/heap.ts:400](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L400)
394
+ Defined in: [data-structures/heap/heap.ts:409](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L409)
395
395
 
396
396
  Insert many elements from an iterable.
397
397
 
@@ -437,7 +437,7 @@ Time O(N log N), Space O(1)
437
437
  clear(): void;
438
438
  ```
439
439
 
440
- Defined in: [data-structures/heap/heap.ts:740](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L740)
440
+ Defined in: [data-structures/heap/heap.ts:761](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L761)
441
441
 
442
442
  Remove all elements.
443
443
 
@@ -474,7 +474,7 @@ Time O(1), Space O(1)
474
474
  clone(): this;
475
475
  ```
476
476
 
477
- Defined in: [data-structures/heap/heap.ts:1100](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1100)
477
+ Defined in: [data-structures/heap/heap.ts:1136](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1136)
478
478
 
479
479
  Deep clone this heap.
480
480
 
@@ -513,7 +513,7 @@ Time O(N), Space O(N)
513
513
  delete(element): boolean;
514
514
  ```
515
515
 
516
- Defined in: [data-structures/heap/heap.ts:841](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L841)
516
+ Defined in: [data-structures/heap/heap.ts:868](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L868)
517
517
 
518
518
  Delete one occurrence of an element.
519
519
 
@@ -558,7 +558,7 @@ Time O(N), Space O(1)
558
558
  deleteBy(predicate): boolean;
559
559
  ```
560
560
 
561
- Defined in: [data-structures/heap/heap.ts:865](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L865)
561
+ Defined in: [data-structures/heap/heap.ts:892](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L892)
562
562
 
563
563
  #### Parameters
564
564
 
@@ -586,7 +586,7 @@ Use `deleteWhere` instead. Will be removed in a future major version.
586
586
  deleteWhere(predicate): boolean;
587
587
  ```
588
588
 
589
- Defined in: [data-structures/heap/heap.ts:875](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L875)
589
+ Defined in: [data-structures/heap/heap.ts:902](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L902)
590
590
 
591
591
  Delete the first element that matches a predicate.
592
592
 
@@ -620,7 +620,7 @@ Time O(N), Space O(1)
620
620
  dfs(order?): E[];
621
621
  ```
622
622
 
623
- Defined in: [data-structures/heap/heap.ts:950](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L950)
623
+ Defined in: [data-structures/heap/heap.ts:980](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L980)
624
624
 
625
625
  Traverse the binary heap as a complete binary tree and collect elements.
626
626
 
@@ -659,6 +659,30 @@ Time O(N), Space O(H)
659
659
 
660
660
  ***
661
661
 
662
+ ### entries()
663
+
664
+ ```ts
665
+ entries(): IterableIterator<[number, E]>;
666
+ ```
667
+
668
+ 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)
669
+
670
+ Return an iterator of `[index, value]` pairs (Array-compatible).
671
+
672
+ #### Returns
673
+
674
+ `IterableIterator`\<\[`number`, `E`\]\>
675
+
676
+ #### Remarks
677
+
678
+ Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
679
+
680
+ #### Inherited from
681
+
682
+ [`PriorityQueue`](PriorityQueue.md).[`entries`](PriorityQueue.md#entries)
683
+
684
+ ***
685
+
662
686
  ### every()
663
687
 
664
688
  ```ts
@@ -705,7 +729,7 @@ Time O(n) in the worst case; may exit early when the first failure is found. Spa
705
729
  filter(callback, thisArg?): this;
706
730
  ```
707
731
 
708
- Defined in: [data-structures/heap/heap.ts:1156](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1156)
732
+ Defined in: [data-structures/heap/heap.ts:1195](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1195)
709
733
 
710
734
  Filter elements into a new heap of the same class.
711
735
 
@@ -846,7 +870,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
846
870
  fix(): boolean[];
847
871
  ```
848
872
 
849
- Defined in: [data-structures/heap/heap.ts:981](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L981)
873
+ Defined in: [data-structures/heap/heap.ts:1011](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1011)
850
874
 
851
875
  Restore heap order bottom-up (heapify in-place).
852
876
 
@@ -912,7 +936,7 @@ Time O(n), Space O(1).
912
936
  has(element): boolean;
913
937
  ```
914
938
 
915
- Defined in: [data-structures/heap/heap.ts:788](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L788)
939
+ Defined in: [data-structures/heap/heap.ts:812](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L812)
916
940
 
917
941
  Check if an equal element exists in the heap.
918
942
 
@@ -951,13 +975,47 @@ Time O(N), Space O(1)
951
975
 
952
976
  ***
953
977
 
978
+ ### includes()
979
+
980
+ ```ts
981
+ includes(element): boolean;
982
+ ```
983
+
984
+ 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)
985
+
986
+ Check whether a value exists (Array-compatible alias for `has`).
987
+
988
+ #### Parameters
989
+
990
+ ##### element
991
+
992
+ `E`
993
+
994
+ Element to search for (uses `===`).
995
+
996
+ #### Returns
997
+
998
+ `boolean`
999
+
1000
+ `true` if found.
1001
+
1002
+ #### Remarks
1003
+
1004
+ Provided for familiarity when migrating from Array. Time O(n), Space O(1).
1005
+
1006
+ #### Inherited from
1007
+
1008
+ [`PriorityQueue`](PriorityQueue.md).[`includes`](PriorityQueue.md#includes)
1009
+
1010
+ ***
1011
+
954
1012
  ### isEmpty()
955
1013
 
956
1014
  ```ts
957
1015
  isEmpty(): boolean;
958
1016
  ```
959
1017
 
960
- Defined in: [data-structures/heap/heap.ts:688](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L688)
1018
+ Defined in: [data-structures/heap/heap.ts:706](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L706)
961
1019
 
962
1020
  Check whether the heap is empty.
963
1021
 
@@ -989,6 +1047,30 @@ Time O(1), Space O(1)
989
1047
 
990
1048
  ***
991
1049
 
1050
+ ### keys()
1051
+
1052
+ ```ts
1053
+ keys(): IterableIterator<number>;
1054
+ ```
1055
+
1056
+ 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)
1057
+
1058
+ Return an iterator of numeric indices (Array-compatible).
1059
+
1060
+ #### Returns
1061
+
1062
+ `IterableIterator`\<`number`\>
1063
+
1064
+ #### Remarks
1065
+
1066
+ Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
1067
+
1068
+ #### Inherited from
1069
+
1070
+ [`PriorityQueue`](PriorityQueue.md).[`keys`](PriorityQueue.md#keys)
1071
+
1072
+ ***
1073
+
992
1074
  ### map()
993
1075
 
994
1076
  ```ts
@@ -998,7 +1080,7 @@ map<EM, RM>(
998
1080
  thisArg?): Heap<EM, RM>;
999
1081
  ```
1000
1082
 
1001
- Defined in: [data-structures/heap/heap.ts:1221](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1221)
1083
+ Defined in: [data-structures/heap/heap.ts:1263](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1263)
1002
1084
 
1003
1085
  Map elements into a new heap of possibly different element type.
1004
1086
 
@@ -1065,7 +1147,7 @@ Time O(N log N), Space O(N)
1065
1147
  mapSame(callback, thisArg?): this;
1066
1148
  ```
1067
1149
 
1068
- Defined in: [data-structures/heap/heap.ts:1245](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1245)
1150
+ Defined in: [data-structures/heap/heap.ts:1287](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1287)
1069
1151
 
1070
1152
  Map elements into a new heap of the same element type.
1071
1153
 
@@ -1105,7 +1187,7 @@ Time O(N log N), Space O(N)
1105
1187
  peek(): E | undefined;
1106
1188
  ```
1107
1189
 
1108
- Defined in: [data-structures/heap/heap.ts:635](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L635)
1190
+ Defined in: [data-structures/heap/heap.ts:650](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L650)
1109
1191
 
1110
1192
  Get the current top element without removing it.
1111
1193
 
@@ -1196,7 +1278,7 @@ Time O(1), Space O(1)
1196
1278
  poll(): E | undefined;
1197
1279
  ```
1198
1280
 
1199
- Defined in: [data-structures/heap/heap.ts:511](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L511)
1281
+ Defined in: [data-structures/heap/heap.ts:523](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L523)
1200
1282
 
1201
1283
  #### Returns
1202
1284
 
@@ -1205,6 +1287,7 @@ Defined in: [data-structures/heap/heap.ts:511](https://github.com/zrwusa/data-st
1205
1287
  #### Deprecated
1206
1288
 
1207
1289
  Use `pop` instead. Will be removed in a future major version.
1290
+
1208
1291
  *
1209
1292
 
1210
1293
  #### Example
@@ -1248,7 +1331,7 @@ Use `pop` instead. Will be removed in a future major version.
1248
1331
  pop(): E | undefined;
1249
1332
  ```
1250
1333
 
1251
- Defined in: [data-structures/heap/heap.ts:520](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L520)
1334
+ Defined in: [data-structures/heap/heap.ts:532](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L532)
1252
1335
 
1253
1336
  Remove and return the top element (min or max depending on comparator).
1254
1337
 
@@ -1274,7 +1357,7 @@ Time O(log N) amortized, Space O(1)
1274
1357
  print(): void;
1275
1358
  ```
1276
1359
 
1277
- 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)
1360
+ 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)
1278
1361
 
1279
1362
  Prints `toVisual()` to the console. Intended for quick debugging.
1280
1363
 
@@ -1332,7 +1415,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
1332
1415
  reduce(callbackfn): E;
1333
1416
  ```
1334
1417
 
1335
- 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)
1418
+ 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)
1336
1419
 
1337
1420
  ##### Parameters
1338
1421
 
@@ -1354,7 +1437,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
1354
1437
  reduce(callbackfn, initialValue): E;
1355
1438
  ```
1356
1439
 
1357
- 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)
1440
+ 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)
1358
1441
 
1359
1442
  ##### Parameters
1360
1443
 
@@ -1380,7 +1463,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
1380
1463
  reduce<U>(callbackfn, initialValue): U;
1381
1464
  ```
1382
1465
 
1383
- 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)
1466
+ 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)
1384
1467
 
1385
1468
  ##### Type Parameters
1386
1469
 
@@ -1414,7 +1497,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.c
1414
1497
  setEquality(equals): this;
1415
1498
  ```
1416
1499
 
1417
- Defined in: [data-structures/heap/heap.ts:903](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L903)
1500
+ Defined in: [data-structures/heap/heap.ts:930](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L930)
1418
1501
 
1419
1502
  Set the equality comparator used by has/delete operations.
1420
1503
 
@@ -1488,7 +1571,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
1488
1571
  sort(): E[];
1489
1572
  ```
1490
1573
 
1491
- Defined in: [data-structures/heap/heap.ts:1039](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1039)
1574
+ Defined in: [data-structures/heap/heap.ts:1072](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1072)
1492
1575
 
1493
1576
  Return all elements in ascending order by repeatedly polling.
1494
1577
 
@@ -1525,7 +1608,7 @@ Time O(N log N), Space O(N)
1525
1608
  toArray(): E[];
1526
1609
  ```
1527
1610
 
1528
- 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)
1611
+ 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)
1529
1612
 
1530
1613
  Materializes the elements into a new array.
1531
1614
 
@@ -1551,7 +1634,7 @@ Time O(n), Space O(n).
1551
1634
  toVisual(): E[];
1552
1635
  ```
1553
1636
 
1554
- 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)
1637
+ 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)
1555
1638
 
1556
1639
  Returns a representation of the structure suitable for quick visualization.
1557
1640
  Defaults to an array of elements; subclasses may override to provide richer visuals.
@@ -1607,7 +1690,7 @@ static from<T, R, S>(
1607
1690
  options?): S;
1608
1691
  ```
1609
1692
 
1610
- Defined in: [data-structures/heap/heap.ts:263](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L263)
1693
+ Defined in: [data-structures/heap/heap.ts:266](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L266)
1611
1694
 
1612
1695
  Create a heap of the same class from an iterable.
1613
1696
 
@@ -1665,7 +1748,7 @@ Time O(N), Space O(N)
1665
1748
  static heapify<EE, RR>(elements, options): Heap<EE, RR>;
1666
1749
  ```
1667
1750
 
1668
- Defined in: [data-structures/heap/heap.ts:281](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L281)
1751
+ Defined in: [data-structures/heap/heap.ts:284](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L284)
1669
1752
 
1670
1753
  Build a Heap from an iterable in linear time given a comparator.
1671
1754
 
@@ -1748,7 +1831,7 @@ Time O(1), Space O(1).
1748
1831
  protected _createInstance(options?): this;
1749
1832
  ```
1750
1833
 
1751
- Defined in: [data-structures/heap/heap.ts:1318](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1318)
1834
+ Defined in: [data-structures/heap/heap.ts:1360](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1360)
1752
1835
 
1753
1836
  (Protected) Create an empty instance of the same concrete class.
1754
1837
 
@@ -1782,7 +1865,7 @@ Time O(1), Space O(1)
1782
1865
  protected _createLike<EM, RM>(elements?, options?): Heap<EM, RM>;
1783
1866
  ```
1784
1867
 
1785
- Defined in: [data-structures/heap/heap.ts:1336](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1336)
1868
+ Defined in: [data-structures/heap/heap.ts:1378](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1378)
1786
1869
 
1787
1870
  (Protected) Create a like-kind instance seeded by elements.
1788
1871
 
@@ -1832,7 +1915,7 @@ Time O(N log N), Space O(N)
1832
1915
  protected _getIterator(): IterableIterator<E>;
1833
1916
  ```
1834
1917
 
1835
- Defined in: [data-structures/heap/heap.ts:1276](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1276)
1918
+ Defined in: [data-structures/heap/heap.ts:1318](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1318)
1836
1919
 
1837
1920
  Internal iterator factory used by the default iterator.
1838
1921
 
@@ -1858,7 +1941,7 @@ Implementations should yield in O(1) per element with O(1) extra space when poss
1858
1941
  protected _spawnLike<EM, RM>(options?): Heap<EM, RM>;
1859
1942
  ```
1860
1943
 
1861
- Defined in: [data-structures/heap/heap.ts:1356](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1356)
1944
+ Defined in: [data-structures/heap/heap.ts:1398](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1398)
1862
1945
 
1863
1946
  (Protected) Spawn an empty like-kind heap instance.
1864
1947