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: PriorityQueue\<E, R\>
8
8
 
9
- Defined in: [data-structures/priority-queue/priority-queue.ts:75](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/priority-queue/priority-queue.ts#L75)
9
+ Defined in: [data-structures/priority-queue/priority-queue.ts:75](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/priority-queue/priority-queue.ts#L75)
10
10
 
11
11
  ## Examples
12
12
 
@@ -106,7 +106,7 @@ Defined in: [data-structures/priority-queue/priority-queue.ts:75](https://github
106
106
  get comparator(): Comparator<E>;
107
107
  ```
108
108
 
109
- Defined in: [data-structures/heap/heap.ts:1184](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1184)
109
+ Defined in: [data-structures/heap/heap.ts:1272](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1272)
110
110
 
111
111
  Get the comparator used to order elements.
112
112
 
@@ -134,7 +134,7 @@ Comparator function.
134
134
  get elements(): E[];
135
135
  ```
136
136
 
137
- Defined in: [data-structures/heap/heap.ts:180](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L180)
137
+ Defined in: [data-structures/heap/heap.ts:180](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L180)
138
138
 
139
139
  Get the backing array of the heap.
140
140
 
@@ -162,7 +162,7 @@ Internal elements array.
162
162
  get leaf(): E | undefined;
163
163
  ```
164
164
 
165
- Defined in: [data-structures/heap/heap.ts:244](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L244)
165
+ Defined in: [data-structures/heap/heap.ts:248](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L248)
166
166
 
167
167
  Get the last leaf element.
168
168
 
@@ -190,7 +190,7 @@ Last element or undefined.
190
190
  get size(): number;
191
191
  ```
192
192
 
193
- Defined in: [data-structures/heap/heap.ts:234](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L234)
193
+ Defined in: [data-structures/heap/heap.ts:238](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L238)
194
194
 
195
195
  Get the number of elements.
196
196
 
@@ -233,7 +233,7 @@ Heap size.
233
233
  get toElementFn(): ((rawElement) => E) | undefined;
234
234
  ```
235
235
 
236
- 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)
236
+ 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)
237
237
 
238
238
  Exposes the current `toElementFn`, if configured.
239
239
 
@@ -259,7 +259,7 @@ The converter function or `undefined` when not set.
259
259
  iterator: IterableIterator<E>;
260
260
  ```
261
261
 
262
- 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)
262
+ 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)
263
263
 
264
264
  Returns an iterator over the structure's elements.
265
265
 
@@ -293,7 +293,7 @@ Producing the iterator is O(1); consuming the entire iterator is Time O(n) with
293
293
  add(element): boolean;
294
294
  ```
295
295
 
296
- Defined in: [data-structures/heap/heap.ts:338](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L338)
296
+ Defined in: [data-structures/heap/heap.ts:346](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L346)
297
297
 
298
298
  Insert an element.
299
299
 
@@ -315,7 +315,7 @@ True.
315
315
 
316
316
  #### Remarks
317
317
 
318
- Time O(1) amortized, Space O(1)
318
+ Time O(log N) amortized, Space O(1)
319
319
 
320
320
  #### Example
321
321
 
@@ -348,7 +348,7 @@ Time O(1) amortized, Space O(1)
348
348
  addMany(elements): boolean[];
349
349
  ```
350
350
 
351
- Defined in: [data-structures/heap/heap.ts:388](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L388)
351
+ Defined in: [data-structures/heap/heap.ts:400](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L400)
352
352
 
353
353
  Insert many elements from an iterable.
354
354
 
@@ -394,7 +394,7 @@ Time O(N log N), Space O(1)
394
394
  clear(): void;
395
395
  ```
396
396
 
397
- Defined in: [data-structures/heap/heap.ts:676](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L676)
397
+ Defined in: [data-structures/heap/heap.ts:740](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L740)
398
398
 
399
399
  Remove all elements.
400
400
 
@@ -431,7 +431,7 @@ Time O(1), Space O(1)
431
431
  clone(): this;
432
432
  ```
433
433
 
434
- Defined in: [data-structures/heap/heap.ts:1020](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1020)
434
+ Defined in: [data-structures/heap/heap.ts:1100](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1100)
435
435
 
436
436
  Deep clone this heap.
437
437
 
@@ -470,7 +470,7 @@ Time O(N), Space O(N)
470
470
  delete(element): boolean;
471
471
  ```
472
472
 
473
- Defined in: [data-structures/heap/heap.ts:779](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L779)
473
+ Defined in: [data-structures/heap/heap.ts:841](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L841)
474
474
 
475
475
  Delete one occurrence of an element.
476
476
 
@@ -509,13 +509,41 @@ Time O(N), Space O(1)
509
509
 
510
510
  ***
511
511
 
512
- ### deleteBy()
512
+ ### ~~deleteBy()~~
513
513
 
514
514
  ```ts
515
515
  deleteBy(predicate): boolean;
516
516
  ```
517
517
 
518
- Defined in: [data-structures/heap/heap.ts:807](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L807)
518
+ Defined in: [data-structures/heap/heap.ts:865](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L865)
519
+
520
+ #### Parameters
521
+
522
+ ##### predicate
523
+
524
+ (`element`, `index`, `heap`) => `boolean`
525
+
526
+ #### Returns
527
+
528
+ `boolean`
529
+
530
+ #### Deprecated
531
+
532
+ Use `deleteWhere` instead. Will be removed in a future major version.
533
+
534
+ #### Inherited from
535
+
536
+ [`Heap`](Heap.md).[`deleteBy`](Heap.md#deleteby)
537
+
538
+ ***
539
+
540
+ ### deleteWhere()
541
+
542
+ ```ts
543
+ deleteWhere(predicate): boolean;
544
+ ```
545
+
546
+ Defined in: [data-structures/heap/heap.ts:875](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L875)
519
547
 
520
548
  Delete the first element that matches a predicate.
521
549
 
@@ -539,7 +567,7 @@ Time O(N), Space O(1)
539
567
 
540
568
  #### Inherited from
541
569
 
542
- [`Heap`](Heap.md).[`deleteBy`](Heap.md#deleteby)
570
+ [`Heap`](Heap.md).[`deleteWhere`](Heap.md#deletewhere)
543
571
 
544
572
  ***
545
573
 
@@ -549,7 +577,7 @@ Time O(N), Space O(1)
549
577
  dfs(order?): E[];
550
578
  ```
551
579
 
552
- Defined in: [data-structures/heap/heap.ts:878](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L878)
580
+ Defined in: [data-structures/heap/heap.ts:950](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L950)
553
581
 
554
582
  Traverse the binary heap as a complete binary tree and collect elements.
555
583
 
@@ -594,7 +622,7 @@ Time O(N), Space O(H)
594
622
  every(predicate, thisArg?): boolean;
595
623
  ```
596
624
 
597
- 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)
625
+ 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)
598
626
 
599
627
  Tests whether all elements satisfy the predicate.
600
628
 
@@ -634,7 +662,7 @@ Time O(n) in the worst case; may exit early when the first failure is found. Spa
634
662
  filter(callback, thisArg?): this;
635
663
  ```
636
664
 
637
- Defined in: [data-structures/heap/heap.ts:1072](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1072)
665
+ Defined in: [data-structures/heap/heap.ts:1156](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1156)
638
666
 
639
667
  Filter elements into a new heap of the same class.
640
668
 
@@ -687,7 +715,7 @@ Time O(N log N), Space O(N)
687
715
  find<S>(predicate, thisArg?): S | undefined;
688
716
  ```
689
717
 
690
- 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)
718
+ 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)
691
719
 
692
720
  Finds the first element that satisfies the predicate and returns it.
693
721
 
@@ -733,7 +761,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
733
761
  find(predicate, thisArg?): E | undefined;
734
762
  ```
735
763
 
736
- 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)
764
+ 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)
737
765
 
