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
|
@@ -133,7 +133,7 @@ Optional configuration.
|
|
|
133
133
|
get comparator(): Comparator<E>;
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
136
|
+
Defined in: [data-structures/heap/heap.ts:1314](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1314)
|
|
137
137
|
|
|
138
138
|
Get the comparator used to order elements.
|
|
139
139
|
|
|
@@ -189,7 +189,7 @@ Internal elements array.
|
|
|
189
189
|
get leaf(): E | undefined;
|
|
190
190
|
```
|
|
191
191
|
|
|
192
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
192
|
+
Defined in: [data-structures/heap/heap.ts:251](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L251)
|
|
193
193
|
|
|
194
194
|
Get the last leaf element.
|
|
195
195
|
|
|
@@ -217,7 +217,7 @@ Last element or undefined.
|
|
|
217
217
|
get size(): number;
|
|
218
218
|
```
|
|
219
219
|
|
|
220
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
220
|
+
Defined in: [data-structures/heap/heap.ts:241](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L241)
|
|
221
221
|
|
|
222
222
|
Get the number of elements.
|
|
223
223
|
|
|
@@ -320,7 +320,7 @@ Producing the iterator is O(1); consuming the entire iterator is Time O(n) with
|
|
|
320
320
|
add(element): boolean;
|
|
321
321
|
```
|
|
322
322
|
|
|
323
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
323
|
+
Defined in: [data-structures/heap/heap.ts:352](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L352)
|
|
324
324
|
|
|
325
325
|
Insert an element.
|
|
326
326
|
|
|
@@ -375,7 +375,7 @@ Time O(log N) amortized, Space O(1)
|
|
|
375
375
|
addMany(elements): boolean[];
|
|
376
376
|
```
|
|
377
377
|
|
|
378
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
378
|
+
Defined in: [data-structures/heap/heap.ts:409](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L409)
|
|
379
379
|
|
|
380
380
|
Insert many elements from an iterable.
|
|
381
381
|
|
|
@@ -421,7 +421,7 @@ Time O(N log N), Space O(1)
|
|
|
421
421
|
clear(): void;
|
|
422
422
|
```
|
|
423
423
|
|
|
424
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
424
|
+
Defined in: [data-structures/heap/heap.ts:761](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L761)
|
|
425
425
|
|
|
426
426
|
Remove all elements.
|
|
427
427
|
|
|
@@ -458,7 +458,7 @@ Time O(1), Space O(1)
|
|
|
458
458
|
clone(): this;
|
|
459
459
|
```
|
|
460
460
|
|
|
461
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
461
|
+
Defined in: [data-structures/heap/heap.ts:1136](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1136)
|
|
462
462
|
|
|
463
463
|
Deep clone this heap.
|
|
464
464
|
|
|
@@ -497,7 +497,7 @@ Time O(N), Space O(N)
|
|
|
497
497
|
delete(element): boolean;
|
|
498
498
|
```
|
|
499
499
|
|
|
500
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
500
|
+
Defined in: [data-structures/heap/heap.ts:868](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L868)
|
|
501
501
|
|
|
502
502
|
Delete one occurrence of an element.
|
|
503
503
|
|
|
@@ -542,7 +542,7 @@ Time O(N), Space O(1)
|
|
|
542
542
|
deleteBy(predicate): boolean;
|
|
543
543
|
```
|
|
544
544
|
|
|
545
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
545
|
+
Defined in: [data-structures/heap/heap.ts:892](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L892)
|
|
546
546
|
|
|
547
547
|
#### Parameters
|
|
548
548
|
|
|
@@ -570,7 +570,7 @@ Use `deleteWhere` instead. Will be removed in a future major version.
|
|
|
570
570
|
deleteWhere(predicate): boolean;
|
|
571
571
|
```
|
|
572
572
|
|
|
573
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
573
|
+
Defined in: [data-structures/heap/heap.ts:902](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L902)
|
|
574
574
|
|
|
575
575
|
Delete the first element that matches a predicate.
|
|
576
576
|
|
|
@@ -604,7 +604,7 @@ Time O(N), Space O(1)
|
|
|
604
604
|
dfs(order?): E[];
|
|
605
605
|
```
|
|
606
606
|
|
|
607
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
607
|
+
Defined in: [data-structures/heap/heap.ts:980](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L980)
|
|
608
608
|
|
|
609
609
|
Traverse the binary heap as a complete binary tree and collect elements.
|
|
610
610
|
|
|
@@ -643,6 +643,30 @@ Time O(N), Space O(H)
|
|
|
643
643
|
|
|
644
644
|
***
|
|
645
645
|
|
|
646
|
+
### entries()
|
|
647
|
+
|
|
648
|
+
```ts
|
|
649
|
+
entries(): IterableIterator<[number, E]>;
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
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)
|
|
653
|
+
|
|
654
|
+
Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
655
|
+
|
|
656
|
+
#### Returns
|
|
657
|
+
|
|
658
|
+
`IterableIterator`\<\[`number`, `E`\]\>
|
|
659
|
+
|
|
660
|
+
#### Remarks
|
|
661
|
+
|
|
662
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
663
|
+
|
|
664
|
+
#### Inherited from
|
|
665
|
+
|
|
666
|
+
[`Heap`](Heap.md).[`entries`](Heap.md#entries)
|
|
667
|
+
|
|
668
|
+
***
|
|
669
|
+
|
|
646
670
|
### every()
|
|
647
671
|
|
|
648
672
|
```ts
|
|
@@ -689,7 +713,7 @@ Time O(n) in the worst case; may exit early when the first failure is found. Spa
|
|
|
689
713
|
filter(callback, thisArg?): this;
|
|
690
714
|
```
|
|
691
715
|
|
|
692
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
716
|
+
Defined in: [data-structures/heap/heap.ts:1195](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1195)
|
|
693
717
|
|
|
694
718
|
Filter elements into a new heap of the same class.
|
|
695
719
|
|
|
@@ -830,7 +854,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
|
830
854
|
fix(): boolean[];
|
|
831
855
|
```
|
|
832
856
|
|
|
833
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
857
|
+
Defined in: [data-structures/heap/heap.ts:1011](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1011)
|
|
834
858
|
|
|
835
859
|
Restore heap order bottom-up (heapify in-place).
|
|
836
860
|
|
|
@@ -896,7 +920,7 @@ Time O(n), Space O(1).
|
|
|
896
920
|
has(element): boolean;
|
|
897
921
|
```
|
|
898
922
|
|
|
899
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
923
|
+
Defined in: [data-structures/heap/heap.ts:812](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L812)
|
|
900
924
|
|
|
901
925
|
Check if an equal element exists in the heap.
|
|
902
926
|
|
|
@@ -935,13 +959,47 @@ Time O(N), Space O(1)
|
|
|
935
959
|
|
|
936
960
|
***
|
|
937
961
|
|
|
962
|
+
### includes()
|
|
963
|
+
|
|
964
|
+
```ts
|
|
965
|
+
includes(element): boolean;
|
|
966
|
+
```
|
|
967
|
+
|
|
968
|
+
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)
|
|
969
|
+
|
|
970
|
+
Check whether a value exists (Array-compatible alias for `has`).
|
|
971
|
+
|
|
972
|
+
#### Parameters
|
|
973
|
+
|
|
974
|
+
##### element
|
|
975
|
+
|
|
976
|
+
`E`
|
|
977
|
+
|
|
978
|
+
Element to search for (uses `===`).
|
|
979
|
+
|
|
980
|
+
#### Returns
|
|
981
|
+
|
|
982
|
+
`boolean`
|
|
983
|
+
|
|
984
|
+
`true` if found.
|
|
985
|
+
|
|
986
|
+
#### Remarks
|
|
987
|
+
|
|
988
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
989
|
+
|
|
990
|
+
#### Inherited from
|
|
991
|
+
|
|
992
|
+
[`Heap`](Heap.md).[`includes`](Heap.md#includes)
|
|
993
|
+
|
|
994
|
+
***
|
|
995
|
+
|
|
938
996
|
### isEmpty()
|
|
939
997
|
|
|
940
998
|
```ts
|
|
941
999
|
isEmpty(): boolean;
|
|
942
1000
|
```
|
|
943
1001
|
|
|
944
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1002
|
+
Defined in: [data-structures/heap/heap.ts:706](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L706)
|
|
945
1003
|
|
|
946
1004
|
Check whether the heap is empty.
|
|
947
1005
|
|
|
@@ -973,6 +1031,30 @@ Time O(1), Space O(1)
|
|
|
973
1031
|
|
|
974
1032
|
***
|
|
975
1033
|
|
|
1034
|
+
### keys()
|
|
1035
|
+
|
|
1036
|
+
```ts
|
|
1037
|
+
keys(): IterableIterator<number>;
|
|
1038
|
+
```
|
|
1039
|
+
|
|
1040
|
+
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)
|
|
1041
|
+
|
|
1042
|
+
Return an iterator of numeric indices (Array-compatible).
|
|
1043
|
+
|
|
1044
|
+
#### Returns
|
|
1045
|
+
|
|
1046
|
+
`IterableIterator`\<`number`\>
|
|
1047
|
+
|
|
1048
|
+
#### Remarks
|
|
1049
|
+
|
|
1050
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
1051
|
+
|
|
1052
|
+
#### Inherited from
|
|
1053
|
+
|
|
1054
|
+
[`Heap`](Heap.md).[`keys`](Heap.md#keys)
|
|
1055
|
+
|
|
1056
|
+
***
|
|
1057
|
+
|
|
976
1058
|
### map()
|
|
977
1059
|
|
|
978
1060
|
```ts
|
|
@@ -982,7 +1064,7 @@ map<EM, RM>(
|
|
|
982
1064
|
thisArg?): Heap<EM, RM>;
|
|
983
1065
|
```
|
|
984
1066
|
|
|
985
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1067
|
+
Defined in: [data-structures/heap/heap.ts:1263](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1263)
|
|
986
1068
|
|
|
987
1069
|
Map elements into a new heap of possibly different element type.
|
|
988
1070
|
|
|
@@ -1049,7 +1131,7 @@ Time O(N log N), Space O(N)
|
|
|
1049
1131
|
mapSame(callback, thisArg?): this;
|
|
1050
1132
|
```
|
|
1051
1133
|
|
|
1052
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1134
|
+
Defined in: [data-structures/heap/heap.ts:1287](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1287)
|
|
1053
1135
|
|
|
1054
1136
|
Map elements into a new heap of the same element type.
|
|
1055
1137
|
|
|
@@ -1089,7 +1171,7 @@ Time O(N log N), Space O(N)
|
|
|
1089
1171
|
peek(): E | undefined;
|
|
1090
1172
|
```
|
|
1091
1173
|
|
|
1092
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1174
|
+
Defined in: [data-structures/heap/heap.ts:650](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L650)
|
|
1093
1175
|
|
|
1094
1176
|
Get the current top element without removing it.
|
|
1095
1177
|
|
|
@@ -1180,7 +1262,7 @@ Time O(1), Space O(1)
|
|
|
1180
1262
|
poll(): E | undefined;
|
|
1181
1263
|
```
|
|
1182
1264
|
|
|
1183
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1265
|
+
Defined in: [data-structures/heap/heap.ts:523](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L523)
|
|
1184
1266
|
|
|
1185
1267
|
#### Returns
|
|
1186
1268
|
|
|
@@ -1189,6 +1271,7 @@ Defined in: [data-structures/heap/heap.ts:511](https://github.com/zrwusa/data-st
|
|
|
1189
1271
|
#### Deprecated
|
|
1190
1272
|
|
|
1191
1273
|
Use `pop` instead. Will be removed in a future major version.
|
|
1274
|
+
|
|
1192
1275
|
*
|
|
1193
1276
|
|
|
1194
1277
|
#### Example
|
|
@@ -1232,7 +1315,7 @@ Use `pop` instead. Will be removed in a future major version.
|
|
|
1232
1315
|
pop(): E | undefined;
|
|
1233
1316
|
```
|
|
1234
1317
|
|
|
1235
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1318
|
+
Defined in: [data-structures/heap/heap.ts:532](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L532)
|
|
1236
1319
|
|
|
1237
1320
|
Remove and return the top element (min or max depending on comparator).
|
|
1238
1321
|
|
|
@@ -1258,7 +1341,7 @@ Time O(log N) amortized, Space O(1)
|
|
|
1258
1341
|
print(): void;
|
|
1259
1342
|
```
|
|
1260
1343
|
|
|
1261
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1344
|
+
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)
|
|
1262
1345
|
|
|
1263
1346
|
Prints `toVisual()` to the console. Intended for quick debugging.
|
|
1264
1347
|
|
|
@@ -1316,7 +1399,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
|
|
|
1316
1399
|
reduce(callbackfn): E;
|
|
1317
1400
|
```
|
|
1318
1401
|
|
|
1319
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1402
|
+
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)
|
|
1320
1403
|
|
|
1321
1404
|
##### Parameters
|
|
1322
1405
|
|
|
@@ -1338,7 +1421,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
|
|
|
1338
1421
|
reduce(callbackfn, initialValue): E;
|
|
1339
1422
|
```
|
|
1340
1423
|
|
|
1341
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1424
|
+
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)
|
|
1342
1425
|
|
|
1343
1426
|
##### Parameters
|
|
1344
1427
|
|
|
@@ -1364,7 +1447,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
|
|
|
1364
1447
|
reduce<U>(callbackfn, initialValue): U;
|
|
1365
1448
|
```
|
|
1366
1449
|
|
|
1367
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1450
|
+
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)
|
|
1368
1451
|
|
|
1369
1452
|
##### Type Parameters
|
|
1370
1453
|
|
|
@@ -1398,7 +1481,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.c
|
|
|
1398
1481
|
setEquality(equals): this;
|
|
1399
1482
|
```
|
|
1400
1483
|
|
|
1401
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1484
|
+
Defined in: [data-structures/heap/heap.ts:930](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L930)
|
|
1402
1485
|
|
|
1403
1486
|
Set the equality comparator used by has/delete operations.
|
|
1404
1487
|
|
|
@@ -1472,7 +1555,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
|
|
|
1472
1555
|
sort(): E[];
|
|
1473
1556
|
```
|
|
1474
1557
|
|
|
1475
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1558
|
+
Defined in: [data-structures/heap/heap.ts:1072](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1072)
|
|
1476
1559
|
|
|
1477
1560
|
Return all elements in ascending order by repeatedly polling.
|
|
1478
1561
|
|
|
@@ -1509,7 +1592,7 @@ Time O(N log N), Space O(N)
|
|
|
1509
1592
|
toArray(): E[];
|
|
1510
1593
|
```
|
|
1511
1594
|
|
|
1512
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1595
|
+
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)
|
|
1513
1596
|
|
|
1514
1597
|
Materializes the elements into a new array.
|
|
1515
1598
|
|
|
@@ -1535,7 +1618,7 @@ Time O(n), Space O(n).
|
|
|
1535
1618
|
toVisual(): E[];
|
|
1536
1619
|
```
|
|
1537
1620
|
|
|
1538
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1621
|
+
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)
|
|
1539
1622
|
|
|
1540
1623
|
Returns a representation of the structure suitable for quick visualization.
|
|
1541
1624
|
Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
@@ -1591,7 +1674,7 @@ static from<T, R, S>(
|
|
|
1591
1674
|
options?): S;
|
|
1592
1675
|
```
|
|
1593
1676
|
|
|
1594
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1677
|
+
Defined in: [data-structures/heap/heap.ts:266](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L266)
|
|
1595
1678
|
|
|
1596
1679
|
Create a heap of the same class from an iterable.
|
|
1597
1680
|
|
|
@@ -1649,7 +1732,7 @@ Time O(N), Space O(N)
|
|
|
1649
1732
|
static heapify<EE, RR>(elements, options): Heap<EE, RR>;
|
|
1650
1733
|
```
|
|
1651
1734
|
|
|
1652
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1735
|
+
Defined in: [data-structures/heap/heap.ts:284](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L284)
|
|
1653
1736
|
|
|
1654
1737
|
Build a Heap from an iterable in linear time given a comparator.
|
|
1655
1738
|
|
|
@@ -1732,7 +1815,7 @@ Time O(1), Space O(1).
|
|
|
1732
1815
|
protected _createInstance(options?): this;
|
|
1733
1816
|
```
|
|
1734
1817
|
|
|
1735
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1818
|
+
Defined in: [data-structures/heap/heap.ts:1360](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1360)
|
|
1736
1819
|
|
|
1737
1820
|
(Protected) Create an empty instance of the same concrete class.
|
|
1738
1821
|
|
|
@@ -1766,7 +1849,7 @@ Time O(1), Space O(1)
|
|
|
1766
1849
|
protected _createLike<EM, RM>(elements?, options?): Heap<EM, RM>;
|
|
1767
1850
|
```
|
|
1768
1851
|
|
|
1769
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1852
|
+
Defined in: [data-structures/heap/heap.ts:1378](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1378)
|
|
1770
1853
|
|
|
1771
1854
|
(Protected) Create a like-kind instance seeded by elements.
|
|
1772
1855
|
|
|
@@ -1816,7 +1899,7 @@ Time O(N log N), Space O(N)
|
|
|
1816
1899
|
protected _getIterator(): IterableIterator<E>;
|
|
1817
1900
|
```
|
|
1818
1901
|
|
|
1819
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1902
|
+
Defined in: [data-structures/heap/heap.ts:1318](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1318)
|
|
1820
1903
|
|
|
1821
1904
|
Internal iterator factory used by the default iterator.
|
|
1822
1905
|
|
|
@@ -1842,7 +1925,7 @@ Implementations should yield in O(1) per element with O(1) extra space when poss
|
|
|
1842
1925
|
protected _spawnLike<EM, RM>(options?): Heap<EM, RM>;
|
|
1843
1926
|
```
|
|
1844
1927
|
|
|
1845
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1928
|
+
Defined in: [data-structures/heap/heap.ts:1398](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L1398)
|
|
1846
1929
|
|
|
1847
1930
|
(Protected) Spawn an empty like-kind heap instance.
|
|
1848
1931
|
|