data-structure-typed 2.6.0 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +7 -2
- package/.github/workflows/release-package.yml +9 -2
- package/docs-site-docusaurus/docs/api/classes/AVLTree.md +108 -108
- package/docs-site-docusaurus/docs/api/classes/BST.md +101 -101
- package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +66 -66
- package/docs-site-docusaurus/docs/api/classes/Deque.md +235 -51
- package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +21 -21
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +231 -67
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +9 -9
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
- package/docs-site-docusaurus/docs/api/classes/HashMap.md +14 -14
- package/docs-site-docusaurus/docs/api/classes/Heap.md +117 -34
- package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +83 -13
- package/docs-site-docusaurus/docs/api/classes/LinearBase.md +124 -20
- package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +140 -32
- package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +23 -23
- package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +159 -51
- package/docs-site-docusaurus/docs/api/classes/MapGraph.md +20 -20
- package/docs-site-docusaurus/docs/api/classes/Matrix.md +23 -23
- package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +117 -34
- package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +117 -34
- package/docs-site-docusaurus/docs/api/classes/MinHeap.md +117 -34
- package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +117 -34
- package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +117 -34
- package/docs-site-docusaurus/docs/api/classes/Queue.md +142 -34
- package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +117 -117
- package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +158 -50
- package/docs-site-docusaurus/docs/api/classes/SkipList.md +21 -21
- package/docs-site-docusaurus/docs/api/classes/Stack.md +108 -26
- package/docs-site-docusaurus/docs/api/classes/TreeMap.md +33 -33
- package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +75 -39
- package/docs-site-docusaurus/docs/api/classes/TreeSet.md +301 -39
- package/docs-site-docusaurus/docs/api/classes/Trie.md +110 -28
- package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +20 -20
- package/package.json +45 -46
- package/src/common/error.ts +15 -32
- package/src/common/index.ts +0 -3
- package/src/data-structures/base/iterable-element-base.ts +0 -3
- package/src/data-structures/base/linear-base.ts +2 -36
- package/src/data-structures/binary-tree/avl-tree.ts +31 -529
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +47 -572
- package/src/data-structures/binary-tree/binary-tree.ts +326 -1311
- package/src/data-structures/binary-tree/bst.ts +158 -1082
- package/src/data-structures/binary-tree/red-black-tree.ts +451 -1290
- package/src/data-structures/binary-tree/segment-tree.ts +73 -351
- package/src/data-structures/binary-tree/tree-map.ts +462 -5124
- package/src/data-structures/binary-tree/tree-multi-map.ts +302 -4914
- package/src/data-structures/binary-tree/tree-multi-set.ts +284 -3972
- package/src/data-structures/binary-tree/tree-set.ts +338 -4836
- package/src/data-structures/graph/abstract-graph.ts +98 -167
- package/src/data-structures/graph/directed-graph.ts +137 -562
- package/src/data-structures/graph/map-graph.ts +0 -3
- package/src/data-structures/graph/undirected-graph.ts +132 -511
- package/src/data-structures/hash/hash-map.ts +154 -582
- package/src/data-structures/heap/heap.ts +200 -795
- package/src/data-structures/linked-list/doubly-linked-list.ts +121 -865
- package/src/data-structures/linked-list/singly-linked-list.ts +122 -794
- package/src/data-structures/linked-list/skip-linked-list.ts +211 -918
- package/src/data-structures/matrix/matrix.ts +179 -518
- package/src/data-structures/matrix/navigator.ts +0 -1
- package/src/data-structures/priority-queue/max-priority-queue.ts +1 -6
- package/src/data-structures/priority-queue/min-priority-queue.ts +6 -11
- package/src/data-structures/priority-queue/priority-queue.ts +1 -2
- package/src/data-structures/queue/deque.ts +214 -882
- package/src/data-structures/queue/queue.ts +102 -625
- package/src/data-structures/stack/stack.ts +76 -505
- package/src/data-structures/trie/trie.ts +98 -628
- package/src/types/common.ts +0 -10
- package/src/types/data-structures/binary-tree/bst.ts +0 -7
- package/src/types/data-structures/binary-tree/red-black-tree.ts +0 -1
- package/src/types/data-structures/graph/abstract-graph.ts +0 -2
- package/src/types/data-structures/hash/hash-map.ts +0 -3
- package/src/types/data-structures/hash/index.ts +0 -1
- package/src/types/data-structures/matrix/navigator.ts +0 -2
- package/src/types/utils/utils.ts +0 -7
- package/src/types/utils/validate-type.ts +0 -7
- package/src/utils/number.ts +0 -2
- package/src/utils/utils.ts +0 -5
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: FibonacciHeap\<E\>
|
|
8
8
|
|
|
9
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
9
|
+
Defined in: [data-structures/heap/heap.ts:1430](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1430)
|
|
10
10
|
|
|
11
11
|
Fibonacci heap (min-heap) optimized for fast merges and amortized operations.
|
|
12
12
|
|
|
@@ -34,7 +34,7 @@ examples will be generated by unit test
|
|
|
34
34
|
new FibonacciHeap<E>(comparator?): FibonacciHeap<E>;
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
37
|
+
Defined in: [data-structures/heap/heap.ts:1438](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1438)
|
|
38
38
|
|
|
39
39
|
Create a FibonacciHeap.
|
|
40
40
|
|
|
@@ -66,7 +66,7 @@ Time O(1), Space O(1)
|
|
|
66
66
|
get min(): FibonacciHeapNode<E> | undefined;
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
69
|
+
Defined in: [data-structures/heap/heap.ts:1469](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1469)
|
|
70
70
|
|
|
71
71
|
Get the current minimum node.
|
|
72
72
|
|
|
@@ -90,7 +90,7 @@ Min node or undefined.
|
|
|
90
90
|
get root(): FibonacciHeapNode<E> | undefined;
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
93
|
+
Defined in: [data-structures/heap/heap.ts:1452](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1452)
|
|
94
94
|
|
|
95
95
|
Get the circular root list head.
|
|
96
96
|
|
|
@@ -112,7 +112,7 @@ Root node or undefined.
|
|
|
112
112
|
consumeLinkedList(head?): FibonacciHeapNode<E>[];
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
115
|
+
Defined in: [data-structures/heap/heap.ts:1518](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1518)
|
|
116
116
|
|
|
117
117
|
Collect nodes from a circular doubly linked list starting at head.
|
|
118
118
|
|
|
@@ -142,7 +142,7 @@ Time O(K), Space O(K)
|
|
|
142
142
|
merge(heapToMerge): void;
|
|
143
143
|
```
|
|
144
144
|
|
|
145
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
145
|
+
Defined in: [data-structures/heap/heap.ts:1589](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1589)
|
|
146
146
|
|
|
147
147
|
Meld another heap into this heap.
|
|
148
148
|
|
|
@@ -172,7 +172,7 @@ Time O(1), Space O(1)
|
|
|
172
172
|
mergeWithChild(parent, node): void;
|
|
173
173
|
```
|
|
174
174
|
|
|
175
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
175
|
+
Defined in: [data-structures/heap/heap.ts:1540](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1540)
|
|
176
176
|
|
|
177
177
|
Insert a node into a parent's child list (circular).
|
|
178
178
|
|
|
@@ -208,7 +208,7 @@ Time O(1), Space O(1)
|
|
|
208
208
|
pop(): E | undefined;
|
|
209
209
|
```
|
|
210
210
|
|
|
211
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
211
|
+
Defined in: [data-structures/heap/heap.ts:1560](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1560)
|
|
212
212
|
|
|
213
213
|
Remove and return the minimum element, consolidating the root list.
|
|
214
214
|
|
|
@@ -230,7 +230,7 @@ Time O(log N) amortized, Space O(1)
|
|
|
230
230
|
push(element): boolean;
|
|
231
231
|
```
|
|
232
232
|
|
|
233
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
233
|
+
Defined in: [data-structures/heap/heap.ts:1497](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1497)
|
|
234
234
|
|
|
235
235
|
Push an element into the root list.
|
|
236
236
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: FibonacciHeapNode\<E\>
|
|
8
8
|
|
|
9
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
9
|
+
Defined in: [data-structures/heap/heap.ts:1408](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1408)
|
|
10
10
|
|
|
11
11
|
Node container used by FibonacciHeap.
|
|
12
12
|
|
|
@@ -317,7 +317,7 @@ Time O(n) to iterate, Space O(1)
|
|
|
317
317
|
clear(): void;
|
|
318
318
|
```
|
|
319
319
|
|
|
320
|
-
Defined in: [data-structures/hash/hash-map.ts:
|
|
320
|
+
Defined in: [data-structures/hash/hash-map.ts:273](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/hash/hash-map.ts#L273)
|
|
321
321
|
|
|
322
322
|
Remove all entries and reset counters.
|
|
323
323
|
|
|
@@ -354,7 +354,7 @@ Time O(N), Space O(1)
|
|
|
354
354
|
clone(): this;
|
|
355
355
|
```
|
|
356
356
|
|
|
357
|
-
Defined in: [data-structures/hash/hash-map.ts:
|
|
357
|
+
Defined in: [data-structures/hash/hash-map.ts:743](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/hash/hash-map.ts#L743)
|
|
358
358
|
|
|
359
359
|
Deep clone this map, preserving hashing behavior.
|
|
360
360
|
|
|
@@ -392,7 +392,7 @@ Time O(N), Space O(N)
|
|
|
392
392
|
delete(key): boolean;
|
|
393
393
|
```
|
|
394
394
|
|
|
395
|
-
Defined in: [data-structures/hash/hash-map.ts:
|
|
395
|
+
Defined in: [data-structures/hash/hash-map.ts:665](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/hash/hash-map.ts#L665)
|
|
396
396
|
|
|
397
397
|
Delete an entry by key.
|
|
398
398
|
|
|
@@ -501,7 +501,7 @@ Time O(n), Space O(1)
|
|
|
501
501
|
filter(predicate, thisArg?): this;
|
|
502
502
|
```
|
|
503
503
|
|
|
504
|
-
Defined in: [data-structures/hash/hash-map.ts:
|
|
504
|
+
Defined in: [data-structures/hash/hash-map.ts:887](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/hash/hash-map.ts#L887)
|
|
505
505
|
|
|
506
506
|
Filter entries into a new map.
|
|
507
507
|
|
|
@@ -650,7 +650,7 @@ Time O(n), Space O(1)
|
|
|
650
650
|
get(key): V | undefined;
|
|
651
651
|
```
|
|
652
652
|
|
|
653
|
-
Defined in: [data-structures/hash/hash-map.ts:
|
|
653
|
+
Defined in: [data-structures/hash/hash-map.ts:544](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/hash/hash-map.ts#L544)
|
|
654
654
|
|
|
655
655
|
Get the value for a key.
|
|
656
656
|
|
|
@@ -711,7 +711,7 @@ Time O(1), Space O(1)
|
|
|
711
711
|
has(key): boolean;
|
|
712
712
|
```
|
|
713
713
|
|
|
714
|
-
Defined in: [data-structures/hash/hash-map.ts:
|
|
714
|
+
Defined in: [data-structures/hash/hash-map.ts:604](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/hash/hash-map.ts#L604)
|
|
715
715
|
|
|
716
716
|
Check if a key exists.
|
|
717
717
|
|
|
@@ -791,7 +791,7 @@ Time O(n), Space O(1)
|
|
|
791
791
|
isEmpty(): boolean;
|
|
792
792
|
```
|
|
793
793
|
|
|
794
|
-
Defined in: [data-structures/hash/hash-map.ts:
|
|
794
|
+
Defined in: [data-structures/hash/hash-map.ts:219](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/hash/hash-map.ts#L219)
|
|
795
795
|
|
|
796
796
|
Check whether the map is empty.
|
|
797
797
|
|
|
@@ -827,7 +827,7 @@ Time O(1), Space O(1)
|
|
|
827
827
|
isEntry(rawElement): rawElement is [K, V];
|
|
828
828
|
```
|
|
829
829
|
|
|
830
|
-
Defined in: [data-structures/hash/hash-map.ts:
|
|
830
|
+
Defined in: [data-structures/hash/hash-map.ts:284](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/hash/hash-map.ts#L284)
|
|
831
831
|
|
|
832
832
|
Type guard: check if a raw value is a [key, value] entry.
|
|
833
833
|
|
|
@@ -881,7 +881,7 @@ Time O(n), Space O(1)
|
|
|
881
881
|
map<VM>(callbackfn, thisArg?): HashMap<K, VM>;
|
|
882
882
|
```
|
|
883
883
|
|
|
884
|
-
Defined in: [data-structures/hash/hash-map.ts:
|
|
884
|
+
Defined in: [data-structures/hash/hash-map.ts:805](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/hash/hash-map.ts#L805)
|
|
885
885
|
|
|
886
886
|
Map values to a new map with the same keys.
|
|
887
887
|
|
|
@@ -1010,7 +1010,7 @@ Time O(n), Space O(1)
|
|
|
1010
1010
|
set(key, value): this;
|
|
1011
1011
|
```
|
|
1012
1012
|
|
|
1013
|
-
Defined in: [data-structures/hash/hash-map.ts:
|
|
1013
|
+
Defined in: [data-structures/hash/hash-map.ts:397](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/hash/hash-map.ts#L397)
|
|
1014
1014
|
|
|
1015
1015
|
Insert or replace a single entry.
|
|
1016
1016
|
|
|
@@ -1070,7 +1070,7 @@ Time O(1), Space O(1)
|
|
|
1070
1070
|
setHashFn(fn): this;
|
|
1071
1071
|
```
|
|
1072
1072
|
|
|
1073
|
-
Defined in: [data-structures/hash/hash-map.ts:
|
|
1073
|
+
Defined in: [data-structures/hash/hash-map.ts:685](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/hash/hash-map.ts#L685)
|
|
1074
1074
|
|
|
1075
1075
|
Replace the hash function and rehash the non-object store.
|
|
1076
1076
|
|
|
@@ -1100,7 +1100,7 @@ Time O(N), Space O(N)
|
|
|
1100
1100
|
setMany(entryOrRawElements): boolean[];
|
|
1101
1101
|
```
|
|
1102
1102
|
|
|
1103
|
-
Defined in: [data-structures/hash/hash-map.ts:
|
|
1103
|
+
Defined in: [data-structures/hash/hash-map.ts:460](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/hash/hash-map.ts#L460)
|
|
1104
1104
|
|
|
1105
1105
|
Insert many entries from an iterable.
|
|
1106
1106
|
|
|
@@ -1262,7 +1262,7 @@ Time O(n), Space O(1)
|
|
|
1262
1262
|
protected _createLike<TK, TV, TR>(entries?, options?): this;
|
|
1263
1263
|
```
|
|
1264
1264
|
|
|
1265
|
-
Defined in: [data-structures/hash/hash-map.ts:
|
|
1265
|
+
Defined in: [data-structures/hash/hash-map.ts:904](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/hash/hash-map.ts#L904)
|
|
1266
1266
|
|
|
1267
1267
|
(Protected) Create a like-kind instance and seed it from an iterable.
|
|
1268
1268
|
|
|
@@ -1312,7 +1312,7 @@ Time O(N), Space O(N)
|
|
|
1312
1312
|
protected _getIterator(): IterableIterator<[K, V]>;
|
|
1313
1313
|
```
|
|
1314
1314
|
|
|
1315
|
-
Defined in: [data-structures/hash/hash-map.ts:
|
|
1315
|
+
Defined in: [data-structures/hash/hash-map.ts:918](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/hash/hash-map.ts#L918)
|
|
1316
1316
|
|
|
1317
1317
|
Underlying iterator for the default iteration protocol.
|
|
1318
1318
|
|
|
@@ -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:
|
|
231
|
+
Defined in: [data-structures/heap/heap.ts:1314](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1314)
|
|
232
232
|
|
|
233
233
|
Get the comparator used to order elements.
|
|
234
234
|
|
|
@@ -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:
|
|
279
|
+
Defined in: [data-structures/heap/heap.ts:251](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L251)
|
|
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:
|
|
303
|
+
Defined in: [data-structures/heap/heap.ts:241](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L241)
|
|
304
304
|
|
|
305
305
|
Get the number of elements.
|
|
306
306
|
|
|
@@ -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:
|
|
402
|
+
Defined in: [data-structures/heap/heap.ts:352](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L352)
|
|
403
403
|
|
|
404
404
|
Insert an element.
|
|
405
405
|
|
|
@@ -450,7 +450,7 @@ Time O(log N) amortized, Space O(1)
|
|
|
450
450
|
addMany(elements): boolean[];
|
|
451
451
|
```
|
|
452
452
|
|
|
453
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
453
|
+
Defined in: [data-structures/heap/heap.ts:409](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L409)
|
|
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:
|
|
495
|
+
Defined in: [data-structures/heap/heap.ts:761](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L761)
|
|
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:
|
|
532
|
+
Defined in: [data-structures/heap/heap.ts:1136](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1136)
|
|
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:
|
|
571
|
+
Defined in: [data-structures/heap/heap.ts:868](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L868)
|
|
572
572
|
|
|
573
573
|
Delete one occurrence of an element.
|
|
574
574
|
|
|
@@ -609,7 +609,7 @@ Time O(N), Space O(1)
|
|
|
609
609
|
deleteBy(predicate): boolean;
|
|
610
610
|
```
|
|
611
611
|
|
|
612
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
612
|
+
Defined in: [data-structures/heap/heap.ts:892](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L892)
|
|
613
613
|
|
|
614
614
|
#### Parameters
|
|
615
615
|
|
|
@@ -633,7 +633,7 @@ Use `deleteWhere` instead. Will be removed in a future major version.
|
|
|
633
633
|
deleteWhere(predicate): boolean;
|
|
634
634
|
```
|
|
635
635
|
|
|
636
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
636
|
+
Defined in: [data-structures/heap/heap.ts:902](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L902)
|
|
637
637
|
|
|
638
638
|
Delete the first element that matches a predicate.
|
|
639
639
|
|
|
@@ -663,7 +663,7 @@ Time O(N), Space O(1)
|
|
|
663
663
|
dfs(order?): E[];
|
|
664
664
|
```
|
|
665
665
|
|
|
666
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
666
|
+
Defined in: [data-structures/heap/heap.ts:980](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L980)
|
|
667
667
|
|
|
668
668
|
Traverse the binary heap as a complete binary tree and collect elements.
|
|
669
669
|
|
|
@@ -698,6 +698,30 @@ Time O(N), Space O(H)
|
|
|
698
698
|
|
|
699
699
|
***
|
|
700
700
|
|
|
701
|
+
### entries()
|
|
702
|
+
|
|
703
|
+
```ts
|
|
704
|
+
entries(): IterableIterator<[number, E]>;
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
Defined in: [data-structures/base/iterable-element-base.ts:208](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L208)
|
|
708
|
+
|
|
709
|
+
Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
710
|
+
|
|
711
|
+
#### Returns
|
|
712
|
+
|
|
713
|
+
`IterableIterator`\<\[`number`, `E`\]\>
|
|
714
|
+
|
|
715
|
+
#### Remarks
|
|
716
|
+
|
|
717
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
718
|
+
|
|
719
|
+
#### Inherited from
|
|
720
|
+
|
|
721
|
+
[`IterableElementBase`](IterableElementBase.md).[`entries`](IterableElementBase.md#entries)
|
|
722
|
+
|
|
723
|
+
***
|
|
724
|
+
|
|
701
725
|
### every()
|
|
702
726
|
|
|
703
727
|
```ts
|
|
@@ -744,7 +768,7 @@ Time O(n) in the worst case; may exit early when the first failure is found. Spa
|
|
|
744
768
|
filter(callback, thisArg?): this;
|
|
745
769
|
```
|
|
746
770
|
|
|
747
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
771
|
+
Defined in: [data-structures/heap/heap.ts:1195](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1195)
|
|
748
772
|
|
|
749
773
|
Filter elements into a new heap of the same class.
|
|
750
774
|
|
|
@@ -885,7 +909,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
|
885
909
|
fix(): boolean[];
|
|
886
910
|
```
|
|
887
911
|
|
|
888
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
912
|
+
Defined in: [data-structures/heap/heap.ts:1011](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1011)
|
|
889
913
|
|
|
890
914
|
Restore heap order bottom-up (heapify in-place).
|
|
891
915
|
|
|
@@ -947,7 +971,7 @@ Time O(n), Space O(1).
|
|
|
947
971
|
has(element): boolean;
|
|
948
972
|
```
|
|
949
973
|
|
|
950
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
974
|
+
Defined in: [data-structures/heap/heap.ts:812](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L812)
|
|
951
975
|
|
|
952
976
|
Check if an equal element exists in the heap.
|
|
953
977
|
|
|
@@ -986,13 +1010,47 @@ Time O(N), Space O(1)
|
|
|
986
1010
|
|
|
987
1011
|
***
|
|
988
1012
|
|
|
1013
|
+
### includes()
|
|
1014
|
+
|
|
1015
|
+
```ts
|
|
1016
|
+
includes(element): boolean;
|
|
1017
|
+
```
|
|
1018
|
+
|
|
1019
|
+
Defined in: [data-structures/base/iterable-element-base.ts:200](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L200)
|
|
1020
|
+
|
|
1021
|
+
Check whether a value exists (Array-compatible alias for `has`).
|
|
1022
|
+
|
|
1023
|
+
#### Parameters
|
|
1024
|
+
|
|
1025
|
+
##### element
|
|
1026
|
+
|
|
1027
|
+
`E`
|
|
1028
|
+
|
|
1029
|
+
Element to search for (uses `===`).
|
|
1030
|
+
|
|
1031
|
+
#### Returns
|
|
1032
|
+
|
|
1033
|
+
`boolean`
|
|
1034
|
+
|
|
1035
|
+
`true` if found.
|
|
1036
|
+
|
|
1037
|
+
#### Remarks
|
|
1038
|
+
|
|
1039
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
1040
|
+
|
|
1041
|
+
#### Inherited from
|
|
1042
|
+
|
|
1043
|
+
[`IterableElementBase`](IterableElementBase.md).[`includes`](IterableElementBase.md#includes)
|
|
1044
|
+
|
|
1045
|
+
***
|
|
1046
|
+
|
|
989
1047
|
### isEmpty()
|
|
990
1048
|
|
|
991
1049
|
```ts
|
|
992
1050
|
isEmpty(): boolean;
|
|
993
1051
|
```
|
|
994
1052
|
|
|
995
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1053
|
+
Defined in: [data-structures/heap/heap.ts:706](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L706)
|
|
996
1054
|
|
|
997
1055
|
Check whether the heap is empty.
|
|
998
1056
|
|
|
@@ -1024,6 +1082,30 @@ Time O(1), Space O(1)
|
|
|
1024
1082
|
|
|
1025
1083
|
***
|
|
1026
1084
|
|
|
1085
|
+
### keys()
|
|
1086
|
+
|
|
1087
|
+
```ts
|
|
1088
|
+
keys(): IterableIterator<number>;
|
|
1089
|
+
```
|
|
1090
|
+
|
|
1091
|
+
Defined in: [data-structures/base/iterable-element-base.ts:219](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L219)
|
|
1092
|
+
|
|
1093
|
+
Return an iterator of numeric indices (Array-compatible).
|
|
1094
|
+
|
|
1095
|
+
#### Returns
|
|
1096
|
+
|
|
1097
|
+
`IterableIterator`\<`number`\>
|
|
1098
|
+
|
|
1099
|
+
#### Remarks
|
|
1100
|
+
|
|
1101
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
1102
|
+
|
|
1103
|
+
#### Inherited from
|
|
1104
|
+
|
|
1105
|
+
[`IterableElementBase`](IterableElementBase.md).[`keys`](IterableElementBase.md#keys)
|
|
1106
|
+
|
|
1107
|
+
***
|
|
1108
|
+
|
|
1027
1109
|
### map()
|
|
1028
1110
|
|
|
1029
1111
|
```ts
|
|
@@ -1033,7 +1115,7 @@ map<EM, RM>(
|
|
|
1033
1115
|
thisArg?): Heap<EM, RM>;
|
|
1034
1116
|
```
|
|
1035
1117
|
|
|
1036
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1118
|
+
Defined in: [data-structures/heap/heap.ts:1263](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1263)
|
|
1037
1119
|
|
|
1038
1120
|
Map elements into a new heap of possibly different element type.
|
|
1039
1121
|
|
|
@@ -1100,7 +1182,7 @@ Time O(N log N), Space O(N)
|
|
|
1100
1182
|
mapSame(callback, thisArg?): this;
|
|
1101
1183
|
```
|
|
1102
1184
|
|
|
1103
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1185
|
+
Defined in: [data-structures/heap/heap.ts:1287](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1287)
|
|
1104
1186
|
|
|
1105
1187
|
Map elements into a new heap of the same element type.
|
|
1106
1188
|
|
|
@@ -1140,7 +1222,7 @@ Time O(N log N), Space O(N)
|
|
|
1140
1222
|
peek(): E | undefined;
|
|
1141
1223
|
```
|
|
1142
1224
|
|
|
1143
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1225
|
+
Defined in: [data-structures/heap/heap.ts:650](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L650)
|
|
1144
1226
|
|
|
1145
1227
|
Get the current top element without removing it.
|
|
1146
1228
|
|
|
@@ -1227,7 +1309,7 @@ Time O(1), Space O(1)
|
|
|
1227
1309
|
poll(): E | undefined;
|
|
1228
1310
|
```
|
|
1229
1311
|
|
|
1230
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1312
|
+
Defined in: [data-structures/heap/heap.ts:523](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L523)
|
|
1231
1313
|
|
|
1232
1314
|
#### Returns
|
|
1233
1315
|
|
|
@@ -1236,6 +1318,7 @@ Defined in: [data-structures/heap/heap.ts:511](https://github.com/zrwusa/data-st
|
|
|
1236
1318
|
#### Deprecated
|
|
1237
1319
|
|
|
1238
1320
|
Use `pop` instead. Will be removed in a future major version.
|
|
1321
|
+
|
|
1239
1322
|
*
|
|
1240
1323
|
|
|
1241
1324
|
#### Example
|
|
@@ -1275,7 +1358,7 @@ Use `pop` instead. Will be removed in a future major version.
|
|
|
1275
1358
|
pop(): E | undefined;
|
|
1276
1359
|
```
|
|
1277
1360
|
|
|
1278
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1361
|
+
Defined in: [data-structures/heap/heap.ts:532](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L532)
|
|
1279
1362
|
|
|
1280
1363
|
Remove and return the top element (min or max depending on comparator).
|
|
1281
1364
|
|
|
@@ -1297,7 +1380,7 @@ Time O(log N) amortized, Space O(1)
|
|
|
1297
1380
|
print(): void;
|
|
1298
1381
|
```
|
|
1299
1382
|
|
|
1300
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1383
|
+
Defined in: [data-structures/base/iterable-element-base.ts:301](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L301)
|
|
1301
1384
|
|
|
1302
1385
|
Prints `toVisual()` to the console. Intended for quick debugging.
|
|
1303
1386
|
|
|
@@ -1355,7 +1438,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
|
|
|
1355
1438
|
reduce(callbackfn): E;
|
|
1356
1439
|
```
|
|
1357
1440
|
|
|
1358
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1441
|
+
Defined in: [data-structures/base/iterable-element-base.ts:226](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L226)
|
|
1359
1442
|
|
|
1360
1443
|
##### Parameters
|
|
1361
1444
|
|
|
@@ -1377,7 +1460,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
|
|
|
1377
1460
|
reduce(callbackfn, initialValue): E;
|
|
1378
1461
|
```
|
|
1379
1462
|
|
|
1380
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1463
|
+
Defined in: [data-structures/base/iterable-element-base.ts:227](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L227)
|
|
1381
1464
|
|
|
1382
1465
|
##### Parameters
|
|
1383
1466
|
|
|
@@ -1403,7 +1486,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
|
|
|
1403
1486
|
reduce<U>(callbackfn, initialValue): U;
|
|
1404
1487
|
```
|
|
1405
1488
|
|
|
1406
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1489
|
+
Defined in: [data-structures/base/iterable-element-base.ts:228](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L228)
|
|
1407
1490
|
|
|
1408
1491
|
##### Type Parameters
|
|
1409
1492
|
|
|
@@ -1437,7 +1520,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.c
|
|
|
1437
1520
|
setEquality(equals): this;
|
|
1438
1521
|
```
|
|
1439
1522
|
|
|
1440
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1523
|
+
Defined in: [data-structures/heap/heap.ts:930](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L930)
|
|
1441
1524
|
|
|
1442
1525
|
Set the equality comparator used by has/delete operations.
|
|
1443
1526
|
|
|
@@ -1507,7 +1590,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
|
|
|
1507
1590
|
sort(): E[];
|
|
1508
1591
|
```
|
|
1509
1592
|
|
|
1510
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1593
|
+
Defined in: [data-structures/heap/heap.ts:1072](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1072)
|
|
1511
1594
|
|
|
1512
1595
|
Return all elements in ascending order by repeatedly polling.
|
|
1513
1596
|
|
|
@@ -1540,7 +1623,7 @@ Time O(N log N), Space O(N)
|
|
|
1540
1623
|
toArray(): E[];
|
|
1541
1624
|
```
|
|
1542
1625
|
|
|
1543
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1626
|
+
Defined in: [data-structures/base/iterable-element-base.ts:278](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L278)
|
|
1544
1627
|
|
|
1545
1628
|
Materializes the elements into a new array.
|
|
1546
1629
|
|
|
@@ -1566,7 +1649,7 @@ Time O(n), Space O(n).
|
|
|
1566
1649
|
toVisual(): E[];
|
|
1567
1650
|
```
|
|
1568
1651
|
|
|
1569
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1652
|
+
Defined in: [data-structures/base/iterable-element-base.ts:290](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L290)
|
|
1570
1653
|
|
|
1571
1654
|
Returns a representation of the structure suitable for quick visualization.
|
|
1572
1655
|
Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
@@ -1622,7 +1705,7 @@ static from<T, R, S>(
|
|
|
1622
1705
|
options?): S;
|
|
1623
1706
|
```
|
|
1624
1707
|
|
|
1625
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1708
|
+
Defined in: [data-structures/heap/heap.ts:266](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L266)
|
|
1626
1709
|
|
|
1627
1710
|
Create a heap of the same class from an iterable.
|
|
1628
1711
|
|
|
@@ -1676,7 +1759,7 @@ Time O(N), Space O(N)
|
|
|
1676
1759
|
static heapify<EE, RR>(elements, options): Heap<EE, RR>;
|
|
1677
1760
|
```
|
|
1678
1761
|
|
|
1679
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1762
|
+
Defined in: [data-structures/heap/heap.ts:284](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L284)
|
|
1680
1763
|
|
|
1681
1764
|
Build a Heap from an iterable in linear time given a comparator.
|
|
1682
1765
|
|
|
@@ -1755,7 +1838,7 @@ Time O(1), Space O(1).
|
|
|
1755
1838
|
protected _createInstance(options?): this;
|
|
1756
1839
|
```
|
|
1757
1840
|
|
|
1758
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1841
|
+
Defined in: [data-structures/heap/heap.ts:1360](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1360)
|
|
1759
1842
|
|
|
1760
1843
|
(Protected) Create an empty instance of the same concrete class.
|
|
1761
1844
|
|
|
@@ -1785,7 +1868,7 @@ Time O(1), Space O(1)
|
|
|
1785
1868
|
protected _createLike<EM, RM>(elements?, options?): Heap<EM, RM>;
|
|
1786
1869
|
```
|
|
1787
1870
|
|
|
1788
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1871
|
+
Defined in: [data-structures/heap/heap.ts:1378](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1378)
|
|
1789
1872
|
|
|
1790
1873
|
(Protected) Create a like-kind instance seeded by elements.
|
|
1791
1874
|
|
|
@@ -1831,7 +1914,7 @@ Time O(N log N), Space O(N)
|
|
|
1831
1914
|
protected _getIterator(): IterableIterator<E>;
|
|
1832
1915
|
```
|
|
1833
1916
|
|
|
1834
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1917
|
+
Defined in: [data-structures/heap/heap.ts:1318](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1318)
|
|
1835
1918
|
|
|
1836
1919
|
Internal iterator factory used by the default iterator.
|
|
1837
1920
|
|
|
@@ -1857,7 +1940,7 @@ Implementations should yield in O(1) per element with O(1) extra space when poss
|
|
|
1857
1940
|
protected _spawnLike<EM, RM>(options?): Heap<EM, RM>;
|
|
1858
1941
|
```
|
|
1859
1942
|
|
|
1860
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1943
|
+
Defined in: [data-structures/heap/heap.ts:1398](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1398)
|
|
1861
1944
|
|
|
1862
1945
|
(Protected) Spawn an empty like-kind heap instance.
|
|
1863
1946
|
|