data-structure-typed 2.5.2 → 2.5.3

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 (156) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/MIGRATION.md +169 -0
  3. package/README.md +60 -6
  4. package/README_CN.md +551 -143
  5. package/SPECIFICATION.md +20 -14
  6. package/SPECIFICATION.zh-CN.md +20 -14
  7. package/dist/cjs/binary-tree.cjs +2417 -132
  8. package/dist/cjs/graph.cjs +248 -14
  9. package/dist/cjs/hash.cjs +62 -7
  10. package/dist/cjs/heap.cjs +103 -16
  11. package/dist/cjs/index.cjs +3046 -124
  12. package/dist/cjs/linked-list.cjs +219 -0
  13. package/dist/cjs/matrix.cjs +32 -0
  14. package/dist/cjs/priority-queue.cjs +101 -14
  15. package/dist/cjs/queue.cjs +215 -0
  16. package/dist/cjs/stack.cjs +44 -4
  17. package/dist/cjs/trie.cjs +44 -0
  18. package/dist/cjs-legacy/binary-tree.cjs +2406 -123
  19. package/dist/cjs-legacy/graph.cjs +248 -14
  20. package/dist/cjs-legacy/hash.cjs +62 -7
  21. package/dist/cjs-legacy/heap.cjs +103 -16
  22. package/dist/cjs-legacy/index.cjs +3105 -185
  23. package/dist/cjs-legacy/linked-list.cjs +219 -0
  24. package/dist/cjs-legacy/matrix.cjs +32 -0
  25. package/dist/cjs-legacy/priority-queue.cjs +101 -14
  26. package/dist/cjs-legacy/queue.cjs +215 -0
  27. package/dist/cjs-legacy/stack.cjs +44 -4
  28. package/dist/cjs-legacy/trie.cjs +44 -0
  29. package/dist/esm/binary-tree.mjs +2417 -132
  30. package/dist/esm/graph.mjs +248 -14
  31. package/dist/esm/hash.mjs +62 -7
  32. package/dist/esm/heap.mjs +103 -16
  33. package/dist/esm/index.mjs +3046 -124
  34. package/dist/esm/linked-list.mjs +219 -0
  35. package/dist/esm/matrix.mjs +32 -0
  36. package/dist/esm/priority-queue.mjs +101 -14
  37. package/dist/esm/queue.mjs +215 -0
  38. package/dist/esm/stack.mjs +44 -4
  39. package/dist/esm/trie.mjs +44 -0
  40. package/dist/esm-legacy/binary-tree.mjs +2406 -123
  41. package/dist/esm-legacy/graph.mjs +248 -14
  42. package/dist/esm-legacy/hash.mjs +62 -7
  43. package/dist/esm-legacy/heap.mjs +103 -16
  44. package/dist/esm-legacy/index.mjs +3105 -185
  45. package/dist/esm-legacy/linked-list.mjs +219 -0
  46. package/dist/esm-legacy/matrix.mjs +32 -0
  47. package/dist/esm-legacy/priority-queue.mjs +101 -14
  48. package/dist/esm-legacy/queue.mjs +215 -0
  49. package/dist/esm-legacy/stack.mjs +44 -4
  50. package/dist/esm-legacy/trie.mjs +44 -0
  51. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +50 -2
  52. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +56 -0
  53. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +116 -15
  54. package/dist/types/data-structures/binary-tree/bst.d.ts +99 -3
  55. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +79 -8
  56. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +24 -0
  57. package/dist/types/data-structures/binary-tree/tree-map.d.ts +520 -1
  58. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +489 -1
  59. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +393 -1
  60. package/dist/types/data-structures/binary-tree/tree-set.d.ts +500 -1
  61. package/dist/types/data-structures/graph/directed-graph.d.ts +40 -0
  62. package/dist/types/data-structures/graph/undirected-graph.d.ts +36 -0
  63. package/dist/types/data-structures/hash/hash-map.d.ts +51 -6
  64. package/dist/types/data-structures/heap/heap.d.ts +98 -12
  65. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +75 -0
  66. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +61 -1
  67. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +72 -0
  68. package/dist/types/data-structures/matrix/matrix.d.ts +32 -0
  69. package/dist/types/data-structures/queue/deque.d.ts +82 -0
  70. package/dist/types/data-structures/queue/queue.d.ts +61 -0
  71. package/dist/types/data-structures/stack/stack.d.ts +42 -2
  72. package/dist/types/data-structures/trie/trie.d.ts +48 -0
  73. package/dist/types/interfaces/binary-tree.d.ts +2 -3
  74. package/dist/umd/data-structure-typed.js +3105 -185
  75. package/dist/umd/data-structure-typed.min.js +4 -4
  76. package/docs-site-docusaurus/docs/api/classes/AVLTree.md +188 -200
  77. package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +11 -11
  78. package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +62 -62
  79. package/docs-site-docusaurus/docs/api/classes/BST.md +183 -195
  80. package/docs-site-docusaurus/docs/api/classes/BSTNode.md +13 -13
  81. package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +15 -15
  82. package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +143 -155
  83. package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
  84. package/docs-site-docusaurus/docs/api/classes/Deque.md +99 -85
  85. package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +73 -73
  86. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +100 -70
  87. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +8 -8
  88. package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +12 -12
  89. package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
  90. package/docs-site-docusaurus/docs/api/classes/HashMap.md +38 -38
  91. package/docs-site-docusaurus/docs/api/classes/Heap.md +96 -85
  92. package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +25 -25
  93. package/docs-site-docusaurus/docs/api/classes/IterableEntryBase.md +23 -23
  94. package/docs-site-docusaurus/docs/api/classes/LinearBase.md +48 -48
  95. package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +52 -52
  96. package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +42 -42
  97. package/docs-site-docusaurus/docs/api/classes/LinkedListNode.md +6 -6
  98. package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +74 -74
  99. package/docs-site-docusaurus/docs/api/classes/MapGraph.md +73 -73
  100. package/docs-site-docusaurus/docs/api/classes/Matrix.md +31 -31
  101. package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +104 -89
  102. package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +104 -89
  103. package/docs-site-docusaurus/docs/api/classes/MinHeap.md +104 -89
  104. package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +104 -89
  105. package/docs-site-docusaurus/docs/api/classes/Navigator.md +5 -5
  106. package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +103 -88
  107. package/docs-site-docusaurus/docs/api/classes/Queue.md +111 -59
  108. package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +200 -212
  109. package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -10
  110. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +75 -75
  111. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +6 -6
  112. package/docs-site-docusaurus/docs/api/classes/SkipList.md +37 -37
  113. package/docs-site-docusaurus/docs/api/classes/Stack.md +42 -42
  114. package/docs-site-docusaurus/docs/api/classes/TreeMap.md +107 -36
  115. package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +43 -43
  116. package/docs-site-docusaurus/docs/api/classes/TreeSet.md +106 -35
  117. package/docs-site-docusaurus/docs/api/classes/Trie.md +43 -43
  118. package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
  119. package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +72 -72
  120. package/docs-site-docusaurus/docs/guide/architecture.md +75 -7
  121. package/docs-site-docusaurus/docs/guide/concepts.md +53 -34
  122. package/docs-site-docusaurus/docs/guide/faq.md +53 -0
  123. package/docs-site-docusaurus/docs/guide/guides.md +8 -9
  124. package/docs-site-docusaurus/docs/guide/integrations.md +74 -177
  125. package/docs-site-docusaurus/docs/guide/overview.md +131 -17
  126. package/docs-site-docusaurus/src/pages/index.tsx +4 -0
  127. package/docs-site-docusaurus/typedoc.json +1 -0
  128. package/package.json +7 -6
  129. package/src/data-structures/binary-tree/avl-tree.ts +52 -5
  130. package/src/data-structures/binary-tree/binary-indexed-tree.ts +56 -0
  131. package/src/data-structures/binary-tree/binary-tree.ts +167 -81
  132. package/src/data-structures/binary-tree/bst.ts +101 -7
  133. package/src/data-structures/binary-tree/red-black-tree.ts +82 -15
  134. package/src/data-structures/binary-tree/segment-tree.ts +24 -0
  135. package/src/data-structures/binary-tree/tree-map.ts +540 -3
  136. package/src/data-structures/binary-tree/tree-multi-map.ts +490 -2
  137. package/src/data-structures/binary-tree/tree-multi-set.ts +393 -1
  138. package/src/data-structures/binary-tree/tree-set.ts +520 -3
  139. package/src/data-structures/graph/directed-graph.ts +41 -1
  140. package/src/data-structures/graph/undirected-graph.ts +37 -1
  141. package/src/data-structures/hash/hash-map.ts +67 -12
  142. package/src/data-structures/heap/heap.ts +107 -19
  143. package/src/data-structures/linked-list/doubly-linked-list.ts +88 -0
  144. package/src/data-structures/linked-list/singly-linked-list.ts +61 -1
  145. package/src/data-structures/linked-list/skip-linked-list.ts +72 -0
  146. package/src/data-structures/matrix/matrix.ts +32 -0
  147. package/src/data-structures/queue/deque.ts +85 -0
  148. package/src/data-structures/queue/queue.ts +73 -0
  149. package/src/data-structures/stack/stack.ts +45 -5
  150. package/src/data-structures/trie/trie.ts +48 -0
  151. package/src/interfaces/binary-tree.ts +1 -9
  152. package/.vitepress/cache/deps_temp_51f5f1b0/chunk-7OIKW5WK.js +0 -12984
  153. package/.vitepress/cache/deps_temp_51f5f1b0/package.json +0 -3
  154. package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vue_devtools-api.js +0 -4505
  155. package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vueuse_core.js +0 -9731
  156. package/.vitepress/cache/deps_temp_51f5f1b0/vue.js +0 -347
