data-structure-typed 2.5.2 → 2.6.0

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 (162) hide show
  1. package/.husky/pre-commit +3 -0
  2. package/CHANGELOG.md +3 -1
  3. package/MIGRATION.md +217 -0
  4. package/README.md +80 -8
  5. package/README_CN.md +569 -143
  6. package/SPECIFICATION.md +44 -14
  7. package/SPECIFICATION.zh-CN.md +44 -14
  8. package/dist/cjs/binary-tree.cjs +5841 -1678
  9. package/dist/cjs/graph.cjs +422 -14
  10. package/dist/cjs/hash.cjs +95 -7
  11. package/dist/cjs/heap.cjs +174 -16
  12. package/dist/cjs/index.cjs +7751 -2449
  13. package/dist/cjs/linked-list.cjs +443 -2
  14. package/dist/cjs/matrix.cjs +56 -0
  15. package/dist/cjs/priority-queue.cjs +172 -14
  16. package/dist/cjs/queue.cjs +435 -0
  17. package/dist/cjs/stack.cjs +103 -4
  18. package/dist/cjs/trie.cjs +106 -0
  19. package/dist/cjs-legacy/binary-tree.cjs +5933 -1772
  20. package/dist/cjs-legacy/graph.cjs +422 -14
  21. package/dist/cjs-legacy/hash.cjs +95 -7
  22. package/dist/cjs-legacy/heap.cjs +174 -16
  23. package/dist/cjs-legacy/index.cjs +8154 -2854
  24. package/dist/cjs-legacy/linked-list.cjs +443 -2
  25. package/dist/cjs-legacy/matrix.cjs +56 -0
  26. package/dist/cjs-legacy/priority-queue.cjs +172 -14
  27. package/dist/cjs-legacy/queue.cjs +435 -0
  28. package/dist/cjs-legacy/stack.cjs +103 -4
  29. package/dist/cjs-legacy/trie.cjs +106 -0
  30. package/dist/esm/binary-tree.mjs +5841 -1678
  31. package/dist/esm/graph.mjs +422 -14
  32. package/dist/esm/hash.mjs +95 -7
  33. package/dist/esm/heap.mjs +174 -16
  34. package/dist/esm/index.mjs +7751 -2449
  35. package/dist/esm/linked-list.mjs +443 -2
  36. package/dist/esm/matrix.mjs +56 -0
  37. package/dist/esm/priority-queue.mjs +172 -14
  38. package/dist/esm/queue.mjs +435 -0
  39. package/dist/esm/stack.mjs +103 -4
  40. package/dist/esm/trie.mjs +106 -0
  41. package/dist/esm-legacy/binary-tree.mjs +5933 -1772
  42. package/dist/esm-legacy/graph.mjs +422 -14
  43. package/dist/esm-legacy/hash.mjs +95 -7
  44. package/dist/esm-legacy/heap.mjs +174 -16
  45. package/dist/esm-legacy/index.mjs +8154 -2854
  46. package/dist/esm-legacy/linked-list.mjs +443 -2
  47. package/dist/esm-legacy/matrix.mjs +56 -0
  48. package/dist/esm-legacy/priority-queue.mjs +172 -14
  49. package/dist/esm-legacy/queue.mjs +435 -0
  50. package/dist/esm-legacy/stack.mjs +103 -4
  51. package/dist/esm-legacy/trie.mjs +106 -0
  52. package/dist/types/data-structures/base/iterable-element-base.d.ts +17 -0
  53. package/dist/types/data-structures/base/linear-base.d.ts +6 -0
  54. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +86 -2
  55. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +98 -0
  56. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +191 -15
  57. package/dist/types/data-structures/binary-tree/bst.d.ts +171 -3
  58. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +136 -8
  59. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +42 -0
  60. package/dist/types/data-structures/binary-tree/tree-map.d.ts +1061 -167
  61. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1232 -355
  62. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +916 -194
  63. package/dist/types/data-structures/binary-tree/tree-set.d.ts +1078 -141
  64. package/dist/types/data-structures/graph/directed-graph.d.ts +70 -0
  65. package/dist/types/data-structures/graph/undirected-graph.d.ts +63 -0
  66. package/dist/types/data-structures/hash/hash-map.d.ts +84 -6
  67. package/dist/types/data-structures/heap/heap.d.ts +140 -12
  68. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +150 -2
  69. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +106 -1
  70. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +126 -0
  71. package/dist/types/data-structures/matrix/matrix.d.ts +56 -0
  72. package/dist/types/data-structures/queue/deque.d.ts +171 -0
  73. package/dist/types/data-structures/queue/queue.d.ts +97 -0
  74. package/dist/types/data-structures/stack/stack.d.ts +72 -2
  75. package/dist/types/data-structures/trie/trie.d.ts +84 -0
  76. package/dist/types/interfaces/binary-tree.d.ts +2 -3
  77. package/dist/umd/data-structure-typed.js +7784 -2484
  78. package/dist/umd/data-structure-typed.min.js +4 -4
  79. package/docs-site-docusaurus/docs/api/classes/AVLTree.md +188 -200
  80. package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +11 -11
  81. package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +62 -62
  82. package/docs-site-docusaurus/docs/api/classes/BST.md +183 -195
  83. package/docs-site-docusaurus/docs/api/classes/BSTNode.md +13 -13
  84. package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +15 -15
  85. package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +143 -155
  86. package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
  87. package/docs-site-docusaurus/docs/api/classes/Deque.md +99 -85
  88. package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +73 -73
  89. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +100 -70
  90. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +8 -8
  91. package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +12 -12
  92. package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
  93. package/docs-site-docusaurus/docs/api/classes/HashMap.md +38 -38
  94. package/docs-site-docusaurus/docs/api/classes/Heap.md +96 -85
  95. package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +25 -25
  96. package/docs-site-docusaurus/docs/api/classes/IterableEntryBase.md +23 -23
  97. package/docs-site-docusaurus/docs/api/classes/LinearBase.md +48 -48
  98. package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +52 -52
  99. package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +46 -42
  100. package/docs-site-docusaurus/docs/api/classes/LinkedListNode.md +6 -6
  101. package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +74 -74
  102. package/docs-site-docusaurus/docs/api/classes/MapGraph.md +73 -73
  103. package/docs-site-docusaurus/docs/api/classes/Matrix.md +31 -31
  104. package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +104 -89
  105. package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +104 -89
  106. package/docs-site-docusaurus/docs/api/classes/MinHeap.md +104 -89
  107. package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +104 -89
  108. package/docs-site-docusaurus/docs/api/classes/Navigator.md +5 -5
  109. package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +103 -88
  110. package/docs-site-docusaurus/docs/api/classes/Queue.md +111 -59
  111. package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +200 -212
  112. package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -10
  113. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +75 -75
  114. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +6 -6
  115. package/docs-site-docusaurus/docs/api/classes/SkipList.md +37 -37
  116. package/docs-site-docusaurus/docs/api/classes/Stack.md +42 -42
  117. package/docs-site-docusaurus/docs/api/classes/TreeMap.md +107 -36
  118. package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +43 -43
  119. package/docs-site-docusaurus/docs/api/classes/TreeSet.md +106 -35
  120. package/docs-site-docusaurus/docs/api/classes/Trie.md +43 -43
  121. package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
  122. package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +72 -72
  123. package/docs-site-docusaurus/docs/guide/architecture.md +75 -7
  124. package/docs-site-docusaurus/docs/guide/concepts.md +53 -34
  125. package/docs-site-docusaurus/docs/guide/faq.md +53 -0
  126. package/docs-site-docusaurus/docs/guide/guides.md +8 -9
  127. package/docs-site-docusaurus/docs/guide/integrations.md +74 -177
  128. package/docs-site-docusaurus/docs/guide/overview.md +131 -17
  129. package/docs-site-docusaurus/src/pages/index.tsx +4 -0
  130. package/docs-site-docusaurus/typedoc.json +1 -0
  131. package/jest.integration.config.js +1 -2
  132. package/package.json +10 -7
  133. package/src/data-structures/base/iterable-element-base.ts +32 -0
  134. package/src/data-structures/base/linear-base.ts +11 -0
  135. package/src/data-structures/binary-tree/avl-tree.ts +88 -5
  136. package/src/data-structures/binary-tree/binary-indexed-tree.ts +98 -0
  137. package/src/data-structures/binary-tree/binary-tree.ts +242 -81
  138. package/src/data-structures/binary-tree/bst.ts +173 -7
  139. package/src/data-structures/binary-tree/red-black-tree.ts +139 -15
  140. package/src/data-structures/binary-tree/segment-tree.ts +42 -0
  141. package/src/data-structures/binary-tree/tree-map.ts +948 -36
  142. package/src/data-structures/binary-tree/tree-multi-map.ts +893 -13
  143. package/src/data-structures/binary-tree/tree-multi-set.ts +761 -33
  144. package/src/data-structures/binary-tree/tree-set.ts +1260 -251
  145. package/src/data-structures/graph/directed-graph.ts +71 -1
  146. package/src/data-structures/graph/undirected-graph.ts +64 -1
  147. package/src/data-structures/hash/hash-map.ts +100 -12
  148. package/src/data-structures/heap/heap.ts +149 -19
  149. package/src/data-structures/linked-list/doubly-linked-list.ts +178 -2
  150. package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
  151. package/src/data-structures/linked-list/skip-linked-list.ts +126 -0
  152. package/src/data-structures/matrix/matrix.ts +56 -0
  153. package/src/data-structures/queue/deque.ts +187 -0
  154. package/src/data-structures/queue/queue.ts +109 -0
  155. package/src/data-structures/stack/stack.ts +75 -5
  156. package/src/data-structures/trie/trie.ts +84 -0
  157. package/src/interfaces/binary-tree.ts +1 -9
  158. package/.vitepress/cache/deps_temp_51f5f1b0/chunk-7OIKW5WK.js +0 -12984
  159. package/.vitepress/cache/deps_temp_51f5f1b0/package.json +0 -3
  160. package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vue_devtools-api.js +0 -4505
  161. package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vueuse_core.js +0 -9731
  162. package/.vitepress/cache/deps_temp_51f5f1b0/vue.js +0 -347
