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,7 +6,7 @@
6
6
 
7
7
  # Class: MinHeap\<E, R\>
8
8
 
9
- Defined in: [data-structures/heap/min-heap.ts:86](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/min-heap.ts#L86)
9
+ Defined in: [data-structures/heap/min-heap.ts:86](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/min-heap.ts#L86)
10
10
 
11
11
  ## Examples
12
12
 
@@ -110,7 +110,7 @@ Notes and typical use-cases are documented in [Heap](Heap.md).
110
110
  new MinHeap<E, R>(elements?, options?): MinHeap<E, R>;
111
111
  ```
112
112
 
113
- Defined in: [data-structures/heap/min-heap.ts:92](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/min-heap.ts#L92)
113
+ Defined in: [data-structures/heap/min-heap.ts:92](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/min-heap.ts#L92)
114
114
 
115
115
  Create a min-heap.
116
116
 
@@ -146,7 +146,7 @@ Optional configuration.
146
146
  get comparator(): Comparator<E>;
147
147
  ```
148
148
 
149
- Defined in: [data-structures/heap/heap.ts:1184](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1184)
149
+ Defined in: [data-structures/heap/heap.ts:1272](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1272)
150
150
 
151
151
  Get the comparator used to order elements.
152
152
 
@@ -174,7 +174,7 @@ Comparator function.
174
174
  get elements(): E[];
175
175
  ```
176
176
 
177
- Defined in: [data-structures/heap/heap.ts:180](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L180)
177
+ Defined in: [data-structures/heap/heap.ts:180](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L180)
178
178
 
179
179
  Get the backing array of the heap.
180
180
 
@@ -202,7 +202,7 @@ Internal elements array.
202
202
  get leaf(): E | undefined;
203
203
  ```
204
204
 
205
- Defined in: [data-structures/heap/heap.ts:244](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L244)
205
+ Defined in: [data-structures/heap/heap.ts:248](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L248)
206
206
 
207
207
  Get the last leaf element.
208
208
 
@@ -230,7 +230,7 @@ Last element or undefined.
230
230
  get size(): number;
231
231
  ```
232
232
 
233
- Defined in: [data-structures/heap/heap.ts:234](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L234)
233
+ Defined in: [data-structures/heap/heap.ts:238](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L238)
234
234
 
235
235
  Get the number of elements.
236
236
 
@@ -273,7 +273,7 @@ Heap size.
273
273
  get toElementFn(): ((rawElement) => E) | undefined;
274
274
  ```
275
275
 
276
- 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)
276
+ 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)
277
277
 
278
278
  Exposes the current `toElementFn`, if configured.
279
279
 
@@ -299,7 +299,7 @@ The converter function or `undefined` when not set.
299
299
  iterator: IterableIterator<E>;
300
300
  ```
301
301
 
302
- 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)
302
+ 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)
303
303
 
304
304
  Returns an iterator over the structure's elements.
305
305
 
@@ -333,7 +333,7 @@ Producing the iterator is O(1); consuming the entire iterator is Time O(n) with
333
333
  add(element): boolean;
334
334
  ```
335
335
 
336
- Defined in: [data-structures/heap/heap.ts:338](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L338)
336
+ Defined in: [data-structures/heap/heap.ts:346](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L346)
337
337
 
338
338
  Insert an element.
339
339
 
@@ -355,7 +355,7 @@ True.
355
355
 
356
356
  #### Remarks
357
357
 
358
- Time O(1) amortized, Space O(1)
358
+ Time O(log N) amortized, Space O(1)
359
359
 
360
360
  #### Example
361
361
 
@@ -388,7 +388,7 @@ Time O(1) amortized, Space O(1)
388
388
  addMany(elements): boolean[];
389
389
  ```
390
390
 
391
- Defined in: [data-structures/heap/heap.ts:388](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L388)
391
+ Defined in: [data-structures/heap/heap.ts:400](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L400)
392
392
 
393
393
  Insert many elements from an iterable.
394
394
 
@@ -434,7 +434,7 @@ Time O(N log N), Space O(1)
434
434
  clear(): void;
435
435
  ```
436
436
 