@@ -6,13 +6,13 @@
6
6
 
7
7
  # Class: Heap\<E, R\>
8
8
 
9
- Defined in: [data-structures/heap/heap.ts:150](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L150)
9
+ Defined in: [data-structures/heap/heap.ts:150](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L150)
10
10
 
11
11
  Binary heap with pluggable comparator; supports fast insertion and removal of the top element.
12
12
 
13
13
  ## Remarks
14
14
 
15
- Time O(1), Space O(1)
15
+ Typical operations: O(log N) insert/remove, O(1) peek. Space O(N).
16
16
 
17
17
  ## Examples
18
18
 
@@ -186,7 +186,7 @@ Min Heap: The value of each parent node is less than or equal to the value of it
186
186
  new Heap<E, R>(elements?, options?): Heap<E, R>;
187
187
  ```
188
188
 
189
- Defined in: [data-structures/heap/heap.ts:161](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L161)
189
+ Defined in: [data-structures/heap/heap.ts:161](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L161)
190
190
 
191
191
  Create a Heap and optionally bulk-insert elements.
192
192
 
@@ -228,7 +228,7 @@ Time O(N), Space O(N)
228
228
  get comparator(): Comparator<E>;
229
229
  ```
230
230
 
231
- Defined in: [data-structures/heap/heap.ts:1184](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1184)
231
+ Defined in: [data-structures/heap/heap.ts:1272](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1272)
232
232
 