738
766
  Finds the first element that satisfies the predicate and returns it.
739
767
 
@@ -775,7 +803,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
775
803
  fix(): boolean[];
776
804
  ```
777
805
 
778
- Defined in: [data-structures/heap/heap.ts:909](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L909)
806
+ Defined in: [data-structures/heap/heap.ts:981](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L981)
779
807
 
780
808
  Restore heap order bottom-up (heapify in-place).
781
809
 
@@ -801,7 +829,7 @@ Time O(N), Space O(1)
801
829
  forEach(callbackfn, thisArg?): void;
802
830
  ```
803
831
 
804
- 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)
832
+ 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)
805
833
 
806
834
  Invokes a callback for each element in iteration order.
807
835
 
@@ -841,7 +869,7 @@ Time O(n), Space O(1).
841
869
  has(element): boolean;
842
870
  ```
843
871
 
844
- Defined in: [data-structures/heap/heap.ts:730](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L730)
872
+ Defined in: [data-structures/heap/heap.ts:788](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L788)
845
873
 
846
874
  Check if an equal element exists in the heap.
847
875
 
@@ -886,7 +914,7 @@ Time O(N), Space O(1)
886
914
  isEmpty(): boolean;
887
915
  ```
888
916
 
889
- Defined in: [data-structures/heap/heap.ts:628](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L628)
917
+ Defined in: [data-structures/heap/heap.ts:688](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L688)
890
918
 
