data-structure-typed 2.6.1 → 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/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 +72 -104
- package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +60 -80
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +67 -101
- 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 +40 -68
- package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +17 -17
- package/docs-site-docusaurus/docs/api/classes/LinearBase.md +38 -38
- package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +45 -45
- package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +23 -23
- package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +68 -96
- 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 +38 -66
- package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +41 -74
- package/docs-site-docusaurus/docs/api/classes/MinHeap.md +38 -66
- package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +46 -79
- package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +40 -68
- package/docs-site-docusaurus/docs/api/classes/Queue.md +54 -78
- 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 +68 -98
- 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 +33 -53
- package/docs-site-docusaurus/docs/api/classes/TreeMap.md +104 -129
- package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +57 -124
- package/docs-site-docusaurus/docs/api/classes/TreeSet.md +45 -116
- package/docs-site-docusaurus/docs/api/classes/Trie.md +37 -61
- 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 +1 -1
- package/src/data-structures/binary-tree/tree-multi-set.ts +15 -11
|
@@ -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)
|
|
@@ -704,7 +690,7 @@ Time O(N), Space O(H)
|
|
|
704
690
|
entries(): IterableIterator<[number, E]>;
|
|
705
691
|
```
|
|
706
692
|
|
|
707
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
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)
|
|
708
694
|
|
|
709
695
|
Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
710
696
|
|
|
@@ -768,7 +754,7 @@ Time O(n) in the worst case; may exit early when the first failure is found. Spa
|
|
|
768
754
|
filter(callback, thisArg?): this;
|
|
769
755
|
```
|
|
770
756
|
|
|
771
|
-
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)
|
|
772
758
|
|
|
773
759
|
Filter elements into a new heap of the same class.
|
|
774
760
|
|
|
@@ -792,8 +778,6 @@ Value for `this` inside the callback.
|
|
|
792
778
|
|
|
793
779
|
A new heap with the kept elements.
|
|
794
780
|
|
|
795
|
-
*
|
|
796
|
-
|
|
797
781
|
#### Remarks
|
|
798
782
|
|
|
799
783
|
Time O(N log N), Space O(N)
|
|
@@ -909,7 +893,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
|
909
893
|
fix(): boolean[];
|
|
910
894
|
```
|
|
911
895
|
|
|
912
|
-
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)
|
|
913
897
|
|
|
914
898
|
Restore heap order bottom-up (heapify in-place).
|
|
915
899
|
|
|
@@ -971,7 +955,7 @@ Time O(n), Space O(1).
|
|
|
971
955
|
has(element): boolean;
|
|
972
956
|
```
|
|
973
957
|
|
|
974
|
-
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)
|
|
975
959
|
|
|
976
960
|
Check if an equal element exists in the heap.
|
|
977
961
|
|
|
@@ -989,8 +973,6 @@ Element to search for.
|
|
|
989
973
|
|
|
990
974
|
True if found.
|
|
991
975
|
|
|
992
|
-
*
|
|
993
|
-
|
|
994
976
|
#### Remarks
|
|
995
977
|
|
|
996
978
|
Time O(N), Space O(1)
|
|
@@ -1016,7 +998,7 @@ Time O(N), Space O(1)
|
|
|
1016
998
|
includes(element): boolean;
|
|
1017
999
|
```
|
|
1018
1000
|
|
|
1019
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
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)
|
|
1020
1002
|
|
|
1021
1003
|
Check whether a value exists (Array-compatible alias for `has`).
|
|
1022
1004
|
|
|
@@ -1050,7 +1032,7 @@ Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
|
1050
1032
|
isEmpty(): boolean;
|
|
1051
1033
|
```
|
|
1052
1034
|
|
|
1053
|
-
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)
|
|
1054
1036
|
|
|
1055
1037
|
Check whether the heap is empty.
|
|
1056
1038
|
|
|
@@ -1060,8 +1042,6 @@ Check whether the heap is empty.
|
|
|
1060
1042
|
|
|
1061
1043
|
True if size is 0.
|
|
1062
1044
|
|
|
1063
|
-
*
|
|
1064
|
-
|
|
1065
1045
|
#### Remarks
|
|
1066
1046
|
|
|
1067
1047
|
Time O(1), Space O(1)
|
|
@@ -1088,7 +1068,7 @@ Time O(1), Space O(1)
|
|
|
1088
1068
|
keys(): IterableIterator<number>;
|
|
1089
1069
|
```
|
|
1090
1070
|
|
|
1091
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
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)
|
|
1092
1072
|
|
|
1093
1073
|
Return an iterator of numeric indices (Array-compatible).
|
|
1094
1074
|
|
|
@@ -1115,7 +1095,7 @@ map<EM, RM>(
|
|
|
1115
1095
|
thisArg?): Heap<EM, RM>;
|
|
1116
1096
|
```
|
|
1117
1097
|
|
|
1118
|
-
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)
|
|
1119
1099
|
|
|
1120
1100
|
Map elements into a new heap of possibly different element type.
|
|
1121
1101
|
|
|
@@ -1155,8 +1135,6 @@ Value for `this` inside the callback.
|
|
|
1155
1135
|
|
|
1156
1136
|
A new heap with mapped elements.
|
|
1157
1137
|
|
|
1158
|
-
*
|
|
1159
|
-
|
|
1160
1138
|
#### Remarks
|
|
1161
1139
|
|
|
1162
1140
|
Time O(N log N), Space O(N)
|
|
@@ -1182,7 +1160,7 @@ Time O(N log N), Space O(N)
|
|
|
1182
1160
|
mapSame(callback, thisArg?): this;
|
|
1183
1161
|
```
|
|
1184
1162
|
|
|
1185
|
-
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)
|
|
1186
1164
|
|
|
1187
1165
|
Map elements into a new heap of the same element type.
|
|
1188
1166
|
|
|
@@ -1222,7 +1200,7 @@ Time O(N log N), Space O(N)
|
|
|
1222
1200
|
peek(): E | undefined;
|
|
1223
1201
|
```
|
|
1224
1202
|
|
|
1225
|
-
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)
|
|
1226
1204
|
|
|
1227
1205
|
Get the current top element without removing it.
|
|
1228
1206
|
|
|
@@ -1232,8 +1210,6 @@ Get the current top element without removing it.
|
|
|
1232
1210
|
|
|
1233
1211
|
Top element or undefined.
|
|
1234
1212
|
|
|
1235
|
-
*
|
|
1236
|
-
|
|
1237
1213
|
#### Remarks
|
|
1238
1214
|
|
|
1239
1215
|
Time O(1), Space O(1)
|
|
@@ -1309,7 +1285,7 @@ Time O(1), Space O(1)
|
|
|
1309
1285
|
poll(): E | undefined;
|
|
1310
1286
|
```
|
|
1311
1287
|
|
|
1312
|
-
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)
|
|
1313
1289
|
|
|
1314
1290
|
#### Returns
|
|
1315
1291
|
|
|
@@ -1319,8 +1295,6 @@ Defined in: [data-structures/heap/heap.ts:523](https://github.com/zrwusa/data-st
|
|
|
1319
1295
|
|
|
1320
1296
|
Use `pop` instead. Will be removed in a future major version.
|
|
1321
1297
|
|
|
1322
|
-
*
|
|
1323
|
-
|
|
1324
1298
|
#### Example
|
|
1325
1299
|
|
|
1326
1300
|
```ts
|
|
@@ -1358,7 +1332,7 @@ Use `pop` instead. Will be removed in a future major version.
|
|
|
1358
1332
|
pop(): E | undefined;
|
|
1359
1333
|
```
|
|
1360
1334
|
|
|
1361
|
-
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)
|
|
1362
1336
|
|
|
1363
1337
|
Remove and return the top element (min or max depending on comparator).
|
|
1364
1338
|
|
|
@@ -1380,7 +1354,7 @@ Time O(log N) amortized, Space O(1)
|
|
|
1380
1354
|
print(): void;
|
|
1381
1355
|
```
|
|
1382
1356
|
|
|
1383
|
-
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)
|
|
1384
1358
|
|
|
1385
1359
|
Prints `toVisual()` to the console. Intended for quick debugging.
|
|
1386
1360
|
|
|
@@ -1438,7 +1412,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
|
|
|
1438
1412
|
reduce(callbackfn): E;
|
|
1439
1413
|
```
|
|
1440
1414
|
|
|
1441
|
-
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)
|
|
1442
1416
|
|
|
1443
1417
|
##### Parameters
|
|
1444
1418
|
|
|
@@ -1460,7 +1434,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:226](https://github.c
|
|
|
1460
1434
|
reduce(callbackfn, initialValue): E;
|
|
1461
1435
|
```
|
|
1462
1436
|
|
|
1463
|
-
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)
|
|
1464
1438
|
|
|
1465
1439
|
##### Parameters
|
|
1466
1440
|
|
|
@@ -1486,7 +1460,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:227](https://github.c
|
|
|
1486
1460
|
reduce<U>(callbackfn, initialValue): U;
|
|
1487
1461
|
```
|
|
1488
1462
|
|
|
1489
|
-
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)
|
|
1490
1464
|
|
|
1491
1465
|
##### Type Parameters
|
|
1492
1466
|
|
|
@@ -1520,7 +1494,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:228](https://github.c
|
|
|
1520
1494
|
setEquality(equals): this;
|
|
1521
1495
|
```
|
|
1522
1496
|
|
|
1523
|
-
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)
|
|
1524
1498
|
|
|
1525
1499
|
Set the equality comparator used by has/delete operations.
|
|
1526
1500
|
|
|
@@ -1590,7 +1564,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
|
|
|
1590
1564
|
sort(): E[];
|
|
1591
1565
|
```
|
|
1592
1566
|
|
|
1593
|
-
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)
|
|
1594
1568
|
|
|
1595
1569
|
Return all elements in ascending order by repeatedly polling.
|
|
1596
1570
|
|
|
@@ -1600,8 +1574,6 @@ Return all elements in ascending order by repeatedly polling.
|
|
|
1600
1574
|
|
|
1601
1575
|
Sorted array of elements.
|
|
1602
1576
|
|
|
1603
|
-
*
|
|
1604
|
-
|
|
1605
1577
|
#### Remarks
|
|
1606
1578
|
|
|
1607
1579
|
Time O(N log N), Space O(N)
|
|
@@ -1623,7 +1595,7 @@ Time O(N log N), Space O(N)
|
|
|
1623
1595
|
toArray(): E[];
|
|
1624
1596
|
```
|
|
1625
1597
|
|
|
1626
|
-
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)
|
|
1627
1599
|
|
|
1628
1600
|
Materializes the elements into a new array.
|
|
1629
1601
|
|
|
@@ -1649,7 +1621,7 @@ Time O(n), Space O(n).
|
|
|
1649
1621
|
toVisual(): E[];
|
|
1650
1622
|
```
|
|
1651
1623
|
|
|
1652
|
-
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)
|
|
1653
1625
|
|
|
1654
1626
|
Returns a representation of the structure suitable for quick visualization.
|
|
1655
1627
|
Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
@@ -1705,7 +1677,7 @@ static from<T, R, S>(
|
|
|
1705
1677
|
options?): S;
|
|
1706
1678
|
```
|
|
1707
1679
|
|
|
1708
|
-
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)
|
|
1709
1681
|
|
|
1710
1682
|
Create a heap of the same class from an iterable.
|
|
1711
1683
|
|
|
@@ -1759,7 +1731,7 @@ Time O(N), Space O(N)
|
|
|
1759
1731
|
static heapify<EE, RR>(elements, options): Heap<EE, RR>;
|
|
1760
1732
|
```
|
|
1761
1733
|
|
|
1762
|
-
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)
|
|
1763
1735
|
|
|
1764
1736
|
Build a Heap from an iterable in linear time given a comparator.
|
|
1765
1737
|
|
|
@@ -1838,7 +1810,7 @@ Time O(1), Space O(1).
|
|
|
1838
1810
|
protected _createInstance(options?): this;
|
|
1839
1811
|
```
|
|
1840
1812
|
|
|
1841
|
-
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)
|
|
1842
1814
|
|
|
1843
1815
|
(Protected) Create an empty instance of the same concrete class.
|
|
1844
1816
|
|
|
@@ -1868,7 +1840,7 @@ Time O(1), Space O(1)
|
|
|
1868
1840
|
protected _createLike<EM, RM>(elements?, options?): Heap<EM, RM>;
|
|
1869
1841
|
```
|
|
1870
1842
|
|
|
1871
|
-
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)
|
|
1872
1844
|
|
|
1873
1845
|
(Protected) Create a like-kind instance seeded by elements.
|
|
1874
1846
|
|
|
@@ -1914,7 +1886,7 @@ Time O(N log N), Space O(N)
|
|
|
1914
1886
|
protected _getIterator(): IterableIterator<E>;
|
|
1915
1887
|
```
|
|
1916
1888
|
|
|
1917
|
-
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)
|
|
1918
1890
|
|
|
1919
1891
|
Internal iterator factory used by the default iterator.
|
|
1920
1892
|
|
|
@@ -1940,7 +1912,7 @@ Implementations should yield in O(1) per element with O(1) extra space when poss
|
|
|
1940
1912
|
protected _spawnLike<EM, RM>(options?): Heap<EM, RM>;
|
|
1941
1913
|
```
|
|
1942
1914
|
|
|
1943
|
-
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)
|
|
1944
1916
|
|
|
1945
1917
|
(Protected) Spawn an empty like-kind heap instance.
|
|
1946
1918
|
|
|
@@ -109,7 +109,7 @@ Iterable.[iterator]
|
|
|
109
109
|
abstract clear(): void;
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
112
|
+
Defined in: [data-structures/base/iterable-element-base.ts:318](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L318)
|
|
113
113
|
|
|
114
114
|
Removes all elements from the structure.
|
|
115
115
|
|
|
@@ -131,7 +131,7 @@ Expected Time O(1) or O(n) depending on the implementation; Space O(1).
|
|
|
131
131
|
abstract clone(): this;
|
|
132
132
|
```
|
|
133
133
|
|
|
134
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
134
|
+
Defined in: [data-structures/base/iterable-element-base.ts:327](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L327)
|
|
135
135
|
|
|
136
136
|
Creates a structural copy with the same element values and configuration.
|
|
137
137
|
|
|
@@ -153,7 +153,7 @@ Expected Time O(n) to copy elements; Space O(n).
|
|
|
153
153
|
entries(): IterableIterator<[number, E]>;
|
|
154
154
|
```
|
|
155
155
|
|
|
156
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
156
|
+
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)
|
|
157
157
|
|
|
158
158
|
Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
159
159
|
|
|
@@ -209,7 +209,7 @@ Time O(n) in the worst case; may exit early when the first failure is found. Spa
|
|
|
209
209
|
abstract filter(predicate, thisArg?): this;
|
|
210
210
|
```
|
|
211
211
|
|
|
212
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
212
|
+
Defined in: [data-structures/base/iterable-element-base.ts:370](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L370)
|
|
213
213
|
|
|
214
214
|
Filters elements using the provided predicate and returns the same concrete structure type.
|
|
215
215
|
|
|
@@ -363,7 +363,7 @@ Time O(n), Space O(1).
|
|
|
363
363
|
has(element): boolean;
|
|
364
364
|
```
|
|
365
365
|
|
|
366
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
366
|
+
Defined in: [data-structures/base/iterable-element-base.ts:188](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L188)
|
|
367
367
|
|
|
368
368
|
Checks whether a strictly-equal element exists in the structure.
|
|
369
369
|
|
|
@@ -393,7 +393,7 @@ Time O(n) in the worst case. Space O(1).
|
|
|
393
393
|
includes(element): boolean;
|
|
394
394
|
```
|
|
395
395
|
|
|
396
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
396
|
+
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)
|
|
397
397
|
|
|
398
398
|
Check whether a value exists (Array-compatible alias for `has`).
|
|
399
399
|
|
|
@@ -423,7 +423,7 @@ Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
|
423
423
|
abstract isEmpty(): boolean;
|
|
424
424
|
```
|
|
425
425
|
|
|
426
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
426
|
+
Defined in: [data-structures/base/iterable-element-base.ts:309](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L309)
|
|
427
427
|
|
|
428
428
|
Indicates whether the structure currently contains no elements.
|
|
429
429
|
|
|
@@ -445,7 +445,7 @@ Expected Time O(1), Space O(1) for most implementations.
|
|
|
445
445
|
keys(): IterableIterator<number>;
|
|
446
446
|
```
|
|
447
447
|
|
|
448
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
448
|
+
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)
|
|
449
449
|
|
|
450
450
|
Return an iterator of numeric indices (Array-compatible).
|
|
451
451
|
|
|
@@ -468,7 +468,7 @@ abstract map<EM, RM>(
|
|
|
468
468
|
thisArg?): IterableElementBase<EM, RM>;
|
|
469
469
|
```
|
|
470
470
|
|
|
471
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
471
|
+
Defined in: [data-structures/base/iterable-element-base.ts:342](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L342)
|
|
472
472
|
|
|
473
473
|
Maps each element to a new element and returns a new iterable structure.
|
|
474
474
|
|
|
@@ -524,7 +524,7 @@ Time O(n), Space O(n).
|
|
|
524
524
|
abstract mapSame(callback, thisArg?): this;
|
|
525
525
|
```
|
|
526
526
|
|
|
527
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
527
|
+
Defined in: [data-structures/base/iterable-element-base.ts:358](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L358)
|
|
528
528
|
|
|
529
529
|
Maps each element to the same element type and returns the same concrete structure type.
|
|
530
530
|
|
|
@@ -560,7 +560,7 @@ Time O(n), Space O(n).
|
|
|
560
560
|
print(): void;
|
|
561
561
|
```
|
|
562
562
|
|
|
563
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
563
|
+
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)
|
|
564
564
|
|
|
565
565
|
Prints `toVisual()` to the console. Intended for quick debugging.
|
|
566
566
|
|
|
@@ -614,7 +614,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
|
|
|
614
614
|
reduce(callbackfn): E;
|
|
615
615
|
```
|
|
616
616
|
|
|
617
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
617
|
+
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)
|
|
618
618
|
|
|
619
619
|
##### Parameters
|
|
620
620
|
|
|
@@ -632,7 +632,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:226](https://github.c
|
|
|
632
632
|
reduce(callbackfn, initialValue): E;
|
|
633
633
|
```
|
|
634
634
|
|
|
635
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
635
|
+
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)
|
|
636
636
|
|
|
637
637
|
##### Parameters
|
|
638
638
|
|
|
@@ -654,7 +654,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:227](https://github.c
|
|
|
654
654
|
reduce<U>(callbackfn, initialValue): U;
|
|
655
655
|
```
|
|
656
656
|
|
|
657
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
657
|
+
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)
|
|
658
658
|
|
|
659
659
|
##### Type Parameters
|
|
660
660
|
|
|
@@ -720,7 +720,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
|
|
|
720
720
|
toArray(): E[];
|
|
721
721
|
```
|
|
722
722
|
|
|
723
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
723
|
+
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)
|
|
724
724
|
|
|
725
725
|
Materializes the elements into a new array.
|
|
726
726
|
|
|
@@ -742,7 +742,7 @@ Time O(n), Space O(n).
|
|
|
742
742
|
toVisual(): E[];
|
|
743
743
|
```
|
|
744
744
|
|
|
745
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
745
|
+
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)
|
|
746
746
|
|
|
747
747
|
Returns a representation of the structure suitable for quick visualization.
|
|
748
748
|
Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
@@ -845,7 +845,7 @@ Time O(1), Space O(1).
|
|
|
845
845
|
abstract protected _getIterator(...args): IterableIterator<E>;
|
|
846
846
|
```
|
|
847
847
|
|
|
848
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
848
|
+
Defined in: [data-structures/base/iterable-element-base.ts:381](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L381)
|
|
849
849
|
|
|
850
850
|
Internal iterator factory used by the default iterator.
|
|
851
851
|
|