233
233
  Get the comparator used to order elements.
234
234
 
@@ -252,7 +252,7 @@ Comparator function.
252
252
  get elements(): E[];
253
253
  ```
254
254
 
255
- Defined in: [data-structures/heap/heap.ts:180](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L180)
255
+ Defined in: [data-structures/heap/heap.ts:180](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L180)
256
256
 
257
257
  Get the backing array of the heap.
258
258
 
@@ -276,7 +276,7 @@ Internal elements array.
276
276
  get leaf(): E | undefined;
277
277
  ```
278
278
 
279
- Defined in: [data-structures/heap/heap.ts:244](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L244)
279
+ Defined in: [data-structures/heap/heap.ts:248](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L248)
280
280
 
281
281
  Get the last leaf element.
282
282
 
@@ -300,7 +300,7 @@ Last element or undefined.
300
300
  get size(): number;
301
301
  ```
302
302
 
303
- Defined in: [data-structures/heap/heap.ts:234](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L234)
303
+ Defined in: [data-structures/heap/heap.ts:238](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L238)
304
304
 
305
305
  Get the number of elements.
306
306
 
@@ -339,7 +339,7 @@ Heap size.
339
339
  get toElementFn(): ((rawElement) => E) | undefined;
340
340
  ```
341
341
 
342
- 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)
342
+ 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)
343
343
 
344
344
  Exposes the current `toElementFn`, if configured.
345
345
 
@@ -365,7 +365,7 @@ The converter function or `undefined` when not set.
365
365
  iterator: IterableIterator<E>;