891
919
  Check whether the heap is empty.
892
920
 
@@ -927,7 +955,7 @@ map<EM, RM>(
927
955
  thisArg?): Heap<EM, RM>;
928
956
  ```
929
957
 
930
- Defined in: [data-structures/heap/heap.ts:1133](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1133)
958
+ Defined in: [data-structures/heap/heap.ts:1221](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1221)
931
959
 
932
960
  Map elements into a new heap of possibly different element type.
933
961
 
@@ -994,7 +1022,7 @@ Time O(N log N), Space O(N)
994
1022
  mapSame(callback, thisArg?): this;
995
1023
  ```
996
1024
 
997
- Defined in: [data-structures/heap/heap.ts:1157](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1157)
1025
+ Defined in: [data-structures/heap/heap.ts:1245](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1245)
998
1026
 
999
1027
  Map elements into a new heap of the same element type.
1000
1028
 
@@ -1034,7 +1062,7 @@ Time O(N log N), Space O(N)
1034
1062
  peek(): E | undefined;
1035
1063
  ```
1036
1064
 
1037
- Defined in: [data-structures/heap/heap.ts:579](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L579)
1065
+ Defined in: [data-structures/heap/heap.ts:635](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L635)
1038
1066
 
1039
1067
  Get the current top element without removing it.
1040
1068
 
@@ -1119,28 +1147,23 @@ Time O(1), Space O(1)
1119
1147
 
1120
1148
  ***
1121
1149
 
1122
- ### poll()
1150
+ ### ~~poll()~~
1123
1151
 
1124
1152
  ```ts
1125
1153
  poll(): E | undefined;
1126
1154
  ```
1127
1155
 
1128
- Defined in: [data-structures/heap/heap.ts:468](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L468)
1129
-
1130
- Remove and return the top element.
1156
+ Defined in: [data-structures/heap/heap.ts:511](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L511)
1131
1157
 
1132
1158
  #### Returns
1133
1159
 
1134
1160
  `E` \| `undefined`
1135
1161
 
1136
- Top element or undefined.
1162
+ #### Deprecated
1137
1163
 
1164
+ Use `pop` instead. Will be removed in a future major version.
1138
1165
  *
1139
1166
 
1140
- #### Remarks
1141
-
1142
- Time O(log N), Space O(1)
1143
-
1144
1167
  #### Example
1145
1168
 
1146
1169
  ```ts
@@ -1176,13 +1199,39 @@ Time O(log N), Space O(1)
1176
1199
 
1177
1200
  ***
1178
1201
 