437
- Defined in: [data-structures/heap/heap.ts:676](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L676)
437
+ Defined in: [data-structures/heap/heap.ts:740](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L740)
438
438
 
439
439
  Remove all elements.
440
440
 
@@ -471,7 +471,7 @@ Time O(1), Space O(1)
471
471
  clone(): this;
472
472
  ```
473
473
 
474
- Defined in: [data-structures/heap/heap.ts:1020](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1020)
474
+ Defined in: [data-structures/heap/heap.ts:1100](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1100)
475
475
 
476
476
  Deep clone this heap.
477
477
 
@@ -510,7 +510,7 @@ Time O(N), Space O(N)
510
510
  delete(element): boolean;
511
511
  ```
512
512
 
513
- Defined in: [data-structures/heap/heap.ts:779](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L779)
513
+ Defined in: [data-structures/heap/heap.ts:841](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L841)
514
514
 
515
515
  Delete one occurrence of an element.
516
516
 
@@ -549,13 +549,41 @@ Time O(N), Space O(1)
549
549
 
550
550
  ***
551
551
 
552
- ### deleteBy()
552
+ ### ~~deleteBy()~~
553
553
 
554
554
  ```ts
555
555
  deleteBy(predicate): boolean;
556
556
  ```
557
557
 
558
- Defined in: [data-structures/heap/heap.ts:807](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L807)
558
+ Defined in: [data-structures/heap/heap.ts:865](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L865)
559
+
560
+ #### Parameters
561
+
562
+ ##### predicate
563
+
564
+ (`element`, `index`, `heap`) => `boolean`
565
+
566
+ #### Returns
567
+
568
+ `boolean`
569
+
570
+ #### Deprecated
571
+
572
+ Use `deleteWhere` instead. Will be removed in a future major version.
573
+
574
+ #### Inherited from
575
+
576
+ [`Heap`](Heap.md).[`deleteBy`](Heap.md#deleteby)
577
+
578
+ ***
579
+
580
+ ### deleteWhere()
581
+
582
+ ```ts
583
+ deleteWhere(predicate): boolean;
584
+ ```
585
+
586
+ Defined in: [data-structures/heap/heap.ts:875](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L875)
559
587
 
560
588
  Delete the first element that matches a predicate.
561
589
 
@@ -579,7 +607,7 @@ Time O(N), Space O(1)
579
607
 
580
608
  #### Inherited from
581
609
 
582
- [`Heap`](Heap.md).[`deleteBy`](Heap.md#deleteby)
610
+ [`Heap`](Heap.md).[`deleteWhere`](Heap.md#deletewhere)
583
611
 
584
612
  ***
585
613
 
@@ -589,7 +617,7 @@ Time O(N), Space O(1)
589
617
  dfs(order?): E[];
590
618
  ```
591
619
 
592
- Defined in: [data-structures/heap/heap.ts:878](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L878)
620
+ Defined in: [data-structures/heap/heap.ts:950](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L950)
593
621
 
594
622
  Traverse the binary heap as a complete binary tree and collect elements.
595
623
 
@@ -634,7 +662,7 @@ Time O(N), Space O(H)
634
662
  every(predicate, thisArg?): boolean;
635
663
  ```
636
664
 
637
- 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)
665
+ 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)
638
666
 
639
667
  Tests whether all elements satisfy the predicate.
640
668
 
@@ -674,7 +702,7 @@ Time O(n) in the worst case; may exit early when the first failure is found. Spa
674
702
  filter(callback, thisArg?): this;
675
703
  ```
676
704
 
677
- Defined in: [data-structures/heap/heap.ts:1072](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1072)
705
+ Defined in: [data-structures/heap/heap.ts:1156](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1156)
678
706
 
679
707
  Filter elements into a new heap of the same class.
680
708
 
@@ -727,7 +755,7 @@ Time O(N log N), Space O(N)
727
755
  find<S>(predicate, thisArg?): S | undefined;
728
756
  ```
729
757
 
730
- 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)
758
+ 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)
731
759
 
732
760
  Finds the first element that satisfies the predicate and returns it.
733
761
 
@@ -773,7 +801,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
773
801
  find(predicate, thisArg?): E | undefined;