@@ -6,7 +6,7 @@
6
6
 
7
7
  # Class: MaxHeap\<E, R\>
8
8
 
9
- Defined in: [data-structures/heap/max-heap.ts:73](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/max-heap.ts#L73)
9
+ Defined in: [data-structures/heap/max-heap.ts:73](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/max-heap.ts#L73)
10
10
 
11
11
  ## Examples
12
12
 
@@ -97,7 +97,7 @@ Notes and typical use-cases are documented in [Heap](Heap.md).
97
97
  new MaxHeap<E, R>(elements?, options?): MaxHeap<E, R>;
98
98
  ```
99
99
 
100
- Defined in: [data-structures/heap/max-heap.ts:79](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/max-heap.ts#L79)
100
+ Defined in: [data-structures/heap/max-heap.ts:79](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/max-heap.ts#L79)
101
101
 
102
102
  Create a max-heap. For objects, supply a custom comparator.
103
103
 
@@ -133,7 +133,7 @@ Optional configuration.
133
133
  get comparator(): Comparator<E>;
134
134
  ```
135
135
 
136
- Defined in: [data-structures/heap/heap.ts:1184](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1184)
136
+ Defined in: [data-structures/heap/heap.ts:1272](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1272)
137
137
 
138
138
  Get the comparator used to order elements.
139
139
 
@@ -161,7 +161,7 @@ Comparator function.
161
161
  get elements(): E[];
162
162
  ```
163
163
 
164
- Defined in: [data-structures/heap/heap.ts:180](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L180)
164
+ Defined in: [data-structures/heap/heap.ts:180](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L180)
165
165
 
166
166
  Get the backing array of the heap.
167
167
 
@@ -189,7 +189,7 @@ Internal elements array.
189
189
  get leaf(): E | undefined;
190
190
  ```
191
191
 
192
- Defined in: [data-structures/heap/heap.ts:244](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L244)
192
+ Defined in: [data-structures/heap/heap.ts:248](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L248)
193
193
 
194
194
  Get the last leaf element.
195
195
 
@@ -217,7 +217,7 @@ Last element or undefined.
217
217
  get size(): number;
218
218
  ```
219
219
 
220
- Defined in: [data-structures/heap/heap.ts:234](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L234)
220
+ Defined in: [data-structures/heap/heap.ts:238](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L238)
221
221
 
222
222
  Get the number of elements.
223
223
 
@@ -260,7 +260,7 @@ Heap size.
260
260
  get toElementFn(): ((rawElement) => E) | undefined;
261
261
  ```
262
262
 
263
- Defined in: [data-structures/base/iterable-element-base.ts:48](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L48)
263
+ Defined in: [data-structures/base/iterable-element-base.ts:48](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L48)
264
264
 
265
265
  Exposes the current `toElementFn`, if configured.
266
266
 
@@ -286,7 +286,7 @@ The converter function or `undefined` when not set.
286
286
  iterator: IterableIterator<E>;
287
287
  ```
288
288
 
289
- Defined in: [data-structures/base/iterable-element-base.ts:61](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L61)
289
+ Defined in: [data-structures/base/iterable-element-base.ts:61](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L61)
290
290
 
291
291
  Returns an iterator over the structure's elements.
292
292
 
@@ -320,7 +320,7 @@ Producing the iterator is O(1); consuming the entire iterator is Time O(n) with
320
320
  add(element): boolean;
321
321
  ```
322
322
 
323
- Defined in: [data-structures/heap/heap.ts:338](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L338)
323
+ Defined in: [data-structures/heap/heap.ts:346](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L346)
324
324
 
325
325
  Insert an element.
326
326
 
@@ -342,7 +342,7 @@ True.
342
342
 
343
343
  #### Remarks
344
344
 
345
- Time O(1) amortized, Space O(1)
345
+ Time O(log N) amortized, Space O(1)
346
346
 
347
347
  #### Example
348
348
 
@@ -375,7 +375,7 @@ Time O(1) amortized, Space O(1)
375
375
  addMany(elements): boolean[];
376
376
  ```
377
377
 
378
- Defined in: [data-structures/heap/heap.ts:388](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L388)
378
+ Defined in: [data-structures/heap/heap.ts:400](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L400)
379
379
 
380
380
  Insert many elements from an iterable.
381
381
 
@@ -421,7 +421,7 @@ Time O(N log N), Space O(1)
421
421
  clear(): void;
422
422
  ```
423
423
 
424
- Defined in: [data-structures/heap/heap.ts:676](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L676)
424
+ Defined in: [data-structures/heap/heap.ts:740](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L740)
425
425
 
426
426
  Remove all elements.
427
427
 
@@ -458,7 +458,7 @@ Time O(1), Space O(1)
458
458
  clone(): this;
459
459
  ```
460
460
 
461
- Defined in: [data-structures/heap/heap.ts:1020](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1020)
461
+ Defined in: [data-structures/heap/heap.ts:1100](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1100)
462
462
 
463
463
  Deep clone this heap.
464
464
 
@@ -497,7 +497,7 @@ Time O(N), Space O(N)
497
497
  delete(element): boolean;
498
498
  ```
499
499
 
500
- Defined in: [data-structures/heap/heap.ts:779](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L779)
500
+ Defined in: [data-structures/heap/heap.ts:841](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L841)
501
501
 
502
502
  Delete one occurrence of an element.
503
503
 
@@ -536,13 +536,41 @@ Time O(N), Space O(1)
536
536
 
537
537
  ***
538
538
 
539
- ### deleteBy()
539
+ ### ~~deleteBy()~~
540
540
 
541
541
  ```ts
542
542
  deleteBy(predicate): boolean;
543
543
  ```
544
544
 
545
- Defined in: [data-structures/heap/heap.ts:807](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L807)
545
+ 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
+
547
+ #### Parameters
548
+
549
+ ##### predicate
550
+
551
+ (`element`, `index`, `heap`) => `boolean`
552
+
553
+ #### Returns
554
+
555
+ `boolean`
556
+
557
+ #### Deprecated
558
+
559
+ Use `deleteWhere` instead. Will be removed in a future major version.
560
+
561
+ #### Inherited from
562
+
563
+ [`Heap`](Heap.md).[`deleteBy`](Heap.md#deleteby)
564
+
565
+ ***
566
+
567
+ ### deleteWhere()
568
+
569
+ ```ts
570
+ deleteWhere(predicate): boolean;
571
+ ```
572
+
573
+ 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
574
 
547
575
  Delete the first element that matches a predicate.
548
576
 
@@ -566,7 +594,7 @@ Time O(N), Space O(1)
566
594
 
567
595
  #### Inherited from
568
596
 
569
- [`Heap`](Heap.md).[`deleteBy`](Heap.md#deleteby)
597
+ [`Heap`](Heap.md).[`deleteWhere`](Heap.md#deletewhere)
570
598
 
571
599
  ***
572
600
 
@@ -576,7 +604,7 @@ Time O(N), Space O(1)
576
604
  dfs(order?): E[];
577
605
  ```
578
606
 
579
- Defined in: [data-structures/heap/heap.ts:878](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L878)
607
+ 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
608
 
581
609
  Traverse the binary heap as a complete binary tree and collect elements.
582
610
 
@@ -621,7 +649,7 @@ Time O(N), Space O(H)
621
649
  every(predicate, thisArg?): boolean;
622
650
  ```
623
651
 
624
- Defined in: [data-structures/base/iterable-element-base.ts:87](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L87)
652
+ Defined in: [data-structures/base/iterable-element-base.ts:87](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L87)
625
653
 
626
654
  Tests whether all elements satisfy the predicate.
627
655
 
@@ -661,7 +689,7 @@ Time O(n) in the worst case; may exit early when the first failure is found. Spa
661
689
  filter(callback, thisArg?): this;
662
690
  ```
663
691
 
664
- Defined in: [data-structures/heap/heap.ts:1072](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1072)
692
+ Defined in: [data-structures/heap/heap.ts:1156](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1156)
665
693
 
666
694
  Filter elements into a new heap of the same class.
667
695
 
@@ -714,7 +742,7 @@ Time O(N log N), Space O(N)
714
742
  find<S>(predicate, thisArg?): S | undefined;
715
743
  ```
716
744
 
717
- Defined in: [data-structures/base/iterable-element-base.ts:163](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L163)
745
+ Defined in: [data-structures/base/iterable-element-base.ts:163](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L163)
718
746
 
719
747
  Finds the first element that satisfies the predicate and returns it.
720
748
 
@@ -760,7 +788,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
760
788
  find(predicate, thisArg?): E | undefined;
761
789
  ```
762
790
 
763
- Defined in: [data-structures/base/iterable-element-base.ts:164](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L164)
791
+ Defined in: [data-structures/base/iterable-element-base.ts:164](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L164)
764
792
 
765
793
  Finds the first element that satisfies the predicate and returns it.
766
794
 
@@ -802,7 +830,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
802
830
  fix(): boolean[];
803
831
  ```
804
832
 
805
- Defined in: [data-structures/heap/heap.ts:909](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L909)
833
+ Defined in: [data-structures/heap/heap.ts:981](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L981)
806
834
 
807
835
  Restore heap order bottom-up (heapify in-place).
808
836
 
@@ -828,7 +856,7 @@ Time O(N), Space O(1)
828
856
  forEach(callbackfn, thisArg?): void;
829
857
  ```
830
858
 
831
- Defined in: [data-structures/base/iterable-element-base.ts:133](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L133)
859
+ Defined in: [data-structures/base/iterable-element-base.ts:133](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L133)
832
860
 
833
861
  Invokes a callback for each element in iteration order.
834
862
 
@@ -868,7 +896,7 @@ Time O(n), Space O(1).
868
896
  has(element): boolean;
869
897
  ```
870
898
 
871
- Defined in: [data-structures/heap/heap.ts:730](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L730)
899
+ Defined in: [data-structures/heap/heap.ts:788](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L788)
872
900
 
873
901
  Check if an equal element exists in the heap.
874
902
 
@@ -913,7 +941,7 @@ Time O(N), Space O(1)
913
941
  isEmpty(): boolean;
914
942
  ```
915
943
 
916
- Defined in: [data-structures/heap/heap.ts:628](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L628)
944
+ Defined in: [data-structures/heap/heap.ts:688](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L688)
917
945
 
918
946
  Check whether the heap is empty.
919
947
 
@@ -954,7 +982,7 @@ map<EM, RM>(
954
982
  thisArg?): Heap<EM, RM>;
955
983
  ```
956
984
 
957
- Defined in: [data-structures/heap/heap.ts:1133](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1133)
985
+ Defined in: [data-structures/heap/heap.ts:1221](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1221)
958
986
 
959
987
  Map elements into a new heap of possibly different element type.
960
988
 
@@ -1021,7 +1049,7 @@ Time O(N log N), Space O(N)
1021
1049
  mapSame(callback, thisArg?): this;
1022
1050
  ```
1023
1051
 
1024
- Defined in: [data-structures/heap/heap.ts:1157](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1157)
1052
+ Defined in: [data-structures/heap/heap.ts:1245](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1245)
1025
1053
 
1026
1054
  Map elements into a new heap of the same element type.
1027
1055
 
@@ -1061,7 +1089,7 @@ Time O(N log N), Space O(N)
1061
1089
  peek(): E | undefined;
1062
1090
  ```
1063
1091
 
1064
- Defined in: [data-structures/heap/heap.ts:579](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L579)
1092
+ Defined in: [data-structures/heap/heap.ts:635](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L635)
1065
1093
 
1066
1094
  Get the current top element without removing it.
1067
1095
 
@@ -1146,28 +1174,23 @@ Time O(1), Space O(1)
1146
1174
 
1147
1175
  ***
1148
1176
 
1149
- ### poll()
1177
+ ### ~~poll()~~
1150
1178
 
1151
1179
  ```ts
1152
1180
  poll(): E | undefined;
1153
1181
  ```
1154
1182
 
1155
- Defined in: [data-structures/heap/heap.ts:468](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L468)
1156
-
1157
- Remove and return the top element.
1183
+ Defined in: [data-structures/heap/heap.ts:511](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L511)
1158
1184
 
1159
1185
  #### Returns
1160
1186
 
1161
1187
  `E` \| `undefined`
1162
1188
 
1163
- Top element or undefined.
1189
+ #### Deprecated
1164
1190
 
1191
+ Use `pop` instead. Will be removed in a future major version.
1165
1192
  *
1166
1193
 
1167
- #### Remarks
1168
-
1169
- Time O(log N), Space O(1)
1170
-
1171
1194
  #### Example
1172
1195
 
1173
1196
  ```ts
@@ -1203,13 +1226,39 @@ Time O(log N), Space O(1)
1203
1226
 
1204
1227
  ***
1205
1228
 
1229
+ ### pop()
1230
+
1231
+ ```ts
1232
+ pop(): E | undefined;
1233
+ ```
1234
+
1235
+ Defined in: [data-structures/heap/heap.ts:520](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L520)
1236
+
1237
+ Remove and return the top element (min or max depending on comparator).
1238
+
1239
+ #### Returns
1240
+
1241
+ `E` \| `undefined`
1242
+
1243
+ The removed top element, or undefined if empty.
1244
+
1245
+ #### Remarks
1246
+
1247
+ Time O(log N) amortized, Space O(1)
1248
+
1249
+ #### Inherited from
1250
+
1251
+ [`Heap`](Heap.md).[`pop`](Heap.md#pop)
1252
+
1253
+ ***
1254
+
1206
1255
  ### print()
1207
1256
 
1208
1257
  ```ts
1209
1258
  print(): void;
1210
1259
  ```
1211
1260
 
1212
- Defined in: [data-structures/base/iterable-element-base.ts:269](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L269)
1261
+ 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)
1213
1262
 
1214
1263
  Prints `toVisual()` to the console. Intended for quick debugging.
1215
1264
 
@@ -1267,7 +1316,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
1267
1316
  reduce(callbackfn): E;
1268
1317
  ```
1269
1318
 
1270
- Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L194)
1319
+ 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)
1271
1320
 
1272
1321
  ##### Parameters
1273
1322
 
@@ -1289,7 +1338,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
1289
1338
  reduce(callbackfn, initialValue): E;
1290
1339
  ```
1291
1340
 
1292
- Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L195)
1341
+ 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)
1293
1342
 
1294
1343
  ##### Parameters
1295
1344
 
@@ -1315,7 +1364,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
1315
1364
  reduce<U>(callbackfn, initialValue): U;
1316
1365
  ```
1317
1366
 
1318
- Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L196)
1367
+ 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)
1319
1368
 
1320
1369
  ##### Type Parameters
1321
1370
 
@@ -1343,47 +1392,13 @@ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.c
1343
1392
 
1344
1393
  ***
1345
1394
 
1346
- ### refill()
1347
-
1348
- ```ts
1349
- refill(elements): boolean[];
1350
- ```
1351
-
1352
- Defined in: [data-structures/heap/heap.ts:687](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L687)
1353
-
1354
- Replace the backing array and rebuild the heap.
1355
-
1356
- #### Parameters
1357
-
1358
- ##### elements
1359
-
1360
- `Iterable`\<`E`\>
1361
-
1362
- Iterable used to refill the heap.
1363
-
1364
- #### Returns
1365
-
1366
- `boolean`[]
1367
-
1368
- Array of per-node results from fixing steps.
1369
-
1370
- #### Remarks
1371
-
1372
- Time O(N), Space O(N)
1373
-
1374
- #### Inherited from
1375
-
1376
- [`Heap`](Heap.md).[`refill`](Heap.md#refill)
1377
-
1378
- ***
1379
-
1380
1395
  ### setEquality()
1381
1396
 
1382
1397
  ```ts
1383
1398
  setEquality(equals): this;
1384
1399
  ```
1385
1400
 
1386
- Defined in: [data-structures/heap/heap.ts:835](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L835)
1401
+ Defined in: [data-structures/heap/heap.ts:903](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L903)
1387
1402
 
1388
1403
  Set the equality comparator used by has/delete operations.
1389
1404
 
@@ -1417,7 +1432,7 @@ Time O(1), Space O(1)
1417
1432
  some(predicate, thisArg?): boolean;
1418
1433
  ```
1419
1434
 
1420
- Defined in: [data-structures/base/iterable-element-base.ts:110](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L110)
1435
+ Defined in: [data-structures/base/iterable-element-base.ts:110](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L110)
1421
1436
 
1422
1437
  Tests whether at least one element satisfies the predicate.
1423
1438
 
@@ -1457,7 +1472,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
1457
1472
  sort(): E[];
1458
1473
  ```
1459
1474
 
1460
- Defined in: [data-structures/heap/heap.ts:963](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L963)
1475
+ Defined in: [data-structures/heap/heap.ts:1039](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1039)
1461
1476
 
1462
1477
  Return all elements in ascending order by repeatedly polling.
1463
1478
 
@@ -1494,7 +1509,7 @@ Time O(N log N), Space O(N)
1494
1509
  toArray(): E[];
1495
1510
  ```
1496
1511
 
1497
- Defined in: [data-structures/base/iterable-element-base.ts:246](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L246)
1512
+ 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)
1498
1513
 
1499
1514
  Materializes the elements into a new array.
1500
1515
 
@@ -1520,7 +1535,7 @@ Time O(n), Space O(n).
1520
1535
  toVisual(): E[];
1521
1536
  ```
1522
1537
 
1523
- Defined in: [data-structures/base/iterable-element-base.ts:258](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L258)
1538
+ 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)
1524
1539
 
1525
1540
  Returns a representation of the structure suitable for quick visualization.
1526
1541
  Defaults to an array of elements; subclasses may override to provide richer visuals.
@@ -1547,7 +1562,7 @@ Time O(n), Space O(n).
1547
1562
  values(): IterableIterator<E>;
1548
1563
  ```
1549
1564
 
1550
- Defined in: [data-structures/base/iterable-element-base.ts:72](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L72)
1565
+ Defined in: [data-structures/base/iterable-element-base.ts:72](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L72)
1551
1566
 
1552
1567
  Returns an iterator over the values (alias of the default iterator).
1553
1568
 
@@ -1576,7 +1591,7 @@ static from<T, R, S>(
1576
1591
  options?): S;
1577
1592
  ```
1578
1593
 
1579
- Defined in: [data-structures/heap/heap.ts:259](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L259)
1594
+ Defined in: [data-structures/heap/heap.ts:263](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L263)
1580
1595
 
1581
1596
  Create a heap of the same class from an iterable.
1582
1597
 
@@ -1634,7 +1649,7 @@ Time O(N), Space O(N)
1634
1649
  static heapify<EE, RR>(elements, options): Heap<EE, RR>;
1635
1650
  ```
1636
1651
 
1637
- Defined in: [data-structures/heap/heap.ts:277](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L277)
1652
+ Defined in: [data-structures/heap/heap.ts:281](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L281)
1638
1653
 
1639
1654
  Build a Heap from an iterable in linear time given a comparator.
1640
1655
 
@@ -1687,7 +1702,7 @@ Time O(N), Space O(N)
1687
1702
  protected optional _toElementFn?: (rawElement) => E;
1688
1703
  ```
1689
1704
 
1690
- Defined in: [data-structures/base/iterable-element-base.ts:39](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-element-base.ts#L39)
1705
+ Defined in: [data-structures/base/iterable-element-base.ts:39](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L39)
1691
1706
 
1692
1707
  The converter used to transform a raw element (`R`) into a public element (`E`).
1693
1708
 
@@ -1717,7 +1732,7 @@ Time O(1), Space O(1).
1717
1732
  protected _createInstance(options?): this;
1718
1733
  ```
1719
1734
 
1720
- Defined in: [data-structures/heap/heap.ts:1230](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1230)
1735
+ Defined in: [data-structures/heap/heap.ts:1318](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1318)
1721
1736
 
1722
1737
  (Protected) Create an empty instance of the same concrete class.
1723
1738
 
@@ -1751,7 +1766,7 @@ Time O(1), Space O(1)
1751
1766
  protected _createLike<EM, RM>(elements?, options?): Heap<EM, RM>;
1752
1767
  ```
1753
1768
 
1754
- Defined in: [data-structures/heap/heap.ts:1248](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1248)
1769
+ Defined in: [data-structures/heap/heap.ts:1336](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1336)
1755
1770
 
1756
1771
  (Protected) Create a like-kind instance seeded by elements.
1757
1772
 
@@ -1801,7 +1816,7 @@ Time O(N log N), Space O(N)
1801
1816
  protected _getIterator(): IterableIterator<E>;
1802
1817
  ```
1803
1818
 
1804
- Defined in: [data-structures/heap/heap.ts:1188](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1188)
1819
+ Defined in: [data-structures/heap/heap.ts:1276](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1276)
1805
1820
 
1806
1821
  Internal iterator factory used by the default iterator.
1807
1822
 
@@ -1827,7 +1842,7 @@ Implementations should yield in O(1) per element with O(1) extra space when poss
1827
1842
  protected _spawnLike<EM, RM>(options?): Heap<EM, RM>;
1828
1843
  ```
1829
1844
 
1830
- Defined in: [data-structures/heap/heap.ts:1268](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1268)
1845
+ Defined in: [data-structures/heap/heap.ts:1356](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1356)
1831
1846
 
1832
1847
  (Protected) Spawn an empty like-kind heap instance.
1833
1848