1202
+ ### pop()
1203
+
1204
+ ```ts
1205
+ pop(): E | undefined;
1206
+ ```
1207
+
1208
+ Defined in: [data-structures/heap/heap.ts:520](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L520)
1209
+
1210
+ Remove and return the top element (min or max depending on comparator).
1211
+
1212
+ #### Returns
1213
+
1214
+ `E` \| `undefined`
1215
+
1216
+ The removed top element, or undefined if empty.
1217
+
1218
+ #### Remarks
1219
+
1220
+ Time O(log N) amortized, Space O(1)
1221
+
1222
+ #### Inherited from
1223
+
1224
+ [`Heap`](Heap.md).[`pop`](Heap.md#pop)
1225
+
1226
+ ***
1227
+
1179
1228
  ### print()
1180
1229
 
1181
1230
  ```ts
1182
1231
  print(): void;
1183
1232
  ```
1184
1233
 
1185
- 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)
1234
+ Defined in: [data-structures/base/iterable-element-base.ts:269](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L269)
1186
1235
 
1187
1236
  Prints `toVisual()` to the console. Intended for quick debugging.
1188
1237
 
@@ -1240,7 +1289,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
1240
1289
  reduce(callbackfn): E;
1241
1290
  ```
1242
1291
 
1243
- 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)
1292
+ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L194)
1244
1293
 
1245
1294
  ##### Parameters
1246
1295
 
@@ -1262,7 +1311,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
1262
1311
  reduce(callbackfn, initialValue): E;
1263
1312
  ```
1264
1313
 
1265
- 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)
1314
+ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L195)
1266
1315
 
1267
1316
  ##### Parameters
1268
1317
 
@@ -1288,7 +1337,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
1288
1337
  reduce<U>(callbackfn, initialValue): U;
1289
1338
  ```
1290
1339
 
1291
- 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)
1340
+ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L196)
1292
1341
 
1293
1342
  ##### Type Parameters
1294
1343
 
@@ -1316,47 +1365,13 @@ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.c
1316
1365
 
1317
1366
  ***
1318
1367
 
1319
- ### refill()
1320
-
1321
- ```ts
1322
- refill(elements): boolean[];
1323
- ```
1324
-
1325
- Defined in: [data-structures/heap/heap.ts:687](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L687)
1326
-
1327
- Replace the backing array and rebuild the heap.
1328
-
1329
- #### Parameters
1330
-
1331
- ##### elements
1332
-
1333
- `Iterable`\<`E`\>
1334
-
1335
- Iterable used to refill the heap.
1336
-
1337
- #### Returns
1338
-
1339
- `boolean`[]
1340
-
1341
- Array of per-node results from fixing steps.
1342
-
1343
- #### Remarks
1344
-
1345
- Time O(N), Space O(N)
1346
-
1347
- #### Inherited from
1348
-
1349
- [`Heap`](Heap.md).[`refill`](Heap.md#refill)
1350
-
1351
- ***
1352
-
1353
1368
  ### setEquality()
1354
1369
 
1355
1370
  ```ts
1356
1371
  setEquality(equals): this;
1357
1372
  ```
1358
1373
 
1359
- Defined in: [data-structures/heap/heap.ts:835](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L835)
1374
+ Defined in: [data-structures/heap/heap.ts:903](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L903)
1360
1375
 
1361
1376
  Set the equality comparator used by has/delete operations.
1362
1377
 
@@ -1390,7 +1405,7 @@ Time O(1), Space O(1)
1390
1405
  some(predicate, thisArg?): boolean;
1391
1406
  ```
1392
1407
 
1393
- 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)
1408
+ 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)
1394
1409
 
1395
1410
  Tests whether at least one element satisfies the predicate.
1396
1411
 
@@ -1430,7 +1445,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
1430
1445
  sort(): E[];
1431
1446
  ```
1432
1447
 
1433
- Defined in: [data-structures/heap/heap.ts:963](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L963)
1448
+ Defined in: [data-structures/heap/heap.ts:1039](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1039)
1434
1449
 
1435
1450
  Return all elements in ascending order by repeatedly polling.
1436
1451
 
@@ -1467,7 +1482,7 @@ Time O(N log N), Space O(N)
1467
1482
  toArray(): E[];
1468
1483
  ```
1469
1484
 
1470
- 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)
1485
+ Defined in: [data-structures/base/iterable-element-base.ts:246](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L246)
1471
1486
 