366
366
  ```
367
367
 
368
- 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)
368
+ 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)
369
369
 
370
370
  Returns an iterator over the structure's elements.
371
371
 
@@ -399,7 +399,7 @@ Producing the iterator is O(1); consuming the entire iterator is Time O(n) with
399
399
  add(element): boolean;
400
400
  ```
401
401
 
402
- Defined in: [data-structures/heap/heap.ts:338](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L338)
402
+ Defined in: [data-structures/heap/heap.ts:346](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L346)
403
403
 
404
404
  Insert an element.
405
405
 
@@ -421,7 +421,7 @@ True.
421
421
 
422
422
  #### Remarks
423
423
 
424
- Time O(1) amortized, Space O(1)
424
+ Time O(log N) amortized, Space O(1)
425
425
 
426
426
  #### Example
427
427
 
@@ -450,7 +450,7 @@ Time O(1) amortized, Space O(1)
450
450
  addMany(elements): boolean[];
451
451
  ```
452
452
 
453
- Defined in: [data-structures/heap/heap.ts:388](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L388)
453
+ Defined in: [data-structures/heap/heap.ts:400](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L400)
454
454
 
455
455
  Insert many elements from an iterable.
456
456
 
@@ -492,7 +492,7 @@ Time O(N log N), Space O(1)
492
492
  clear(): void;
493
493
  ```
494
494
 
495
- Defined in: [data-structures/heap/heap.ts:676](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L676)
495
+ Defined in: [data-structures/heap/heap.ts:740](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L740)
496
496
 
497
497
  Remove all elements.
498
498
 
@@ -529,7 +529,7 @@ Time O(1), Space O(1)
529
529
  clone(): this;
530
530
  ```
531
531
 
532
- Defined in: [data-structures/heap/heap.ts:1020](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1020)
532
+ Defined in: [data-structures/heap/heap.ts:1100](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1100)
533
533
 
534
534
  Deep clone this heap.
535
535
 
@@ -568,7 +568,7 @@ Time O(N), Space O(N)
568
568
  delete(element): boolean;
569
569
  ```
570
570
 
571
- Defined in: [data-structures/heap/heap.ts:779](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L779)
571
+ Defined in: [data-structures/heap/heap.ts:841](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L841)
572
572
 
573
573
  Delete one occurrence of an element.
574
574
 
@@ -603,13 +603,37 @@ Time O(N), Space O(1)
603
603
 
604
604
  ***
605
605
 
606
- ### deleteBy()
606
+ ### ~~deleteBy()~~
607
607
 
608
608
  ```ts
609
609
  deleteBy(predicate): boolean;
610
610
  ```
611
611
 
612
- Defined in: [data-structures/heap/heap.ts:807](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L807)
612
+ Defined in: [data-structures/heap/heap.ts:865](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L865)
613
+
614
+ #### Parameters
615
+
616
+ ##### predicate
617
+
618
+ (`element`, `index`, `heap`) => `boolean`
619
+
620
+ #### Returns
621
+
622
+ `boolean`
623
+
624
+ #### Deprecated
625
+
626
+ Use `deleteWhere` instead. Will be removed in a future major version.
627
+
628
+ ***
629
+
630
+ ### deleteWhere()
631
+
632
+ ```ts
633
+ deleteWhere(predicate): boolean;
634
+ ```
635
+
636
+ Defined in: [data-structures/heap/heap.ts:875](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L875)
613
637
 
614
638
  Delete the first element that matches a predicate.
615
639
 
@@ -639,7 +663,7 @@ Time O(N), Space O(1)
639
663
  dfs(order?): E[];
640
664
  ```
641
665
 
642
- Defined in: [data-structures/heap/heap.ts:878](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L878)
666
+ Defined in: [data-structures/heap/heap.ts:950](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L950)
643
667
 
644
668
  Traverse the binary heap as a complete binary tree and collect elements.
645
669
 
@@ -680,7 +704,7 @@ Time O(N), Space O(H)
680
704
  every(predicate, thisArg?): boolean;
681
705
  ```
682
706
 
683
- 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)
707
+ 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)
684
708
 
685
709
  Tests whether all elements satisfy the predicate.
686
710
 
