data-structure-typed 2.5.3 → 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/.husky/pre-commit +3 -0
- package/CHANGELOG.md +1 -1
- package/MIGRATION.md +48 -0
- package/README.md +20 -2
- package/README_CN.md +20 -2
- package/SPECIFICATION.md +24 -0
- package/SPECIFICATION.zh-CN.md +24 -0
- package/dist/cjs/binary-tree.cjs +1897 -19
- package/dist/cjs/graph.cjs +174 -0
- package/dist/cjs/hash.cjs +33 -0
- package/dist/cjs/heap.cjs +71 -0
- package/dist/cjs/index.cjs +2383 -3
- package/dist/cjs/linked-list.cjs +224 -2
- package/dist/cjs/matrix.cjs +24 -0
- package/dist/cjs/priority-queue.cjs +71 -0
- package/dist/cjs/queue.cjs +221 -1
- package/dist/cjs/stack.cjs +59 -0
- package/dist/cjs/trie.cjs +62 -0
- package/dist/cjs-legacy/binary-tree.cjs +1897 -19
- package/dist/cjs-legacy/graph.cjs +174 -0
- package/dist/cjs-legacy/hash.cjs +33 -0
- package/dist/cjs-legacy/heap.cjs +71 -0
- package/dist/cjs-legacy/index.cjs +2383 -3
- package/dist/cjs-legacy/linked-list.cjs +224 -2
- package/dist/cjs-legacy/matrix.cjs +24 -0
- package/dist/cjs-legacy/priority-queue.cjs +71 -0
- package/dist/cjs-legacy/queue.cjs +221 -1
- package/dist/cjs-legacy/stack.cjs +59 -0
- package/dist/cjs-legacy/trie.cjs +62 -0
- package/dist/esm/binary-tree.mjs +1897 -19
- package/dist/esm/graph.mjs +174 -0
- package/dist/esm/hash.mjs +33 -0
- package/dist/esm/heap.mjs +71 -0
- package/dist/esm/index.mjs +2383 -3
- package/dist/esm/linked-list.mjs +224 -2
- package/dist/esm/matrix.mjs +24 -0
- package/dist/esm/priority-queue.mjs +71 -0
- package/dist/esm/queue.mjs +221 -1
- package/dist/esm/stack.mjs +59 -0
- package/dist/esm/trie.mjs +62 -0
- package/dist/esm-legacy/binary-tree.mjs +1897 -19
- package/dist/esm-legacy/graph.mjs +174 -0
- package/dist/esm-legacy/hash.mjs +33 -0
- package/dist/esm-legacy/heap.mjs +71 -0
- package/dist/esm-legacy/index.mjs +2383 -3
- package/dist/esm-legacy/linked-list.mjs +224 -2
- package/dist/esm-legacy/matrix.mjs +24 -0
- package/dist/esm-legacy/priority-queue.mjs +71 -0
- package/dist/esm-legacy/queue.mjs +221 -1
- package/dist/esm-legacy/stack.mjs +59 -0
- package/dist/esm-legacy/trie.mjs +62 -0
- package/dist/types/data-structures/base/iterable-element-base.d.ts +17 -0
- package/dist/types/data-structures/base/linear-base.d.ts +6 -0
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +36 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +42 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +75 -0
- package/dist/types/data-structures/binary-tree/bst.d.ts +72 -0
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +57 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +18 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +375 -0
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +389 -0
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +330 -0
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +438 -0
- package/dist/types/data-structures/graph/directed-graph.d.ts +30 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +27 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +33 -0
- package/dist/types/data-structures/heap/heap.d.ts +42 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +75 -2
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +45 -0
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +54 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +24 -0
- package/dist/types/data-structures/queue/deque.d.ts +90 -1
- package/dist/types/data-structures/queue/queue.d.ts +36 -0
- package/dist/types/data-structures/stack/stack.d.ts +30 -0
- package/dist/types/data-structures/trie/trie.d.ts +36 -0
- package/dist/umd/data-structure-typed.js +2383 -3
- package/dist/umd/data-structure-typed.min.js +3 -3
- 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 +30 -26
- 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/jest.integration.config.js +1 -2
- package/package.json +51 -50
- package/src/common/error.ts +15 -32
- package/src/common/index.ts +0 -3
- package/src/data-structures/base/iterable-element-base.ts +32 -3
- package/src/data-structures/base/linear-base.ts +13 -36
- package/src/data-structures/binary-tree/avl-tree.ts +31 -493
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +47 -530
- package/src/data-structures/binary-tree/binary-tree.ts +326 -1236
- package/src/data-structures/binary-tree/bst.ts +158 -1010
- package/src/data-structures/binary-tree/red-black-tree.ts +451 -1233
- package/src/data-structures/binary-tree/segment-tree.ts +73 -333
- package/src/data-structures/binary-tree/tree-map.ts +462 -4749
- package/src/data-structures/binary-tree/tree-multi-map.ts +310 -4530
- package/src/data-structures/binary-tree/tree-multi-set.ts +300 -3652
- package/src/data-structures/binary-tree/tree-set.ts +437 -4443
- package/src/data-structures/graph/abstract-graph.ts +98 -167
- package/src/data-structures/graph/directed-graph.ts +137 -532
- package/src/data-structures/graph/map-graph.ts +0 -3
- package/src/data-structures/graph/undirected-graph.ts +132 -484
- package/src/data-structures/hash/hash-map.ts +154 -549
- package/src/data-structures/heap/heap.ts +200 -753
- package/src/data-structures/linked-list/doubly-linked-list.ts +153 -809
- package/src/data-structures/linked-list/singly-linked-list.ts +122 -749
- package/src/data-structures/linked-list/skip-linked-list.ts +211 -864
- package/src/data-structures/matrix/matrix.ts +179 -494
- 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 +241 -807
- package/src/data-structures/queue/queue.ts +102 -589
- package/src/data-structures/stack/stack.ts +76 -475
- package/src/data-structures/trie/trie.ts +98 -592
- 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
|
@@ -150,7 +150,7 @@ PriorityQueue<E, R>.constructor
|
|
|
150
150
|
get comparator(): Comparator<E>;
|
|
151
151
|
```
|
|
152
152
|
|
|
153
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
153
|
+
Defined in: [data-structures/heap/heap.ts:1314](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1314)
|
|
154
154
|
|
|
155
155
|
Get the comparator used to order elements.
|
|
156
156
|
|
|
@@ -206,7 +206,7 @@ Internal elements array.
|
|
|
206
206
|
get leaf(): E | undefined;
|
|
207
207
|
```
|
|
208
208
|
|
|
209
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
209
|
+
Defined in: [data-structures/heap/heap.ts:251](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L251)
|
|
210
210
|
|
|
211
211
|
Get the last leaf element.
|
|
212
212
|
|
|
@@ -234,7 +234,7 @@ Last element or undefined.
|
|
|
234
234
|
get size(): number;
|
|
235
235
|
```
|
|
236
236
|
|
|
237
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
237
|
+
Defined in: [data-structures/heap/heap.ts:241](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L241)
|
|
238
238
|
|
|
239
239
|
Get the number of elements.
|
|
240
240
|
|
|
@@ -337,7 +337,7 @@ Producing the iterator is O(1); consuming the entire iterator is Time O(n) with
|
|
|
337
337
|
add(element): boolean;
|
|
338
338
|
```
|
|
339
339
|
|
|
340
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
340
|
+
Defined in: [data-structures/heap/heap.ts:352](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L352)
|
|
341
341
|
|
|
342
342
|
Insert an element.
|
|
343
343
|
|
|
@@ -392,7 +392,7 @@ Time O(log N) amortized, Space O(1)
|
|
|
392
392
|
addMany(elements): boolean[];
|
|
393
393
|
```
|
|
394
394
|
|
|
395
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
395
|
+
Defined in: [data-structures/heap/heap.ts:409](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L409)
|
|
396
396
|
|
|
397
397
|
Insert many elements from an iterable.
|
|
398
398
|
|
|
@@ -438,7 +438,7 @@ Time O(N log N), Space O(1)
|
|
|
438
438
|
clear(): void;
|
|
439
439
|
```
|
|
440
440
|
|
|
441
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
441
|
+
Defined in: [data-structures/heap/heap.ts:761](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L761)
|
|
442
442
|
|
|
443
443
|
Remove all elements.
|
|
444
444
|
|
|
@@ -475,7 +475,7 @@ Time O(1), Space O(1)
|
|
|
475
475
|
clone(): this;
|
|
476
476
|
```
|
|
477
477
|
|
|
478
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
478
|
+
Defined in: [data-structures/heap/heap.ts:1136](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1136)
|
|
479
479
|
|
|
480
480
|
Deep clone this heap.
|
|
481
481
|
|
|
@@ -514,7 +514,7 @@ Time O(N), Space O(N)
|
|
|
514
514
|
delete(element): boolean;
|
|
515
515
|
```
|
|
516
516
|
|
|
517
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
517
|
+
Defined in: [data-structures/heap/heap.ts:868](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L868)
|
|
518
518
|
|
|
519
519
|
Delete one occurrence of an element.
|
|
520
520
|
|
|
@@ -559,7 +559,7 @@ Time O(N), Space O(1)
|
|
|
559
559
|
deleteBy(predicate): boolean;
|
|
560
560
|
```
|
|
561
561
|
|
|
562
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
562
|
+
Defined in: [data-structures/heap/heap.ts:892](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L892)
|
|
563
563
|
|
|
564
564
|
#### Parameters
|
|
565
565
|
|
|
@@ -587,7 +587,7 @@ Use `deleteWhere` instead. Will be removed in a future major version.
|
|
|
587
587
|
deleteWhere(predicate): boolean;
|
|
588
588
|
```
|
|
589
589
|
|
|
590
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
590
|
+
Defined in: [data-structures/heap/heap.ts:902](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L902)
|
|
591
591
|
|
|
592
592
|
Delete the first element that matches a predicate.
|
|
593
593
|
|
|
@@ -621,7 +621,7 @@ Time O(N), Space O(1)
|
|
|
621
621
|
dfs(order?): E[];
|
|
622
622
|
```
|
|
623
623
|
|
|
624
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
624
|
+
Defined in: [data-structures/heap/heap.ts:980](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L980)
|
|
625
625
|
|
|
626
626
|
Traverse the binary heap as a complete binary tree and collect elements.
|
|
627
627
|
|
|
@@ -660,6 +660,30 @@ Time O(N), Space O(H)
|
|
|
660
660
|
|
|
661
661
|
***
|
|
662
662
|
|
|
663
|
+
### entries()
|
|
664
|
+
|
|
665
|
+
```ts
|
|
666
|
+
entries(): IterableIterator<[number, E]>;
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
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)
|
|
670
|
+
|
|
671
|
+
Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
672
|
+
|
|
673
|
+
#### Returns
|
|
674
|
+
|
|
675
|
+
`IterableIterator`\<\[`number`, `E`\]\>
|
|
676
|
+
|
|
677
|
+
#### Remarks
|
|
678
|
+
|
|
679
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
680
|
+
|
|
681
|
+
#### Inherited from
|
|
682
|
+
|
|
683
|
+
[`PriorityQueue`](PriorityQueue.md).[`entries`](PriorityQueue.md#entries)
|
|
684
|
+
|
|
685
|
+
***
|
|
686
|
+
|
|
663
687
|
### every()
|
|
664
688
|
|
|
665
689
|
```ts
|
|
@@ -706,7 +730,7 @@ Time O(n) in the worst case; may exit early when the first failure is found. Spa
|
|
|
706
730
|
filter(callback, thisArg?): this;
|
|
707
731
|
```
|
|
708
732
|
|
|
709
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
733
|
+
Defined in: [data-structures/heap/heap.ts:1195](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1195)
|
|
710
734
|
|
|
711
735
|
Filter elements into a new heap of the same class.
|
|
712
736
|
|
|
@@ -847,7 +871,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
|
847
871
|
fix(): boolean[];
|
|
848
872
|
```
|
|
849
873
|
|
|
850
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
874
|
+
Defined in: [data-structures/heap/heap.ts:1011](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1011)
|
|
851
875
|
|
|
852
876
|
Restore heap order bottom-up (heapify in-place).
|
|
853
877
|
|
|
@@ -913,7 +937,7 @@ Time O(n), Space O(1).
|
|
|
913
937
|
has(element): boolean;
|
|
914
938
|
```
|
|
915
939
|
|
|
916
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
940
|
+
Defined in: [data-structures/heap/heap.ts:812](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L812)
|
|
917
941
|
|
|
918
942
|
Check if an equal element exists in the heap.
|
|
919
943
|
|
|
@@ -952,13 +976,47 @@ Time O(N), Space O(1)
|
|
|
952
976
|
|
|
953
977
|
***
|
|
954
978
|
|
|
979
|
+
### includes()
|
|
980
|
+
|
|
981
|
+
```ts
|
|
982
|
+
includes(element): boolean;
|
|
983
|
+
```
|
|
984
|
+
|
|
985
|
+
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)
|
|
986
|
+
|
|
987
|
+
Check whether a value exists (Array-compatible alias for `has`).
|
|
988
|
+
|
|
989
|
+
#### Parameters
|
|
990
|
+
|
|
991
|
+
##### element
|
|
992
|
+
|
|
993
|
+
`E`
|
|
994
|
+
|
|
995
|
+
Element to search for (uses `===`).
|
|
996
|
+
|
|
997
|
+
#### Returns
|
|
998
|
+
|
|
999
|
+
`boolean`
|
|
1000
|
+
|
|
1001
|
+
`true` if found.
|
|
1002
|
+
|
|
1003
|
+
#### Remarks
|
|
1004
|
+
|
|
1005
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
1006
|
+
|
|
1007
|
+
#### Inherited from
|
|
1008
|
+
|
|
1009
|
+
[`PriorityQueue`](PriorityQueue.md).[`includes`](PriorityQueue.md#includes)
|
|
1010
|
+
|
|
1011
|
+
***
|
|
1012
|
+
|
|
955
1013
|
### isEmpty()
|
|
956
1014
|
|
|
957
1015
|
```ts
|
|
958
1016
|
isEmpty(): boolean;
|
|
959
1017
|
```
|
|
960
1018
|
|
|
961
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1019
|
+
Defined in: [data-structures/heap/heap.ts:706](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L706)
|
|
962
1020
|
|
|
963
1021
|
Check whether the heap is empty.
|
|
964
1022
|
|
|
@@ -990,6 +1048,30 @@ Time O(1), Space O(1)
|
|
|
990
1048
|
|
|
991
1049
|
***
|
|
992
1050
|
|
|
1051
|
+
### keys()
|
|
1052
|
+
|
|
1053
|
+
```ts
|
|
1054
|
+
keys(): IterableIterator<number>;
|
|
1055
|
+
```
|
|
1056
|
+
|
|
1057
|
+
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)
|
|
1058
|
+
|
|
1059
|
+
Return an iterator of numeric indices (Array-compatible).
|
|
1060
|
+
|
|
1061
|
+
#### Returns
|
|
1062
|
+
|
|
1063
|
+
`IterableIterator`\<`number`\>
|
|
1064
|
+
|
|
1065
|
+
#### Remarks
|
|
1066
|
+
|
|
1067
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
1068
|
+
|
|
1069
|
+
#### Inherited from
|
|
1070
|
+
|
|
1071
|
+
[`PriorityQueue`](PriorityQueue.md).[`keys`](PriorityQueue.md#keys)
|
|
1072
|
+
|
|
1073
|
+
***
|
|
1074
|
+
|
|
993
1075
|
### map()
|
|
994
1076
|
|
|
995
1077
|
```ts
|
|
@@ -999,7 +1081,7 @@ map<EM, RM>(
|
|
|
999
1081
|
thisArg?): Heap<EM, RM>;
|
|
1000
1082
|
```
|
|
1001
1083
|
|
|
1002
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1084
|
+
Defined in: [data-structures/heap/heap.ts:1263](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1263)
|
|
1003
1085
|
|
|
1004
1086
|
Map elements into a new heap of possibly different element type.
|
|
1005
1087
|
|
|
@@ -1066,7 +1148,7 @@ Time O(N log N), Space O(N)
|
|
|
1066
1148
|
mapSame(callback, thisArg?): this;
|
|
1067
1149
|
```
|
|
1068
1150
|
|
|
1069
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1151
|
+
Defined in: [data-structures/heap/heap.ts:1287](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1287)
|
|
1070
1152
|
|
|
1071
1153
|
Map elements into a new heap of the same element type.
|
|
1072
1154
|
|
|
@@ -1106,7 +1188,7 @@ Time O(N log N), Space O(N)
|
|
|
1106
1188
|
peek(): E | undefined;
|
|
1107
1189
|
```
|
|
1108
1190
|
|
|
1109
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1191
|
+
Defined in: [data-structures/heap/heap.ts:650](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L650)
|
|
1110
1192
|
|
|
1111
1193
|
Get the current top element without removing it.
|
|
1112
1194
|
|
|
@@ -1197,7 +1279,7 @@ Time O(1), Space O(1)
|
|
|
1197
1279
|
poll(): E | undefined;
|
|
1198
1280
|
```
|
|
1199
1281
|
|
|
1200
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1282
|
+
Defined in: [data-structures/heap/heap.ts:523](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L523)
|
|
1201
1283
|
|
|
1202
1284
|
#### Returns
|
|
1203
1285
|
|
|
@@ -1206,6 +1288,7 @@ Defined in: [data-structures/heap/heap.ts:511](https://github.com/zrwusa/data-st
|
|
|
1206
1288
|
#### Deprecated
|
|
1207
1289
|
|
|
1208
1290
|
Use `pop` instead. Will be removed in a future major version.
|
|
1291
|
+
|
|
1209
1292
|
*
|
|
1210
1293
|
|
|
1211
1294
|
#### Example
|
|
@@ -1249,7 +1332,7 @@ Use `pop` instead. Will be removed in a future major version.
|
|
|
1249
1332
|
pop(): E | undefined;
|
|
1250
1333
|
```
|
|
1251
1334
|
|
|
1252
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1335
|
+
Defined in: [data-structures/heap/heap.ts:532](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L532)
|
|
1253
1336
|
|
|
1254
1337
|
Remove and return the top element (min or max depending on comparator).
|
|
1255
1338
|
|
|
@@ -1275,7 +1358,7 @@ Time O(log N) amortized, Space O(1)
|
|
|
1275
1358
|
print(): void;
|
|
1276
1359
|
```
|
|
1277
1360
|
|
|
1278
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1361
|
+
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)
|
|
1279
1362
|
|
|
1280
1363
|
Prints `toVisual()` to the console. Intended for quick debugging.
|
|
1281
1364
|
|
|
@@ -1333,7 +1416,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
|
|
|
1333
1416
|
reduce(callbackfn): E;
|
|
1334
1417
|
```
|
|
1335
1418
|
|
|
1336
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1419
|
+
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)
|
|
1337
1420
|
|
|
1338
1421
|
##### Parameters
|
|
1339
1422
|
|
|
@@ -1355,7 +1438,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
|
|
|
1355
1438
|
reduce(callbackfn, initialValue): 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:227](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L227)
|
|
1359
1442
|
|
|
1360
1443
|
##### Parameters
|
|
1361
1444
|
|
|
@@ -1381,7 +1464,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
|
|
|
1381
1464
|
reduce<U>(callbackfn, initialValue): U;
|
|
1382
1465
|
```
|
|
1383
1466
|
|
|
1384
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1467
|
+
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)
|
|
1385
1468
|
|
|
1386
1469
|
##### Type Parameters
|
|
1387
1470
|
|
|
@@ -1415,7 +1498,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.c
|
|
|
1415
1498
|
setEquality(equals): this;
|
|
1416
1499
|
```
|
|
1417
1500
|
|
|
1418
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1501
|
+
Defined in: [data-structures/heap/heap.ts:930](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L930)
|
|
1419
1502
|
|
|
1420
1503
|
Set the equality comparator used by has/delete operations.
|
|
1421
1504
|
|
|
@@ -1489,7 +1572,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
|
|
|
1489
1572
|
sort(): E[];
|
|
1490
1573
|
```
|
|
1491
1574
|
|
|
1492
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1575
|
+
Defined in: [data-structures/heap/heap.ts:1072](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1072)
|
|
1493
1576
|
|
|
1494
1577
|
Return all elements in ascending order by repeatedly polling.
|
|
1495
1578
|
|
|
@@ -1526,7 +1609,7 @@ Time O(N log N), Space O(N)
|
|
|
1526
1609
|
toArray(): E[];
|
|
1527
1610
|
```
|
|
1528
1611
|
|
|
1529
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1612
|
+
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)
|
|
1530
1613
|
|
|
1531
1614
|
Materializes the elements into a new array.
|
|
1532
1615
|
|
|
@@ -1552,7 +1635,7 @@ Time O(n), Space O(n).
|
|
|
1552
1635
|
toVisual(): E[];
|
|
1553
1636
|
```
|
|
1554
1637
|
|
|
1555
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1638
|
+
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)
|
|
1556
1639
|
|
|
1557
1640
|
Returns a representation of the structure suitable for quick visualization.
|
|
1558
1641
|
Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
@@ -1608,7 +1691,7 @@ static from<T, R, S>(
|
|
|
1608
1691
|
options?): S;
|
|
1609
1692
|
```
|
|
1610
1693
|
|
|
1611
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1694
|
+
Defined in: [data-structures/heap/heap.ts:266](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L266)
|
|
1612
1695
|
|
|
1613
1696
|
Create a heap of the same class from an iterable.
|
|
1614
1697
|
|
|
@@ -1666,7 +1749,7 @@ Time O(N), Space O(N)
|
|
|
1666
1749
|
static heapify<EE, RR>(elements, options): Heap<EE, RR>;
|
|
1667
1750
|
```
|
|
1668
1751
|
|
|
1669
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1752
|
+
Defined in: [data-structures/heap/heap.ts:284](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L284)
|
|
1670
1753
|
|
|
1671
1754
|
Build a Heap from an iterable in linear time given a comparator.
|
|
1672
1755
|
|
|
@@ -1749,7 +1832,7 @@ Time O(1), Space O(1).
|
|
|
1749
1832
|
protected _createInstance(options?): this;
|
|
1750
1833
|
```
|
|
1751
1834
|
|
|
1752
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1835
|
+
Defined in: [data-structures/heap/heap.ts:1360](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1360)
|
|
1753
1836
|
|
|
1754
1837
|
(Protected) Create an empty instance of the same concrete class.
|
|
1755
1838
|
|
|
@@ -1783,7 +1866,7 @@ Time O(1), Space O(1)
|
|
|
1783
1866
|
protected _createLike<EM, RM>(elements?, options?): Heap<EM, RM>;
|
|
1784
1867
|
```
|
|
1785
1868
|
|
|
1786
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1869
|
+
Defined in: [data-structures/heap/heap.ts:1378](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1378)
|
|
1787
1870
|
|
|
1788
1871
|
(Protected) Create a like-kind instance seeded by elements.
|
|
1789
1872
|
|
|
@@ -1833,7 +1916,7 @@ Time O(N log N), Space O(N)
|
|
|
1833
1916
|
protected _getIterator(): IterableIterator<E>;
|
|
1834
1917
|
```
|
|
1835
1918
|
|
|
1836
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1919
|
+
Defined in: [data-structures/heap/heap.ts:1318](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1318)
|
|
1837
1920
|
|
|
1838
1921
|
Internal iterator factory used by the default iterator.
|
|
1839
1922
|
|
|
@@ -1859,7 +1942,7 @@ Implementations should yield in O(1) per element with O(1) extra space when poss
|
|
|
1859
1942
|
protected _spawnLike<EM, RM>(options?): Heap<EM, RM>;
|
|
1860
1943
|
```
|
|
1861
1944
|
|
|
1862
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1945
|
+
Defined in: [data-structures/heap/heap.ts:1398](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1398)
|
|
1863
1946
|
|
|
1864
1947
|
(Protected) Spawn an empty like-kind heap instance.
|
|
1865
1948
|
|