774
802
  ```
775
803
 
776
- 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)
804
+ 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)
777
805
 
778
806
  Finds the first element that satisfies the predicate and returns it.
779
807
 
@@ -815,7 +843,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
815
843
  fix(): boolean[];
816
844
  ```
817
845
 
818
- Defined in: [data-structures/heap/heap.ts:909](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L909)
846
+ Defined in: [data-structures/heap/heap.ts:981](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L981)
819
847
 
820
848
  Restore heap order bottom-up (heapify in-place).
821
849
 
@@ -841,7 +869,7 @@ Time O(N), Space O(1)
841
869
  forEach(callbackfn, thisArg?): void;
842
870
  ```
843
871
 
844
- 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)
872
+ 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)
845
873
 
846
874
  Invokes a callback for each element in iteration order.
847
875
 
@@ -881,7 +909,7 @@ Time O(n), Space O(1).
881
909
  has(element): boolean;
882
910
  ```
883
911
 
884
- Defined in: [data-structures/heap/heap.ts:730](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L730)
912
+ Defined in: [data-structures/heap/heap.ts:788](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L788)
885
913
 
886
914
  Check if an equal element exists in the heap.
887
915
 
@@ -926,7 +954,7 @@ Time O(N), Space O(1)
926
954
  isEmpty(): boolean;
927
955
  ```
928
956
 
929
- Defined in: [data-structures/heap/heap.ts:628](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L628)
957
+ Defined in: [data-structures/heap/heap.ts:688](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L688)
930
958
 
931
959
  Check whether the heap is empty.
932
960
 
@@ -967,7 +995,7 @@ map<EM, RM>(
967
995
  thisArg?): Heap<EM, RM>;
968
996
  ```
969
997
 
970
- Defined in: [data-structures/heap/heap.ts:1133](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1133)
998
+ Defined in: [data-structures/heap/heap.ts:1221](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1221)
971
999
 
972
1000
  Map elements into a new heap of possibly different element type.
973
1001
 
@@ -1034,7 +1062,7 @@ Time O(N log N), Space O(N)
1034
1062
  mapSame(callback, thisArg?): this;
1035
1063
  ```
1036
1064
 
1037
- Defined in: [data-structures/heap/heap.ts:1157](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1157)
1065
+ Defined in: [data-structures/heap/heap.ts:1245](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1245)
1038
1066
 
1039
1067
  Map elements into a new heap of the same element type.
1040
1068
 
@@ -1074,7 +1102,7 @@ Time O(N log N), Space O(N)
1074
1102
  peek(): E | undefined;
1075
1103
  ```
1076
1104
 
1077
- Defined in: [data-structures/heap/heap.ts:579](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L579)
1105
+ Defined in: [data-structures/heap/heap.ts:635](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L635)
1078
1106
 
1079
1107
  Get the current top element without removing it.
1080
1108
 
@@ -1159,28 +1187,23 @@ Time O(1), Space O(1)
1159
1187
 
1160
1188
  ***
1161
1189
 
1162
- ### poll()
1190
+ ### ~~poll()~~
1163
1191
 
1164
1192
  ```ts
1165
1193
  poll(): E | undefined;
1166
1194
  ```
1167
1195
 
1168
- Defined in: [data-structures/heap/heap.ts:468](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L468)
1169
-
1170
- Remove and return the top element.
1196
+ Defined in: [data-structures/heap/heap.ts:511](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L511)
1171
1197
 
1172
1198
  #### Returns
1173
1199
 
1174
1200
  `E` \| `undefined`
1175
1201
 
1176
- Top element or undefined.
1202
+ #### Deprecated
1177
1203
 
1204
+ Use `pop` instead. Will be removed in a future major version.
1178
1205
  *
1179
1206
 
1180
- #### Remarks
1181
-
1182
- Time O(log N), Space O(1)
1183
-
1184
1207
  #### Example
1185
1208
 
