data-structure-typed 2.6.0 → 2.6.2
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/CHANGELOG.md +9 -1
- package/dist/cjs/binary-tree.cjs +2927 -23688
- package/dist/cjs/graph.cjs +845 -2634
- package/dist/cjs/hash.cjs +185 -616
- package/dist/cjs/heap.cjs +266 -818
- package/dist/cjs/index.cjs +5116 -31358
- package/dist/cjs/linked-list.cjs +644 -2615
- package/dist/cjs/matrix.cjs +220 -535
- package/dist/cjs/priority-queue.cjs +266 -818
- package/dist/cjs/queue.cjs +637 -2343
- package/dist/cjs/stack.cjs +124 -530
- package/dist/cjs/trie.cjs +145 -592
- package/dist/cjs-legacy/binary-tree.cjs +4352 -25113
- package/dist/cjs-legacy/graph.cjs +847 -2636
- package/dist/cjs-legacy/hash.cjs +181 -612
- package/dist/cjs-legacy/heap.cjs +266 -818
- package/dist/cjs-legacy/index.cjs +6657 -32899
- package/dist/cjs-legacy/linked-list.cjs +640 -2611
- package/dist/cjs-legacy/matrix.cjs +220 -535
- package/dist/cjs-legacy/priority-queue.cjs +266 -818
- package/dist/cjs-legacy/queue.cjs +634 -2340
- package/dist/cjs-legacy/stack.cjs +124 -530
- package/dist/cjs-legacy/trie.cjs +145 -592
- package/dist/esm/binary-tree.mjs +2927 -23688
- package/dist/esm/graph.mjs +845 -2634
- package/dist/esm/hash.mjs +185 -616
- package/dist/esm/heap.mjs +266 -818
- package/dist/esm/index.mjs +5116 -31358
- package/dist/esm/linked-list.mjs +644 -2615
- package/dist/esm/matrix.mjs +220 -535
- package/dist/esm/priority-queue.mjs +266 -818
- package/dist/esm/queue.mjs +637 -2343
- package/dist/esm/stack.mjs +124 -530
- package/dist/esm/trie.mjs +145 -592
- package/dist/esm-legacy/binary-tree.mjs +4352 -25113
- package/dist/esm-legacy/graph.mjs +847 -2636
- package/dist/esm-legacy/hash.mjs +181 -612
- package/dist/esm-legacy/heap.mjs +266 -818
- package/dist/esm-legacy/index.mjs +6657 -32899
- package/dist/esm-legacy/linked-list.mjs +640 -2611
- package/dist/esm-legacy/matrix.mjs +220 -535
- package/dist/esm-legacy/priority-queue.mjs +266 -818
- package/dist/esm-legacy/queue.mjs +634 -2340
- package/dist/esm-legacy/stack.mjs +124 -530
- package/dist/esm-legacy/trie.mjs +145 -592
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +29 -500
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +38 -563
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +230 -1212
- package/dist/types/data-structures/binary-tree/bst.d.ts +124 -1063
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +99 -854
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +62 -314
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +366 -5057
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +277 -4885
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +253 -3929
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +261 -4782
- package/dist/types/data-structures/graph/abstract-graph.d.ts +44 -44
- package/dist/types/data-structures/graph/directed-graph.d.ts +130 -527
- package/dist/types/data-structures/graph/undirected-graph.d.ts +125 -482
- package/dist/types/data-structures/hash/hash-map.d.ts +132 -562
- package/dist/types/data-structures/heap/heap.d.ts +194 -746
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +120 -809
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +121 -733
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +193 -863
- package/dist/types/data-structures/matrix/matrix.d.ts +159 -474
- package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -6
- package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +6 -11
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
- package/dist/types/data-structures/queue/deque.d.ts +196 -804
- package/dist/types/data-structures/queue/queue.d.ts +99 -585
- package/dist/types/data-structures/stack/stack.d.ts +75 -481
- package/dist/types/data-structures/trie/trie.d.ts +98 -584
- package/dist/umd/data-structure-typed.js +6580 -32822
- package/dist/umd/data-structure-typed.min.js +3 -3
- package/docs-site-docusaurus/docs/api/classes/AVLTree.md +162 -215
- package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +9 -9
- package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +47 -47
- package/docs-site-docusaurus/docs/api/classes/BST.md +155 -208
- package/docs-site-docusaurus/docs/api/classes/BSTNode.md +7 -7
- package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +13 -29
- package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +104 -158
- package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/Deque.md +253 -101
- package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +60 -80
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +244 -114
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +6 -6
- 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 +52 -48
- package/docs-site-docusaurus/docs/api/classes/Heap.md +119 -64
- package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +84 -14
- package/docs-site-docusaurus/docs/api/classes/LinearBase.md +138 -34
- package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +149 -41
- package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +23 -23
- package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +172 -92
- package/docs-site-docusaurus/docs/api/classes/MapGraph.md +60 -80
- package/docs-site-docusaurus/docs/api/classes/Matrix.md +57 -52
- package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +117 -62
- package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +120 -70
- package/docs-site-docusaurus/docs/api/classes/MinHeap.md +117 -62
- package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +125 -75
- package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +119 -64
- package/docs-site-docusaurus/docs/api/classes/Queue.md +158 -74
- package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +171 -225
- package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -22
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +172 -94
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +4 -4
- package/docs-site-docusaurus/docs/api/classes/SkipList.md +98 -75
- package/docs-site-docusaurus/docs/api/classes/Stack.md +112 -50
- package/docs-site-docusaurus/docs/api/classes/TreeMap.md +104 -129
- package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +90 -121
- package/docs-site-docusaurus/docs/api/classes/TreeSet.md +298 -107
- package/docs-site-docusaurus/docs/api/classes/Trie.md +116 -58
- package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +59 -77
- 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 +299 -3983
- 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: Heap\<E, R\>
|
|
8
8
|
|
|
9
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
9
|
+
Defined in: [data-structures/heap/heap.ts:149](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L149)
|
|
10
10
|
|
|
11
11
|
Binary heap with pluggable comparator; supports fast insertion and removal of the top element.
|
|
12
12
|
|
|
@@ -186,7 +186,7 @@ Min Heap: The value of each parent node is less than or equal to the value of it
|
|
|
186
186
|
new Heap<E, R>(elements?, options?): Heap<E, R>;
|
|
187
187
|
```
|
|
188
188
|
|
|
189
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
189
|
+
Defined in: [data-structures/heap/heap.ts:159](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L159)
|
|
190
190
|
|
|
191
191
|
Create a Heap and optionally bulk-insert elements.
|
|
192
192
|
|
|
@@ -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:211](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L211)
|
|
232
232
|
|
|
233
233
|
Get the comparator used to order elements.
|
|
234
234
|
|
|
@@ -252,7 +252,7 @@ Comparator function.
|
|
|
252
252
|
get elements(): E[];
|
|
253
253
|
```
|
|
254
254
|
|
|
255
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
255
|
+
Defined in: [data-structures/heap/heap.ts:175](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L175)
|
|
256
256
|
|
|
257
257
|
Get the backing array of the heap.
|
|
258
258
|
|
|
@@ -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:202](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L202)
|
|
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:193](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L193)
|
|
304
304
|
|
|
305
305
|
Get the number of elements.
|
|
306
306
|
|
|
@@ -327,8 +327,6 @@ Time O(1), Space O(1)
|
|
|
327
327
|
|
|
328
328
|
Heap size.
|
|
329
329
|
|
|
330
|
-
*
|
|
331
|
-
|
|
332
330
|
***
|
|
333
331
|
|
|
334
332
|
### toElementFn
|
|
@@ -399,7 +397,7 @@ Producing the iterator is O(1); consuming the entire iterator is Time O(n) with
|
|
|
399
397
|
add(element): boolean;
|
|
400
398
|
```
|
|
401
399
|
|
|
402
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
400
|
+
Defined in: [data-structures/heap/heap.ts:267](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L267)
|
|
403
401
|
|
|
404
402
|
Insert an element.
|
|
405
403
|
|
|
@@ -417,8 +415,6 @@ Element to insert.
|
|
|
417
415
|
|
|
418
416
|
True.
|
|
419
417
|
|
|
420
|
-
*
|
|
421
|
-
|
|
422
418
|
#### Remarks
|
|
423
419
|
|
|
424
420
|
Time O(log N) amortized, Space O(1)
|
|
@@ -450,7 +446,7 @@ Time O(log N) amortized, Space O(1)
|
|
|
450
446
|
addMany(elements): boolean[];
|
|
451
447
|
```
|
|
452
448
|
|
|
453
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
449
|
+
Defined in: [data-structures/heap/heap.ts:284](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L284)
|
|
454
450
|
|
|
455
451
|
Insert many elements from an iterable.
|
|
456
452
|
|
|
@@ -468,8 +464,6 @@ Iterable of elements or raw values.
|
|
|
468
464
|
|
|
469
465
|
Array of per-element success flags.
|
|
470
466
|
|
|
471
|
-
*
|
|
472
|
-
|
|
473
467
|
#### Remarks
|
|
474
468
|
|
|
475
469
|
Time O(N log N), Space O(1)
|
|
@@ -492,7 +486,7 @@ Time O(N log N), Space O(1)
|
|
|
492
486
|
clear(): void;
|
|
493
487
|
```
|
|
494
488
|
|
|
495
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
489
|
+
Defined in: [data-structures/heap/heap.ts:469](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L469)
|
|
496
490
|
|
|
497
491
|
Remove all elements.
|
|
498
492
|
|
|
@@ -502,8 +496,6 @@ Remove all elements.
|
|
|
502
496
|
|
|
503
497
|
void
|
|
504
498
|
|
|
505
|
-
*
|
|
506
|
-
|
|
507
499
|
#### Remarks
|
|
508
500
|
|
|
509
501
|
Time O(1), Space O(1)
|
|
@@ -529,7 +521,7 @@ Time O(1), Space O(1)
|
|
|
529
521
|
clone(): this;
|
|
530
522
|
```
|
|
531
523
|
|
|
532
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
524
|
+
Defined in: [data-structures/heap/heap.ts:648](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L648)
|
|
533
525
|
|
|
534
526
|
Deep clone this heap.
|
|
535
527
|
|
|
@@ -539,8 +531,6 @@ Deep clone this heap.
|
|
|
539
531
|
|
|
540
532
|
A new heap with the same elements.
|
|
541
533
|
|
|
542
|
-
*
|
|
543
|
-
|
|
544
534
|
#### Remarks
|
|
545
535
|
|
|
546
536
|
Time O(N), Space O(N)
|
|
@@ -568,7 +558,7 @@ Time O(N), Space O(N)
|
|
|
568
558
|
delete(element): boolean;
|
|
569
559
|
```
|
|
570
560
|
|
|
571
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
561
|
+
Defined in: [data-structures/heap/heap.ts:500](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L500)
|
|
572
562
|
|
|
573
563
|
Delete one occurrence of an element.
|
|
574
564
|
|
|
@@ -586,8 +576,6 @@ Element to delete.
|
|
|
586
576
|
|
|
587
577
|
True if an element was removed.
|
|
588
578
|
|
|
589
|
-
*
|
|
590
|
-
|
|
591
579
|
#### Remarks
|
|
592
580
|
|
|
593
581
|
Time O(N), Space O(1)
|
|
@@ -609,7 +597,7 @@ Time O(N), Space O(1)
|
|
|
609
597
|
deleteBy(predicate): boolean;
|
|
610
598
|
```
|
|
611
599
|
|
|
612
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
600
|
+
Defined in: [data-structures/heap/heap.ts:524](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L524)
|
|
613
601
|
|
|
614
602
|
#### Parameters
|
|
615
603
|
|
|
@@ -633,7 +621,7 @@ Use `deleteWhere` instead. Will be removed in a future major version.
|
|
|
633
621
|
deleteWhere(predicate): boolean;
|
|
634
622
|
```
|
|
635
623
|
|
|
636
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
624
|
+
Defined in: [data-structures/heap/heap.ts:534](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L534)
|
|
637
625
|
|
|
638
626
|
Delete the first element that matches a predicate.
|
|
639
627
|
|
|
@@ -663,7 +651,7 @@ Time O(N), Space O(1)
|
|
|
663
651
|
dfs(order?): E[];
|
|
664
652
|
```
|
|
665
653
|
|
|
666
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
654
|
+
Defined in: [data-structures/heap/heap.ts:577](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L577)
|
|
667
655
|
|
|
668
656
|
Traverse the binary heap as a complete binary tree and collect elements.
|
|
669
657
|
|
|
@@ -681,8 +669,6 @@ Traversal order: 'PRE' | 'IN' | 'POST'.
|
|
|
681
669
|
|
|
682
670
|
Array of visited elements.
|
|
683
671
|
|
|
684
|
-
*
|
|
685
|
-
|
|
686
672
|
#### Remarks
|
|
687
673
|
|
|
688
674
|
Time O(N), Space O(H)
|
|
@@ -698,6 +684,30 @@ Time O(N), Space O(H)
|
|
|
698
684
|
|
|
699
685
|
***
|
|
700
686
|
|
|
687
|
+
### entries()
|
|
688
|
+
|
|
689
|
+
```ts
|
|
690
|
+
entries(): IterableIterator<[number, E]>;
|
|
691
|
+
```
|
|
692
|
+
|
|
693
|
+
Defined in: [data-structures/base/iterable-element-base.ts:207](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L207)
|
|
694
|
+
|
|
695
|
+
Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
696
|
+
|
|
697
|
+
#### Returns
|
|
698
|
+
|
|
699
|
+
`IterableIterator`\<\[`number`, `E`\]\>
|
|
700
|
+
|
|
701
|
+
#### Remarks
|
|
702
|
+
|
|
703
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
704
|
+
|
|
705
|
+
#### Inherited from
|
|
706
|
+
|
|
707
|
+
[`IterableElementBase`](IterableElementBase.md).[`entries`](IterableElementBase.md#entries)
|
|
708
|
+
|
|
709
|
+
***
|
|
710
|
+
|
|
701
711
|
### every()
|
|
702
712
|
|
|
703
713
|
```ts
|
|
@@ -744,7 +754,7 @@ Time O(n) in the worst case; may exit early when the first failure is found. Spa
|
|
|
744
754
|
filter(callback, thisArg?): this;
|
|
745
755
|
```
|
|
746
756
|
|
|
747
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
757
|
+
Defined in: [data-structures/heap/heap.ts:666](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L666)
|
|
748
758
|
|
|
749
759
|
Filter elements into a new heap of the same class.
|
|
750
760
|
|
|
@@ -768,8 +778,6 @@ Value for `this` inside the callback.
|
|
|
768
778
|
|
|
769
779
|
A new heap with the kept elements.
|
|
770
780
|
|
|
771
|
-
*
|
|
772
|
-
|
|
773
781
|
#### Remarks
|
|
774
782
|
|
|
775
783
|
Time O(N log N), Space O(N)
|
|
@@ -885,7 +893,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
|
885
893
|
fix(): boolean[];
|
|
886
894
|
```
|
|
887
895
|
|
|
888
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
896
|
+
Defined in: [data-structures/heap/heap.ts:607](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L607)
|
|
889
897
|
|
|
890
898
|
Restore heap order bottom-up (heapify in-place).
|
|
891
899
|
|
|
@@ -947,7 +955,7 @@ Time O(n), Space O(1).
|
|
|
947
955
|
has(element): boolean;
|
|
948
956
|
```
|
|
949
957
|
|
|
950
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
958
|
+
Defined in: [data-structures/heap/heap.ts:484](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L484)
|
|
951
959
|
|
|
952
960
|
Check if an equal element exists in the heap.
|
|
953
961
|
|
|
@@ -965,8 +973,6 @@ Element to search for.
|
|
|
965
973
|
|
|
966
974
|
True if found.
|
|
967
975
|
|
|
968
|
-
*
|
|
969
|
-
|
|
970
976
|
#### Remarks
|
|
971
977
|
|
|
972
978
|
Time O(N), Space O(1)
|
|
@@ -986,13 +992,47 @@ Time O(N), Space O(1)
|
|
|
986
992
|
|
|
987
993
|
***
|
|
988
994
|
|
|
995
|
+
### includes()
|
|
996
|
+
|
|
997
|
+
```ts
|
|
998
|
+
includes(element): boolean;
|
|
999
|
+
```
|
|
1000
|
+
|
|
1001
|
+
Defined in: [data-structures/base/iterable-element-base.ts:199](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L199)
|
|
1002
|
+
|
|
1003
|
+
Check whether a value exists (Array-compatible alias for `has`).
|
|
1004
|
+
|
|
1005
|
+
#### Parameters
|
|
1006
|
+
|
|
1007
|
+
##### element
|
|
1008
|
+
|
|
1009
|
+
`E`
|
|
1010
|
+
|
|
1011
|
+
Element to search for (uses `===`).
|
|
1012
|
+
|
|
1013
|
+
#### Returns
|
|
1014
|
+
|
|
1015
|
+
`boolean`
|
|
1016
|
+
|
|
1017
|
+
`true` if found.
|
|
1018
|
+
|
|
1019
|
+
#### Remarks
|
|
1020
|
+
|
|
1021
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
1022
|
+
|
|
1023
|
+
#### Inherited from
|
|
1024
|
+
|
|
1025
|
+
[`IterableElementBase`](IterableElementBase.md).[`includes`](IterableElementBase.md#includes)
|
|
1026
|
+
|
|
1027
|
+
***
|
|
1028
|
+
|
|
989
1029
|
### isEmpty()
|
|
990
1030
|
|
|
991
1031
|
```ts
|
|
992
1032
|
isEmpty(): boolean;
|
|
993
1033
|
```
|
|
994
1034
|
|
|
995
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1035
|
+
Defined in: [data-structures/heap/heap.ts:455](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L455)
|
|
996
1036
|
|
|
997
1037
|
Check whether the heap is empty.
|
|
998
1038
|
|
|
@@ -1002,8 +1042,6 @@ Check whether the heap is empty.
|
|
|
1002
1042
|
|
|
1003
1043
|
True if size is 0.
|
|
1004
1044
|
|
|
1005
|
-
*
|
|
1006
|
-
|
|
1007
1045
|
#### Remarks
|
|
1008
1046
|
|
|
1009
1047
|
Time O(1), Space O(1)
|
|
@@ -1024,6 +1062,30 @@ Time O(1), Space O(1)
|
|
|
1024
1062
|
|
|
1025
1063
|
***
|
|
1026
1064
|
|
|
1065
|
+
### keys()
|
|
1066
|
+
|
|
1067
|
+
```ts
|
|
1068
|
+
keys(): IterableIterator<number>;
|
|
1069
|
+
```
|
|
1070
|
+
|
|
1071
|
+
Defined in: [data-structures/base/iterable-element-base.ts:218](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L218)
|
|
1072
|
+
|
|
1073
|
+
Return an iterator of numeric indices (Array-compatible).
|
|
1074
|
+
|
|
1075
|
+
#### Returns
|
|
1076
|
+
|
|
1077
|
+
`IterableIterator`\<`number`\>
|
|
1078
|
+
|
|
1079
|
+
#### Remarks
|
|
1080
|
+
|
|
1081
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
1082
|
+
|
|
1083
|
+
#### Inherited from
|
|
1084
|
+
|
|
1085
|
+
[`IterableElementBase`](IterableElementBase.md).[`keys`](IterableElementBase.md#keys)
|
|
1086
|
+
|
|
1087
|
+
***
|
|
1088
|
+
|
|
1027
1089
|
### map()
|
|
1028
1090
|
|
|
1029
1091
|
```ts
|
|
@@ -1033,7 +1095,7 @@ map<EM, RM>(
|
|
|
1033
1095
|
thisArg?): Heap<EM, RM>;
|
|
1034
1096
|
```
|
|
1035
1097
|
|
|
1036
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1098
|
+
Defined in: [data-structures/heap/heap.ts:694](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L694)
|
|
1037
1099
|
|
|
1038
1100
|
Map elements into a new heap of possibly different element type.
|
|
1039
1101
|
|
|
@@ -1073,8 +1135,6 @@ Value for `this` inside the callback.
|
|
|
1073
1135
|
|
|
1074
1136
|
A new heap with mapped elements.
|
|
1075
1137
|
|
|
1076
|
-
*
|
|
1077
|
-
|
|
1078
1138
|
#### Remarks
|
|
1079
1139
|
|
|
1080
1140
|
Time O(N log N), Space O(N)
|
|
@@ -1100,7 +1160,7 @@ Time O(N log N), Space O(N)
|
|
|
1100
1160
|
mapSame(callback, thisArg?): this;
|
|
1101
1161
|
```
|
|
1102
1162
|
|
|
1103
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1163
|
+
Defined in: [data-structures/heap/heap.ts:717](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L717)
|
|
1104
1164
|
|
|
1105
1165
|
Map elements into a new heap of the same element type.
|
|
1106
1166
|
|
|
@@ -1140,7 +1200,7 @@ Time O(N log N), Space O(N)
|
|
|
1140
1200
|
peek(): E | undefined;
|
|
1141
1201
|
```
|
|
1142
1202
|
|
|
1143
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1203
|
+
Defined in: [data-structures/heap/heap.ts:440](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L440)
|
|
1144
1204
|
|
|
1145
1205
|
Get the current top element without removing it.
|
|
1146
1206
|
|
|
@@ -1150,8 +1210,6 @@ Get the current top element without removing it.
|
|
|
1150
1210
|
|
|
1151
1211
|
Top element or undefined.
|
|
1152
1212
|
|
|
1153
|
-
*
|
|
1154
|
-
|
|
1155
1213
|
#### Remarks
|
|
1156
1214
|
|
|
1157
1215
|
Time O(1), Space O(1)
|
|
@@ -1227,7 +1285,7 @@ Time O(1), Space O(1)
|
|
|
1227
1285
|
poll(): E | undefined;
|
|
1228
1286
|
```
|
|
1229
1287
|
|
|
1230
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1288
|
+
Defined in: [data-structures/heap/heap.ts:356](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L356)
|
|
1231
1289
|
|
|
1232
1290
|
#### Returns
|
|
1233
1291
|
|
|
@@ -1236,7 +1294,6 @@ Defined in: [data-structures/heap/heap.ts:511](https://github.com/zrwusa/data-st
|
|
|
1236
1294
|
#### Deprecated
|
|
1237
1295
|
|
|
1238
1296
|
Use `pop` instead. Will be removed in a future major version.
|
|
1239
|
-
*
|
|
1240
1297
|
|
|
1241
1298
|
#### Example
|
|
1242
1299
|
|
|
@@ -1275,7 +1332,7 @@ Use `pop` instead. Will be removed in a future major version.
|
|
|
1275
1332
|
pop(): E | undefined;
|
|
1276
1333
|
```
|
|
1277
1334
|
|
|
1278
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1335
|
+
Defined in: [data-structures/heap/heap.ts:365](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L365)
|
|
1279
1336
|
|
|
1280
1337
|
Remove and return the top element (min or max depending on comparator).
|
|
1281
1338
|
|
|
@@ -1297,7 +1354,7 @@ Time O(log N) amortized, Space O(1)
|
|
|
1297
1354
|
print(): void;
|
|
1298
1355
|
```
|
|
1299
1356
|
|
|
1300
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1357
|
+
Defined in: [data-structures/base/iterable-element-base.ts:298](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L298)
|
|
1301
1358
|
|
|
1302
1359
|
Prints `toVisual()` to the console. Intended for quick debugging.
|
|
1303
1360
|
|
|
@@ -1355,7 +1412,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
|
|
|
1355
1412
|
reduce(callbackfn): E;
|
|
1356
1413
|
```
|
|
1357
1414
|
|
|
1358
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1415
|
+
Defined in: [data-structures/base/iterable-element-base.ts:225](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L225)
|
|
1359
1416
|
|
|
1360
1417
|
##### Parameters
|
|
1361
1418
|
|
|
@@ -1377,7 +1434,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
|
|
|
1377
1434
|
reduce(callbackfn, initialValue): E;
|
|
1378
1435
|
```
|
|
1379
1436
|
|
|
1380
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1437
|
+
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)
|
|
1381
1438
|
|
|
1382
1439
|
##### Parameters
|
|
1383
1440
|
|
|
@@ -1403,7 +1460,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
|
|
|
1403
1460
|
reduce<U>(callbackfn, initialValue): U;
|
|
1404
1461
|
```
|
|
1405
1462
|
|
|
1406
|
-
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)
|
|
1407
1464
|
|
|
1408
1465
|
##### Type Parameters
|
|
1409
1466
|
|
|
@@ -1437,7 +1494,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.c
|
|
|
1437
1494
|
setEquality(equals): this;
|
|
1438
1495
|
```
|
|
1439
1496
|
|
|
1440
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1497
|
+
Defined in: [data-structures/heap/heap.ts:561](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L561)
|
|
1441
1498
|
|
|
1442
1499
|
Set the equality comparator used by has/delete operations.
|
|
1443
1500
|
|
|
@@ -1507,7 +1564,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
|
|
|
1507
1564
|
sort(): E[];
|
|
1508
1565
|
```
|
|
1509
1566
|
|
|
1510
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1567
|
+
Defined in: [data-structures/heap/heap.ts:625](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L625)
|
|
1511
1568
|
|
|
1512
1569
|
Return all elements in ascending order by repeatedly polling.
|
|
1513
1570
|
|
|
@@ -1517,8 +1574,6 @@ Return all elements in ascending order by repeatedly polling.
|
|
|
1517
1574
|
|
|
1518
1575
|
Sorted array of elements.
|
|
1519
1576
|
|
|
1520
|
-
*
|
|
1521
|
-
|
|
1522
1577
|
#### Remarks
|
|
1523
1578
|
|
|
1524
1579
|
Time O(N log N), Space O(N)
|
|
@@ -1540,7 +1595,7 @@ Time O(N log N), Space O(N)
|
|
|
1540
1595
|
toArray(): E[];
|
|
1541
1596
|
```
|
|
1542
1597
|
|
|
1543
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1598
|
+
Defined in: [data-structures/base/iterable-element-base.ts:275](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L275)
|
|
1544
1599
|
|
|
1545
1600
|
Materializes the elements into a new array.
|
|
1546
1601
|
|
|
@@ -1566,7 +1621,7 @@ Time O(n), Space O(n).
|
|
|
1566
1621
|
toVisual(): E[];
|
|
1567
1622
|
```
|
|
1568
1623
|
|
|
1569
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1624
|
+
Defined in: [data-structures/base/iterable-element-base.ts:287](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L287)
|
|
1570
1625
|
|
|
1571
1626
|
Returns a representation of the structure suitable for quick visualization.
|
|
1572
1627
|
Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
@@ -1622,7 +1677,7 @@ static from<T, R, S>(
|
|
|
1622
1677
|
options?): S;
|
|
1623
1678
|
```
|
|
1624
1679
|
|
|
1625
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1680
|
+
Defined in: [data-structures/heap/heap.ts:225](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L225)
|
|
1626
1681
|
|
|
1627
1682
|
Create a heap of the same class from an iterable.
|
|
1628
1683
|
|
|
@@ -1676,7 +1731,7 @@ Time O(N), Space O(N)
|
|
|
1676
1731
|
static heapify<EE, RR>(elements, options): Heap<EE, RR>;
|
|
1677
1732
|
```
|
|
1678
1733
|
|
|
1679
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1734
|
+
Defined in: [data-structures/heap/heap.ts:242](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L242)
|
|
1680
1735
|
|
|
1681
1736
|
Build a Heap from an iterable in linear time given a comparator.
|
|
1682
1737
|
|
|
@@ -1755,7 +1810,7 @@ Time O(1), Space O(1).
|
|
|
1755
1810
|
protected _createInstance(options?): this;
|
|
1756
1811
|
```
|
|
1757
1812
|
|
|
1758
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1813
|
+
Defined in: [data-structures/heap/heap.ts:779](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L779)
|
|
1759
1814
|
|
|
1760
1815
|
(Protected) Create an empty instance of the same concrete class.
|
|
1761
1816
|
|
|
@@ -1785,7 +1840,7 @@ Time O(1), Space O(1)
|
|
|
1785
1840
|
protected _createLike<EM, RM>(elements?, options?): Heap<EM, RM>;
|
|
1786
1841
|
```
|
|
1787
1842
|
|
|
1788
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1843
|
+
Defined in: [data-structures/heap/heap.ts:793](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L793)
|
|
1789
1844
|
|
|
1790
1845
|
(Protected) Create a like-kind instance seeded by elements.
|
|
1791
1846
|
|
|
@@ -1831,7 +1886,7 @@ Time O(N log N), Space O(N)
|
|
|
1831
1886
|
protected _getIterator(): IterableIterator<E>;
|
|
1832
1887
|
```
|
|
1833
1888
|
|
|
1834
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1889
|
+
Defined in: [data-structures/heap/heap.ts:738](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L738)
|
|
1835
1890
|
|
|
1836
1891
|
Internal iterator factory used by the default iterator.
|
|
1837
1892
|
|
|
@@ -1857,7 +1912,7 @@ Implementations should yield in O(1) per element with O(1) extra space when poss
|
|
|
1857
1912
|
protected _spawnLike<EM, RM>(options?): Heap<EM, RM>;
|
|
1858
1913
|
```
|
|
1859
1914
|
|
|
1860
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1915
|
+
Defined in: [data-structures/heap/heap.ts:812](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L812)
|
|
1861
1916
|
|
|
1862
1917
|
(Protected) Spawn an empty like-kind heap instance.
|
|
1863
1918
|
|