1472
1487
  Materializes the elements into a new array.
1473
1488
 
@@ -1493,7 +1508,7 @@ Time O(n), Space O(n).
1493
1508
  toVisual(): E[];
1494
1509
  ```
1495
1510
 
1496
- 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)
1511
+ Defined in: [data-structures/base/iterable-element-base.ts:258](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L258)
1497
1512
 
1498
1513
  Returns a representation of the structure suitable for quick visualization.
1499
1514
  Defaults to an array of elements; subclasses may override to provide richer visuals.
@@ -1520,7 +1535,7 @@ Time O(n), Space O(n).
1520
1535
  values(): IterableIterator<E>;
1521
1536
  ```
1522
1537
 
1523
- 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)
1538
+ 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)
1524
1539
 
1525
1540
  Returns an iterator over the values (alias of the default iterator).
1526
1541
 
@@ -1549,7 +1564,7 @@ static from<T, R, S>(
1549
1564
  options?): S;
1550
1565
  ```
1551
1566
 
1552
- Defined in: [data-structures/heap/heap.ts:259](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L259)
1567
+ Defined in: [data-structures/heap/heap.ts:263](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L263)
1553
1568
 
1554
1569
  Create a heap of the same class from an iterable.
1555
1570
 
@@ -1607,7 +1622,7 @@ Time O(N), Space O(N)
1607
1622
  static heapify<EE, RR>(elements, options): Heap<EE, RR>;
1608
1623
  ```
1609
1624
 
1610
- Defined in: [data-structures/heap/heap.ts:277](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L277)
1625
+ Defined in: [data-structures/heap/heap.ts:281](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L281)
1611
1626
 
1612
1627
  Build a Heap from an iterable in linear time given a comparator.
1613
1628
 
@@ -1660,7 +1675,7 @@ Time O(N), Space O(N)
1660
1675
  protected optional _toElementFn?: (rawElement) => E;
1661
1676
  ```
1662
1677
 
1663
- 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)
1678
+ 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)
1664
1679
 
1665
1680
  The converter used to transform a raw element (`R`) into a public element (`E`).
1666
1681
 
@@ -1690,7 +1705,7 @@ Time O(1), Space O(1).
1690
1705
  protected _createInstance(options?): this;
1691
1706
  ```
1692
1707
 
1693
- Defined in: [data-structures/heap/heap.ts:1230](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1230)
1708
+ Defined in: [data-structures/heap/heap.ts:1318](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1318)
1694
1709
 
1695
1710
  (Protected) Create an empty instance of the same concrete class.
1696
1711
 
@@ -1724,7 +1739,7 @@ Time O(1), Space O(1)
1724
1739
  protected _createLike<EM, RM>(elements?, options?): Heap<EM, RM>;
1725
1740
  ```
1726
1741
 
1727
- Defined in: [data-structures/heap/heap.ts:1248](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1248)
1742
+ Defined in: [data-structures/heap/heap.ts:1336](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1336)
1728
1743
 
1729
1744
  (Protected) Create a like-kind instance seeded by elements.
1730
1745
 
@@ -1774,7 +1789,7 @@ Time O(N log N), Space O(N)
1774
1789
  protected _getIterator(): IterableIterator<E>;
1775
1790
  ```
1776
1791
 
1777
- Defined in: [data-structures/heap/heap.ts:1188](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1188)
1792
+ Defined in: [data-structures/heap/heap.ts:1276](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1276)
1778
1793
 
1779
1794
  Internal iterator factory used by the default iterator.
1780
1795
 
@@ -1800,7 +1815,7 @@ Implementations should yield in O(1) per element with O(1) extra space when poss
1800
1815
  protected _spawnLike<EM, RM>(options?): Heap<EM, RM>;
1801
1816
  ```
1802
1817
 
1803
- Defined in: [data-structures/heap/heap.ts:1268](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1268)
1818
+ Defined in: [data-structures/heap/heap.ts:1356](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1356)
1804
1819
 
1805
1820
  (Protected) Spawn an empty like-kind heap instance.
1806
1821