1186
1209
  ```ts
@@ -1216,13 +1239,39 @@ Time O(log N), Space O(1)
1216
1239
 
1217
1240
  ***
1218
1241
 
1242
+ ### pop()
1243
+
1244
+ ```ts
1245
+ pop(): E | undefined;
1246
+ ```
1247
+
1248
+ Defined in: [data-structures/heap/heap.ts:520](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L520)
1249
+
1250
+ Remove and return the top element (min or max depending on comparator).
1251
+
1252
+ #### Returns
1253
+
1254
+ `E` \| `undefined`
1255
+
1256
+ The removed top element, or undefined if empty.
1257
+
1258
+ #### Remarks
1259
+
1260
+ Time O(log N) amortized, Space O(1)
1261
+
1262
+ #### Inherited from
1263
+
1264
+ [`Heap`](Heap.md).[`pop`](Heap.md#pop)
1265
+
1266
+ ***
1267
+
1219
1268
  ### print()
1220
1269
 
1221
1270
  ```ts
1222
1271
  print(): void;
1223
1272
  ```
1224
1273
 
1225
- 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)
1274
+ 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)
1226
1275
 
1227
1276
  Prints `toVisual()` to the console. Intended for quick debugging.
1228
1277
 
@@ -1280,7 +1329,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
1280
1329
  reduce(callbackfn): E;
1281
1330
  ```
1282
1331
 
1283
- 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)
1332
+ 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)
1284
1333
 
1285
1334
  ##### Parameters
1286
1335
 
@@ -1302,7 +1351,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
1302
1351
  reduce(callbackfn, initialValue): E;
1303
1352
  ```
1304
1353
 
1305
- 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)
1354
+ 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)
1306
1355
 
1307
1356
  ##### Parameters
1308
1357
 
@@ -1328,7 +1377,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
1328
1377
  reduce<U>(callbackfn, initialValue): U;
1329
1378
  ```
1330
1379
 
1331
- 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)
1380
+ 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)
1332
1381
 
1333
1382
  ##### Type Parameters
1334
1383
 
@@ -1356,47 +1405,13 @@ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.c
1356
1405
 
1357
1406
  ***
1358
1407
 
1359
- ### refill()
1360
-
1361
- ```ts
1362
- refill(elements): boolean[];
1363
- ```
1364
-
1365
- Defined in: [data-structures/heap/heap.ts:687](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L687)
1366
-
1367
- Replace the backing array and rebuild the heap.
1368
-
1369
- #### Parameters
1370
-
1371
- ##### elements
1372
-
1373
- `Iterable`\<`E`\>
1374
-
1375
- Iterable used to refill the heap.
1376
-
1377
- #### Returns
1378
-
1379
- `boolean`[]
1380
-
1381
- Array of per-node results from fixing steps.
1382
-
1383
- #### Remarks
1384
-
1385
- Time O(N), Space O(N)
1386
-
1387
- #### Inherited from
1388
-
1389
- [`Heap`](Heap.md).[`refill`](Heap.md#refill)
1390
-
1391
- ***
1392
-
1393
1408
  ### setEquality()
1394
1409
 
1395
1410
  ```ts
1396
1411
  setEquality(equals): this;
1397
1412
  ```
1398
1413
 
1399
- Defined in: [data-structures/heap/heap.ts:835](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L835)
1414
+ Defined in: [data-structures/heap/heap.ts:903](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L903)
1400
1415
 
1401
1416
  Set the equality comparator used by has/delete operations.
1402
1417
 
@@ -1430,7 +1445,7 @@ Time O(1), Space O(1)
1430
1445
  some(predicate, thisArg?): boolean;
1431
1446
  ```
1432
1447
 
1433
- 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)
1448
+ 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)
1434
1449
 
1435
1450
  Tests whether at least one element satisfies the predicate.
1436
1451
 
@@ -1470,7 +1485,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
1470
1485
  sort(): E[];
1471
1486
  ```
1472
1487
 
1473
- Defined in: [data-structures/heap/heap.ts:963](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L963)
1488
+ Defined in: [data-structures/heap/heap.ts:1039](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1039)
1474
1489
 
1475
1490
  Return all elements in ascending order by repeatedly polling.
1476
1491
 
@@ -1507,7 +1522,7 @@ Time O(N log N), Space O(N)
1507
1522
  toArray(): E[];
1508
1523
  ```
1509
1524
 
1510
- 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)
1525
+ 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)
1511
1526
 
1512
1527
  Materializes the elements into a new array.
1513
1528
 
@@ -1533,7 +1548,7 @@ Time O(n), Space O(n).
1533
1548
  toVisual(): E[];
1534
1549
  ```
1535
1550
 
1536
- 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)
1551
+ 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)
1537
1552
 