@@ -720,7 +744,7 @@ Time O(n) in the worst case; may exit early when the first failure is found. Spa
720
744
  filter(callback, thisArg?): this;
721
745
  ```
722
746
 
723
- Defined in: [data-structures/heap/heap.ts:1072](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1072)
747
+ Defined in: [data-structures/heap/heap.ts:1156](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1156)
724
748
 
725
749
  Filter elements into a new heap of the same class.
726
750
 
@@ -773,7 +797,7 @@ Time O(N log N), Space O(N)
773
797
  find<S>(predicate, thisArg?): S | undefined;
774
798
  ```
775
799
 
776
- 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)
800
+ 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)
777
801
 
778
802
  Finds the first element that satisfies the predicate and returns it.
779
803
 
@@ -819,7 +843,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
819
843
  find(predicate, thisArg?): E | undefined;
820
844
  ```
821
845
 
822
- 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)
846
+ 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)
823
847
 
824
848
  Finds the first element that satisfies the predicate and returns it.
825
849
 
@@ -861,7 +885,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
861
885
  fix(): boolean[];
862
886
  ```
863
887
 
864
- Defined in: [data-structures/heap/heap.ts:909](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L909)
888
+ Defined in: [data-structures/heap/heap.ts:981](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L981)
865
889
 
866
890
  Restore heap order bottom-up (heapify in-place).
867
891
 
@@ -883,7 +907,7 @@ Time O(N), Space O(1)
883
907
  forEach(callbackfn, thisArg?): void;
884
908
  ```
885
909
 
886
- 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)
910
+ 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)
887
911
 
888
912
  Invokes a callback for each element in iteration order.
889
913
 
@@ -923,7 +947,7 @@ Time O(n), Space O(1).
923
947
  has(element): boolean;
924
948
  ```
925
949
 
926
- Defined in: [data-structures/heap/heap.ts:730](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L730)
950
+ Defined in: [data-structures/heap/heap.ts:788](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L788)
927
951
 
928
952
  Check if an equal element exists in the heap.
929
953
 
@@ -968,7 +992,7 @@ Time O(N), Space O(1)
968
992
  isEmpty(): boolean;
969
993
  ```
970
994
 
971
- Defined in: [data-structures/heap/heap.ts:628](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L628)
995
+ Defined in: [data-structures/heap/heap.ts:688](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L688)
972
996
 
973
997
  Check whether the heap is empty.
974
998
 
@@ -1009,7 +1033,7 @@ map<EM, RM>(
1009
1033
  thisArg?): Heap<EM, RM>;
1010
1034
  ```
1011
1035
 
1012
- Defined in: [data-structures/heap/heap.ts:1133](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1133)
1036
+ Defined in: [data-structures/heap/heap.ts:1221](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1221)
1013
1037
 
1014
1038
  Map elements into a new heap of possibly different element type.
1015
1039
 
@@ -1076,7 +1100,7 @@ Time O(N log N), Space O(N)
1076
1100
  mapSame(callback, thisArg?): this;
1077
1101
  ```
1078
1102
 
1079
- Defined in: [data-structures/heap/heap.ts:1157](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1157)
1103
+ Defined in: [data-structures/heap/heap.ts:1245](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1245)
1080
1104
 
1081
1105
  Map elements into a new heap of the same element type.
1082
1106
 
@@ -1116,7 +1140,7 @@ Time O(N log N), Space O(N)
1116
1140
  peek(): E | undefined;
1117
1141
  ```
1118
1142
 
1119
- Defined in: [data-structures/heap/heap.ts:579](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L579)
1143
+ Defined in: [data-structures/heap/heap.ts:635](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L635)
1120
1144
 
1121
1145
  Get the current top element without removing it.
1122
1146
 
@@ -1197,28 +1221,23 @@ Time O(1), Space O(1)
1197
1221
 
1198
1222
  ***
1199
1223
 
1200
- ### poll()
1224
+ ### ~~poll()~~
1201
1225
 
1202
1226
  ```ts
1203
1227
  poll(): E | undefined;
1204
1228
  ```
1205
1229
 
1206
- Defined in: [data-structures/heap/heap.ts:468](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L468)
1207
-
1208
- Remove and return the top element.
1230
+ Defined in: [data-structures/heap/heap.ts:511](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L511)
1209
1231
 
1210
1232
  #### Returns
