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: PriorityQueue\<E, R\>
|
|
8
8
|
|
|
9
|
-
Defined in: [data-structures/priority-queue/priority-queue.ts:
|
|
9
|
+
Defined in: [data-structures/priority-queue/priority-queue.ts:74](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/priority-queue/priority-queue.ts#L74)
|
|
10
10
|
|
|
11
11
|
## Examples
|
|
12
12
|
|
|
@@ -66,7 +66,7 @@ Defined in: [data-structures/priority-queue/priority-queue.ts:75](https://github
|
|
|
66
66
|
comparator: (a, b) => a[0] - b[0]
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
bandwidth.add([1, 'Video call']);
|
|
69
|
+
bandwidth.add([1, 'Video call']); // highest priority
|
|
70
70
|
bandwidth.add([3, 'File download']);
|
|
71
71
|
bandwidth.add([2, 'Web browsing']);
|
|
72
72
|
bandwidth.add([1, 'Voice call']);
|
|
@@ -106,7 +106,7 @@ Defined in: [data-structures/priority-queue/priority-queue.ts:75](https://github
|
|
|
106
106
|
get comparator(): Comparator<E>;
|
|
107
107
|
```
|
|
108
108
|
|
|
109
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
109
|
+
Defined in: [data-structures/heap/heap.ts:211](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L211)
|
|
110
110
|
|
|
111
111
|
Get the comparator used to order elements.
|
|
112
112
|
|
|
@@ -134,7 +134,7 @@ Comparator function.
|
|
|
134
134
|
get elements(): E[];
|
|
135
135
|
```
|
|
136
136
|
|
|
137
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
137
|
+
Defined in: [data-structures/heap/heap.ts:175](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L175)
|
|
138
138
|
|
|
139
139
|
Get the backing array of the heap.
|
|
140
140
|
|
|
@@ -162,7 +162,7 @@ Internal elements array.
|
|
|
162
162
|
get leaf(): E | undefined;
|
|
163
163
|
```
|
|
164
164
|
|
|
165
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
165
|
+
Defined in: [data-structures/heap/heap.ts:202](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L202)
|
|
166
166
|
|
|
167
167
|
Get the last leaf element.
|
|
168
168
|
|
|
@@ -190,7 +190,7 @@ Last element or undefined.
|
|
|
190
190
|
get size(): number;
|
|
191
191
|
```
|
|
192
192
|
|
|
193
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
193
|
+
Defined in: [data-structures/heap/heap.ts:193](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L193)
|
|
194
194
|
|
|
195
195
|
Get the number of elements.
|
|
196
196
|
|
|
@@ -217,8 +217,6 @@ Time O(1), Space O(1)
|
|
|
217
217
|
|
|
218
218
|
Heap size.
|
|
219
219
|
|
|
220
|
-
*
|
|
221
|
-
|
|
222
220
|
#### Inherited from
|
|
223
221
|
|
|
224
222
|
[`Heap`](Heap.md).[`size`](Heap.md#size)
|
|
@@ -293,7 +291,7 @@ Producing the iterator is O(1); consuming the entire iterator is Time O(n) with
|
|
|
293
291
|
add(element): boolean;
|
|
294
292
|
```
|
|
295
293
|
|
|
296
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
294
|
+
Defined in: [data-structures/heap/heap.ts:267](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L267)
|
|
297
295
|
|
|
298
296
|
Insert an element.
|
|
299
297
|
|
|
@@ -311,8 +309,6 @@ Element to insert.
|
|
|
311
309
|
|
|
312
310
|
True.
|
|
313
311
|
|
|
314
|
-
*
|
|
315
|
-
|
|
316
312
|
#### Remarks
|
|
317
313
|
|
|
318
314
|
Time O(log N) amortized, Space O(1)
|
|
@@ -348,7 +344,7 @@ Time O(log N) amortized, Space O(1)
|
|
|
348
344
|
addMany(elements): boolean[];
|
|
349
345
|
```
|
|
350
346
|
|
|
351
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
347
|
+
Defined in: [data-structures/heap/heap.ts:284](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L284)
|
|
352
348
|
|
|
353
349
|
Insert many elements from an iterable.
|
|
354
350
|
|
|
@@ -366,8 +362,6 @@ Iterable of elements or raw values.
|
|
|
366
362
|
|
|
367
363
|
Array of per-element success flags.
|
|
368
364
|
|
|
369
|
-
*
|
|
370
|
-
|
|
371
365
|
#### Remarks
|
|
372
366
|
|
|
373
367
|
Time O(N log N), Space O(1)
|
|
@@ -394,7 +388,7 @@ Time O(N log N), Space O(1)
|
|
|
394
388
|
clear(): void;
|
|
395
389
|
```
|
|
396
390
|
|
|
397
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
391
|
+
Defined in: [data-structures/heap/heap.ts:469](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L469)
|
|
398
392
|
|
|
399
393
|
Remove all elements.
|
|
400
394
|
|
|
@@ -404,8 +398,6 @@ Remove all elements.
|
|
|
404
398
|
|
|
405
399
|
void
|
|
406
400
|
|
|
407
|
-
*
|
|
408
|
-
|
|
409
401
|
#### Remarks
|
|
410
402
|
|
|
411
403
|
Time O(1), Space O(1)
|
|
@@ -431,7 +423,7 @@ Time O(1), Space O(1)
|
|
|
431
423
|
clone(): this;
|
|
432
424
|
```
|
|
433
425
|
|
|
434
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
426
|
+
Defined in: [data-structures/heap/heap.ts:648](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L648)
|
|
435
427
|
|
|
436
428
|
Deep clone this heap.
|
|
437
429
|
|
|
@@ -441,8 +433,6 @@ Deep clone this heap.
|
|
|
441
433
|
|
|
442
434
|
A new heap with the same elements.
|
|
443
435
|
|
|
444
|
-
*
|
|
445
|
-
|
|
446
436
|
#### Remarks
|
|
447
437
|
|
|
448
438
|
Time O(N), Space O(N)
|
|
@@ -470,7 +460,7 @@ Time O(N), Space O(N)
|
|
|
470
460
|
delete(element): boolean;
|
|
471
461
|
```
|
|
472
462
|
|
|
473
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
463
|
+
Defined in: [data-structures/heap/heap.ts:500](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L500)
|
|
474
464
|
|
|
475
465
|
Delete one occurrence of an element.
|
|
476
466
|
|
|
@@ -488,8 +478,6 @@ Element to delete.
|
|
|
488
478
|
|
|
489
479
|
True if an element was removed.
|
|
490
480
|
|
|
491
|
-
*
|
|
492
|
-
|
|
493
481
|
#### Remarks
|
|
494
482
|
|
|
495
483
|
Time O(N), Space O(1)
|
|
@@ -515,7 +503,7 @@ Time O(N), Space O(1)
|
|
|
515
503
|
deleteBy(predicate): boolean;
|
|
516
504
|
```
|
|
517
505
|
|
|
518
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
506
|
+
Defined in: [data-structures/heap/heap.ts:524](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L524)
|
|
519
507
|
|
|
520
508
|
#### Parameters
|
|
521
509
|
|
|
@@ -543,7 +531,7 @@ Use `deleteWhere` instead. Will be removed in a future major version.
|
|
|
543
531
|
deleteWhere(predicate): boolean;
|
|
544
532
|
```
|
|
545
533
|
|
|
546
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
534
|
+
Defined in: [data-structures/heap/heap.ts:534](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L534)
|
|
547
535
|
|
|
548
536
|
Delete the first element that matches a predicate.
|
|
549
537
|
|
|
@@ -577,7 +565,7 @@ Time O(N), Space O(1)
|
|
|
577
565
|
dfs(order?): E[];
|
|
578
566
|
```
|
|
579
567
|
|
|
580
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
568
|
+
Defined in: [data-structures/heap/heap.ts:577](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L577)
|
|
581
569
|
|
|
582
570
|
Traverse the binary heap as a complete binary tree and collect elements.
|
|
583
571
|
|
|
@@ -595,8 +583,6 @@ Traversal order: 'PRE' | 'IN' | 'POST'.
|
|
|
595
583
|
|
|
596
584
|
Array of visited elements.
|
|
597
585
|
|
|
598
|
-
*
|
|
599
|
-
|
|
600
586
|
#### Remarks
|
|
601
587
|
|
|
602
588
|
Time O(N), Space O(H)
|
|
@@ -622,7 +608,7 @@ Time O(N), Space O(H)
|
|
|
622
608
|
entries(): IterableIterator<[number, E]>;
|
|
623
609
|
```
|
|
624
610
|
|
|
625
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
611
|
+
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)
|
|
626
612
|
|
|
627
613
|
Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
628
614
|
|
|
@@ -686,7 +672,7 @@ Time O(n) in the worst case; may exit early when the first failure is found. Spa
|
|
|
686
672
|
filter(callback, thisArg?): this;
|
|
687
673
|
```
|
|
688
674
|
|
|
689
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
675
|
+
Defined in: [data-structures/heap/heap.ts:666](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L666)
|
|
690
676
|
|
|
691
677
|
Filter elements into a new heap of the same class.
|
|
692
678
|
|
|
@@ -710,8 +696,6 @@ Value for `this` inside the callback.
|
|
|
710
696
|
|
|
711
697
|
A new heap with the kept elements.
|
|
712
698
|
|
|
713
|
-
*
|
|
714
|
-
|
|
715
699
|
#### Remarks
|
|
716
700
|
|
|
717
701
|
Time O(N log N), Space O(N)
|
|
@@ -827,7 +811,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
|
827
811
|
fix(): boolean[];
|
|
828
812
|
```
|
|
829
813
|
|
|
830
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
814
|
+
Defined in: [data-structures/heap/heap.ts:607](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L607)
|
|
831
815
|
|
|
832
816
|
Restore heap order bottom-up (heapify in-place).
|
|
833
817
|
|
|
@@ -893,7 +877,7 @@ Time O(n), Space O(1).
|
|
|
893
877
|
has(element): boolean;
|
|
894
878
|
```
|
|
895
879
|
|
|
896
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
880
|
+
Defined in: [data-structures/heap/heap.ts:484](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L484)
|
|
897
881
|
|
|
898
882
|
Check if an equal element exists in the heap.
|
|
899
883
|
|
|
@@ -911,8 +895,6 @@ Element to search for.
|
|
|
911
895
|
|
|
912
896
|
True if found.
|
|
913
897
|
|
|
914
|
-
*
|
|
915
|
-
|
|
916
898
|
#### Remarks
|
|
917
899
|
|
|
918
900
|
Time O(N), Space O(1)
|
|
@@ -938,7 +920,7 @@ Time O(N), Space O(1)
|
|
|
938
920
|
includes(element): boolean;
|
|
939
921
|
```
|
|
940
922
|
|
|
941
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
923
|
+
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)
|
|
942
924
|
|
|
943
925
|
Check whether a value exists (Array-compatible alias for `has`).
|
|
944
926
|
|
|
@@ -972,7 +954,7 @@ Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
|
972
954
|
isEmpty(): boolean;
|
|
973
955
|
```
|
|
974
956
|
|
|
975
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
957
|
+
Defined in: [data-structures/heap/heap.ts:455](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L455)
|
|
976
958
|
|
|
977
959
|
Check whether the heap is empty.
|
|
978
960
|
|
|
@@ -982,8 +964,6 @@ Check whether the heap is empty.
|
|
|
982
964
|
|
|
983
965
|
True if size is 0.
|
|
984
966
|
|
|
985
|
-
*
|
|
986
|
-
|
|
987
967
|
#### Remarks
|
|
988
968
|
|
|
989
969
|
Time O(1), Space O(1)
|
|
@@ -1010,7 +990,7 @@ Time O(1), Space O(1)
|
|
|
1010
990
|
keys(): IterableIterator<number>;
|
|
1011
991
|
```
|
|
1012
992
|
|
|
1013
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
993
|
+
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)
|
|
1014
994
|
|
|
1015
995
|
Return an iterator of numeric indices (Array-compatible).
|
|
1016
996
|
|
|
@@ -1037,7 +1017,7 @@ map<EM, RM>(
|
|
|
1037
1017
|
thisArg?): Heap<EM, RM>;
|
|
1038
1018
|
```
|
|
1039
1019
|
|
|
1040
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1020
|
+
Defined in: [data-structures/heap/heap.ts:694](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L694)
|
|
1041
1021
|
|
|
1042
1022
|
Map elements into a new heap of possibly different element type.
|
|
1043
1023
|
|
|
@@ -1077,8 +1057,6 @@ Value for `this` inside the callback.
|
|
|
1077
1057
|
|
|
1078
1058
|
A new heap with mapped elements.
|
|
1079
1059
|
|
|
1080
|
-
*
|
|
1081
|
-
|
|
1082
1060
|
#### Remarks
|
|
1083
1061
|
|
|
1084
1062
|
Time O(N log N), Space O(N)
|
|
@@ -1104,7 +1082,7 @@ Time O(N log N), Space O(N)
|
|
|
1104
1082
|
mapSame(callback, thisArg?): this;
|
|
1105
1083
|
```
|
|
1106
1084
|
|
|
1107
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1085
|
+
Defined in: [data-structures/heap/heap.ts:717](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L717)
|
|
1108
1086
|
|
|
1109
1087
|
Map elements into a new heap of the same element type.
|
|
1110
1088
|
|
|
@@ -1144,7 +1122,7 @@ Time O(N log N), Space O(N)
|
|
|
1144
1122
|
peek(): E | undefined;
|
|
1145
1123
|
```
|
|
1146
1124
|
|
|
1147
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1125
|
+
Defined in: [data-structures/heap/heap.ts:440](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L440)
|
|
1148
1126
|
|
|
1149
1127
|
Get the current top element without removing it.
|
|
1150
1128
|
|
|
@@ -1154,8 +1132,6 @@ Get the current top element without removing it.
|
|
|
1154
1132
|
|
|
1155
1133
|
Top element or undefined.
|
|
1156
1134
|
|
|
1157
|
-
*
|
|
1158
|
-
|
|
1159
1135
|
#### Remarks
|
|
1160
1136
|
|
|
1161
1137
|
Time O(1), Space O(1)
|
|
@@ -1235,7 +1211,7 @@ Time O(1), Space O(1)
|
|
|
1235
1211
|
poll(): E | undefined;
|
|
1236
1212
|
```
|
|
1237
1213
|
|
|
1238
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1214
|
+
Defined in: [data-structures/heap/heap.ts:356](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L356)
|
|
1239
1215
|
|
|
1240
1216
|
#### Returns
|
|
1241
1217
|
|
|
@@ -1245,8 +1221,6 @@ Defined in: [data-structures/heap/heap.ts:523](https://github.com/zrwusa/data-st
|
|
|
1245
1221
|
|
|
1246
1222
|
Use `pop` instead. Will be removed in a future major version.
|
|
1247
1223
|
|
|
1248
|
-
*
|
|
1249
|
-
|
|
1250
1224
|
#### Example
|
|
1251
1225
|
|
|
1252
1226
|
```ts
|
|
@@ -1288,7 +1262,7 @@ Use `pop` instead. Will be removed in a future major version.
|
|
|
1288
1262
|
pop(): E | undefined;
|
|
1289
1263
|
```
|
|
1290
1264
|
|
|
1291
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1265
|
+
Defined in: [data-structures/heap/heap.ts:365](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L365)
|
|
1292
1266
|
|
|
1293
1267
|
Remove and return the top element (min or max depending on comparator).
|
|
1294
1268
|
|
|
@@ -1314,7 +1288,7 @@ Time O(log N) amortized, Space O(1)
|
|
|
1314
1288
|
print(): void;
|
|
1315
1289
|
```
|
|
1316
1290
|
|
|
1317
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1291
|
+
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)
|
|
1318
1292
|
|
|
1319
1293
|
Prints `toVisual()` to the console. Intended for quick debugging.
|
|
1320
1294
|
|
|
@@ -1372,7 +1346,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
|
|
|
1372
1346
|
reduce(callbackfn): E;
|
|
1373
1347
|
```
|
|
1374
1348
|
|
|
1375
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1349
|
+
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)
|
|
1376
1350
|
|
|
1377
1351
|
##### Parameters
|
|
1378
1352
|
|
|
@@ -1394,7 +1368,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:226](https://github.c
|
|
|
1394
1368
|
reduce(callbackfn, initialValue): E;
|
|
1395
1369
|
```
|
|
1396
1370
|
|
|
1397
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1371
|
+
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)
|
|
1398
1372
|
|
|
1399
1373
|
##### Parameters
|
|
1400
1374
|
|
|
@@ -1420,7 +1394,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:227](https://github.c
|
|
|
1420
1394
|
reduce<U>(callbackfn, initialValue): U;
|
|
1421
1395
|
```
|
|
1422
1396
|
|
|
1423
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1397
|
+
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)
|
|
1424
1398
|
|
|
1425
1399
|
##### Type Parameters
|
|
1426
1400
|
|
|
@@ -1454,7 +1428,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:228](https://github.c
|
|
|
1454
1428
|
setEquality(equals): this;
|
|
1455
1429
|
```
|
|
1456
1430
|
|
|
1457
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1431
|
+
Defined in: [data-structures/heap/heap.ts:561](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L561)
|
|
1458
1432
|
|
|
1459
1433
|
Set the equality comparator used by has/delete operations.
|
|
1460
1434
|
|
|
@@ -1528,7 +1502,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
|
|
|
1528
1502
|
sort(): E[];
|
|
1529
1503
|
```
|
|
1530
1504
|
|
|
1531
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1505
|
+
Defined in: [data-structures/heap/heap.ts:625](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L625)
|
|
1532
1506
|
|
|
1533
1507
|
Return all elements in ascending order by repeatedly polling.
|
|
1534
1508
|
|
|
@@ -1538,8 +1512,6 @@ Return all elements in ascending order by repeatedly polling.
|
|
|
1538
1512
|
|
|
1539
1513
|
Sorted array of elements.
|
|
1540
1514
|
|
|
1541
|
-
*
|
|
1542
|
-
|
|
1543
1515
|
#### Remarks
|
|
1544
1516
|
|
|
1545
1517
|
Time O(N log N), Space O(N)
|
|
@@ -1565,7 +1537,7 @@ Time O(N log N), Space O(N)
|
|
|
1565
1537
|
toArray(): E[];
|
|
1566
1538
|
```
|
|
1567
1539
|
|
|
1568
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1540
|
+
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)
|
|
1569
1541
|
|
|
1570
1542
|
Materializes the elements into a new array.
|
|
1571
1543
|
|
|
@@ -1591,7 +1563,7 @@ Time O(n), Space O(n).
|
|
|
1591
1563
|
toVisual(): E[];
|
|
1592
1564
|
```
|
|
1593
1565
|
|
|
1594
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1566
|
+
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)
|
|
1595
1567
|
|
|
1596
1568
|
Returns a representation of the structure suitable for quick visualization.
|
|
1597
1569
|
Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
@@ -1647,7 +1619,7 @@ static from<T, R, S>(
|
|
|
1647
1619
|
options?): S;
|
|
1648
1620
|
```
|
|
1649
1621
|
|
|
1650
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1622
|
+
Defined in: [data-structures/heap/heap.ts:225](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L225)
|
|
1651
1623
|
|
|
1652
1624
|
Create a heap of the same class from an iterable.
|
|
1653
1625
|
|
|
@@ -1705,7 +1677,7 @@ Time O(N), Space O(N)
|
|
|
1705
1677
|
static heapify<EE, RR>(elements, options): Heap<EE, RR>;
|
|
1706
1678
|
```
|
|
1707
1679
|
|
|
1708
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1680
|
+
Defined in: [data-structures/heap/heap.ts:242](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L242)
|
|
1709
1681
|
|
|
1710
1682
|
Build a Heap from an iterable in linear time given a comparator.
|
|
1711
1683
|
|
|
@@ -1788,7 +1760,7 @@ Time O(1), Space O(1).
|
|
|
1788
1760
|
protected _createInstance(options?): this;
|
|
1789
1761
|
```
|
|
1790
1762
|
|
|
1791
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1763
|
+
Defined in: [data-structures/heap/heap.ts:779](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L779)
|
|
1792
1764
|
|
|
1793
1765
|
(Protected) Create an empty instance of the same concrete class.
|
|
1794
1766
|
|
|
@@ -1822,7 +1794,7 @@ Time O(1), Space O(1)
|
|
|
1822
1794
|
protected _createLike<EM, RM>(elements?, options?): Heap<EM, RM>;
|
|
1823
1795
|
```
|
|
1824
1796
|
|
|
1825
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1797
|
+
Defined in: [data-structures/heap/heap.ts:793](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L793)
|
|
1826
1798
|
|
|
1827
1799
|
(Protected) Create a like-kind instance seeded by elements.
|
|
1828
1800
|
|
|
@@ -1872,7 +1844,7 @@ Time O(N log N), Space O(N)
|
|
|
1872
1844
|
protected _getIterator(): IterableIterator<E>;
|
|
1873
1845
|
```
|
|
1874
1846
|
|
|
1875
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1847
|
+
Defined in: [data-structures/heap/heap.ts:738](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L738)
|
|
1876
1848
|
|
|
1877
1849
|
Internal iterator factory used by the default iterator.
|
|
1878
1850
|
|
|
@@ -1898,7 +1870,7 @@ Implementations should yield in O(1) per element with O(1) extra space when poss
|
|
|
1898
1870
|
protected _spawnLike<EM, RM>(options?): Heap<EM, RM>;
|
|
1899
1871
|
```
|
|
1900
1872
|
|
|
1901
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1873
|
+
Defined in: [data-structures/heap/heap.ts:812](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L812)
|
|
1902
1874
|
|
|
1903
1875
|
(Protected) Spawn an empty like-kind heap instance.
|
|
1904
1876
|
|