1538
1553
  Returns a representation of the structure suitable for quick visualization.
1539
1554
  Defaults to an array of elements; subclasses may override to provide richer visuals.
@@ -1560,7 +1575,7 @@ Time O(n), Space O(n).
1560
1575
  values(): IterableIterator<E>;
1561
1576
  ```
1562
1577
 
1563
- 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)
1578
+ 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)
1564
1579
 
1565
1580
  Returns an iterator over the values (alias of the default iterator).
1566
1581
 
@@ -1589,7 +1604,7 @@ static from<T, R, S>(
1589
1604
  options?): S;
1590
1605
  ```
1591
1606
 
1592
- Defined in: [data-structures/heap/heap.ts:259](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L259)
1607
+ Defined in: [data-structures/heap/heap.ts:263](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L263)
1593
1608
 
1594
1609
  Create a heap of the same class from an iterable.
1595
1610
 
@@ -1647,7 +1662,7 @@ Time O(N), Space O(N)
1647
1662
  static heapify<EE, RR>(elements, options): Heap<EE, RR>;
1648
1663
  ```
1649
1664
 
1650
- Defined in: [data-structures/heap/heap.ts:277](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L277)
1665
+ Defined in: [data-structures/heap/heap.ts:281](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L281)
1651
1666
 
1652
1667
  Build a Heap from an iterable in linear time given a comparator.
1653
1668
 
@@ -1700,7 +1715,7 @@ Time O(N), Space O(N)
1700
1715
  protected optional _toElementFn?: (rawElement) => E;
1701
1716
  ```
1702
1717
 
1703
- 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)
1718
+ 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)
1704
1719
 
1705
1720
  The converter used to transform a raw element (`R`) into a public element (`E`).
1706
1721
 
@@ -1730,7 +1745,7 @@ Time O(1), Space O(1).
1730
1745
  protected _createInstance(options?): this;
1731
1746
  ```
1732
1747
 
1733
- Defined in: [data-structures/heap/heap.ts:1230](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1230)
1748
+ Defined in: [data-structures/heap/heap.ts:1318](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1318)
1734
1749
 
1735
1750
  (Protected) Create an empty instance of the same concrete class.
1736
1751
 
@@ -1764,7 +1779,7 @@ Time O(1), Space O(1)
1764
1779
  protected _createLike<EM, RM>(elements?, options?): Heap<EM, RM>;
1765
1780
  ```
1766
1781
 
1767
- Defined in: [data-structures/heap/heap.ts:1248](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1248)
1782
+ Defined in: [data-structures/heap/heap.ts:1336](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1336)
1768
1783
 
1769
1784
  (Protected) Create a like-kind instance seeded by elements.
1770
1785
 
@@ -1814,7 +1829,7 @@ Time O(N log N), Space O(N)
1814
1829
  protected _getIterator(): IterableIterator<E>;
1815
1830
  ```
1816
1831
 
1817
- Defined in: [data-structures/heap/heap.ts:1188](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1188)
1832
+ Defined in: [data-structures/heap/heap.ts:1276](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1276)
1818
1833
 
1819
1834
  Internal iterator factory used by the default iterator.
1820
1835
 
@@ -1840,7 +1855,7 @@ Implementations should yield in O(1) per element with O(1) extra space when poss
1840
1855
  protected _spawnLike<EM, RM>(options?): Heap<EM, RM>;
1841
1856
  ```
1842
1857
 
1843
- Defined in: [data-structures/heap/heap.ts:1268](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/heap/heap.ts#L1268)
1858
+ Defined in: [data-structures/heap/heap.ts:1356](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1356)
1844
1859
 
1845
1860
  (Protected) Spawn an empty like-kind heap instance.
1846
1861