1211
1233
 
1212
1234
  `E` \| `undefined`
1213
1235
 
1214
- Top element or undefined.
1236
+ #### Deprecated
1215
1237
 
1238
+ Use `pop` instead. Will be removed in a future major version.
1216
1239
  *
1217
1240
 
1218
- #### Remarks
1219
-
1220
- Time O(log N), Space O(1)
1221
-
1222
1241
  #### Example
1223
1242
 
1224
1243
  ```ts
@@ -1250,13 +1269,35 @@ Time O(log N), Space O(1)
1250
1269
 
1251
1270
  ***
1252
1271
 
1272
+ ### pop()
1273
+
1274
+ ```ts
1275
+ pop(): E | undefined;
1276
+ ```
1277
+
1278
+ Defined in: [data-structures/heap/heap.ts:520](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L520)
1279
+
1280
+ Remove and return the top element (min or max depending on comparator).
1281
+
1282
+ #### Returns
1283
+
1284
+ `E` \| `undefined`
1285
+
1286
+ The removed top element, or undefined if empty.
1287
+
1288
+ #### Remarks
1289
+
1290
+ Time O(log N) amortized, Space O(1)
1291
+
1292
+ ***
1293
+
1253
1294
  ### print()
1254
1295
 
1255
1296
  ```ts
1256
1297
  print(): void;
1257
1298
  ```
1258
1299
 
1259
- 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)
1300
+ 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)
1260
1301
 
1261
1302
  Prints `toVisual()` to the console. Intended for quick debugging.
1262
1303
 
@@ -1314,7 +1355,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
1314
1355
  reduce(callbackfn): E;
1315
1356
  ```
1316
1357
 
1317
- 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)
1358
+ 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)
1318
1359
 
1319
1360
  ##### Parameters
1320
1361
 
@@ -1336,7 +1377,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
1336
1377
  reduce(callbackfn, initialValue): E;
1337
1378
  ```
1338
1379
 
1339
- 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)
1380
+ 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)
1340
1381
 
1341
1382
  ##### Parameters
1342
1383
 
@@ -1362,7 +1403,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
1362
1403
  reduce<U>(callbackfn, initialValue): U;
1363
1404
  ```
1364
1405
 
1365
- 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)
1406
+ 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)
1366
1407
 
1367
1408
  ##### Type Parameters
1368
1409
 
@@ -1390,43 +1431,13 @@ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.c
1390
1431
 
1391
1432
  ***
1392
1433
 
1393
- ### refill()
1394
-
1395
- ```ts
1396
- refill(elements): boolean[];
1397
- ```
1398
-
1399
- Defined in: [data-structures/heap/heap.ts:687](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L687)
1400
-
1401
- Replace the backing array and rebuild the heap.
1402
-
1403
- #### Parameters
1404
-
1405
- ##### elements
1406
-
1407
- `Iterable`\<`E`\>
1408
-
1409
- Iterable used to refill the heap.
1410
-
1411
- #### Returns
1412
-
1413
- `boolean`[]
1414
-
1415
- Array of per-node results from fixing steps.
1416
-
1417
- #### Remarks
1418
-
1419
- Time O(N), Space O(N)
1420
-
1421
- ***
1422
-
1423
1434
  ### setEquality()
1424
1435
 
1425
1436
  ```ts
1426
1437
  setEquality(equals): this;
1427
1438
  ```
1428
1439
 
1429
- Defined in: [data-structures/heap/heap.ts:835](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L835)
1440
+ Defined in: [data-structures/heap/heap.ts:903](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L903)
1430
1441
 
1431
1442
  Set the equality comparator used by has/delete operations.
1432
1443
 
@@ -1456,7 +1467,7 @@ Time O(1), Space O(1)
1456
1467
  some(predicate, thisArg?): boolean;
1457
1468
  ```
1458
1469
 
1459
- 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)
1470
+ 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)
1460
1471
 
1461
1472
  Tests whether at least one element satisfies the predicate.
1462
1473
 
@@ -1496,7 +1507,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
1496
1507
  sort(): E[];
1497
1508
  ```
1498
1509
 
1499
- Defined in: [data-structures/heap/heap.ts:963](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L963)
1510
+ Defined in: [data-structures/heap/heap.ts:1039](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1039)
1500
1511
 
1501
1512
  Return all elements in ascending order by repeatedly polling.
1502
1513
 
@@ -1529,7 +1540,7 @@ Time O(N log N), Space O(N)
1529
1540
  toArray(): E[];
1530
1541
  ```
1531
1542
 
1532
- 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)
1543
+ 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)
1533
1544
 
1534
1545
  Materializes the elements into a new array.
1535
1546
 
@@ -1555,7 +1566,7 @@ Time O(n), Space O(n).
1555
1566
  toVisual(): E[];
1556
1567
  ```
1557
1568
 
1558
- 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)
1569
+ 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)
1559
1570
 
1560
1571
  Returns a representation of the structure suitable for quick visualization.
1561
1572
  Defaults to an array of elements; subclasses may override to provide richer visuals.
@@ -1582,7 +1593,7 @@ Time O(n), Space O(n).
1582
1593
  values(): IterableIterator<E>;
1583
1594
  ```
1584
1595
 
1585
- 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)
1596
+ 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)
1586
1597
 
1587
1598
  Returns an iterator over the values (alias of the default iterator).
1588
1599
 
@@ -1611,7 +1622,7 @@ static from<T, R, S>(
1611
1622
  options?): S;
1612
1623
  ```
1613
1624
 
1614
- Defined in: [data-structures/heap/heap.ts:259](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L259)
1625
+ Defined in: [data-structures/heap/heap.ts:263](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L263)
1615
1626
 
1616
1627
  Create a heap of the same class from an iterable.
1617
1628
 
@@ -1665,7 +1676,7 @@ Time O(N), Space O(N)
1665
1676
  static heapify<EE, RR>(elements, options): Heap<EE, RR>;
1666
1677
  ```
1667
1678
 
1668
- Defined in: [data-structures/heap/heap.ts:277](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L277)
1679
+ Defined in: [data-structures/heap/heap.ts:281](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L281)
1669
1680
 
1670
1681
  Build a Heap from an iterable in linear time given a comparator.
1671
1682
 
@@ -1714,7 +1725,7 @@ Time O(N), Space O(N)
1714
1725
  protected optional _toElementFn?: (rawElement) => E;
1715
1726
  ```
1716
1727
 
1717
- 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)
1728
+ 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)
1718
1729
 
1719
1730
  The converter used to transform a raw element (`R`) into a public element (`E`).
1720
1731
 
@@ -1744,7 +1755,7 @@ Time O(1), Space O(1).
1744
1755
  protected _createInstance(options?): this;
1745
1756
  ```
1746
1757
 
1747
- Defined in: [data-structures/heap/heap.ts:1230](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1230)
1758
+ Defined in: [data-structures/heap/heap.ts:1318](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1318)
1748
1759
 
1749
1760
  (Protected) Create an empty instance of the same concrete class.
1750
1761
 
@@ -1774,7 +1785,7 @@ Time O(1), Space O(1)
1774
1785
  protected _createLike<EM, RM>(elements?, options?): Heap<EM, RM>;
1775
1786
  ```
1776
1787
 
1777
- Defined in: [data-structures/heap/heap.ts:1248](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1248)
1788
+ Defined in: [data-structures/heap/heap.ts:1336](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1336)
1778
1789
 
1779
1790
  (Protected) Create a like-kind instance seeded by elements.
1780
1791
 
@@ -1820,7 +1831,7 @@ Time O(N log N), Space O(N)
1820
1831
  protected _getIterator(): IterableIterator<E>;
1821
1832
  ```
1822
1833
 
1823
- Defined in: [data-structures/heap/heap.ts:1188](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1188)
1834
+ Defined in: [data-structures/heap/heap.ts:1276](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1276)
1824
1835
 
1825
1836
  Internal iterator factory used by the default iterator.
1826
1837
 
@@ -1846,7 +1857,7 @@ Implementations should yield in O(1) per element with O(1) extra space when poss
1846
1857
  protected _spawnLike<EM, RM>(options?): Heap<EM, RM>;
1847
1858
  ```
1848
1859
 
1849
- Defined in: [data-structures/heap/heap.ts:1268](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1268)
1860
+ Defined in: [data-structures/heap/heap.ts:1356](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1356)
1850
1861
 
1851
1862
  (Protected) Spawn an empty like-kind heap instance.
1852
1863