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: MaxPriorityQueue\<E, R\>
|
|
8
8
|
|
|
9
|
-
Defined in: [data-structures/priority-queue/max-priority-queue.ts:
|
|
9
|
+
Defined in: [data-structures/priority-queue/max-priority-queue.ts:72](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/priority-queue/max-priority-queue.ts#L72)
|
|
10
10
|
|
|
11
11
|
Max-oriented priority queue (max-heap) built on [PriorityQueue](PriorityQueue.md).
|
|
12
12
|
The default comparator orders primitive values in descending order. If you store objects,
|
|
@@ -70,12 +70,7 @@ you must provide a custom comparator via PriorityQueueOptions.
|
|
|
70
70
|
while (cpuQueue.size > 0) {
|
|
71
71
|
order.push(cpuQueue.poll()![1]);
|
|
72
72
|
}
|
|
73
|
-
console.log(order); // [
|
|
74
|
-
// 'User interaction',
|
|
75
|
-
// 'System process',
|
|
76
|
-
// 'Network sync',
|
|
77
|
-
// 'Background task'
|
|
78
|
-
// ];
|
|
73
|
+
console.log(order); // ['User interaction', 'System process', 'Network sync', 'Background task'];
|
|
79
74
|
```
|
|
80
75
|
|
|
81
76
|
## Extends
|
|
@@ -104,7 +99,7 @@ Extra record/metadata associated with each element.
|
|
|
104
99
|
new MaxPriorityQueue<E, R>(elements?, options?): MaxPriorityQueue<E, R>;
|
|
105
100
|
```
|
|
106
101
|
|
|
107
|
-
Defined in: [data-structures/priority-queue/max-priority-queue.ts:
|
|
102
|
+
Defined in: [data-structures/priority-queue/max-priority-queue.ts:80](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/priority-queue/max-priority-queue.ts#L80)
|
|
108
103
|
|
|
109
104
|
Creates a max-priority queue.
|
|
110
105
|
|
|
@@ -150,7 +145,7 @@ PriorityQueue<E, R>.constructor
|
|
|
150
145
|
get comparator(): Comparator<E>;
|
|
151
146
|
```
|
|
152
147
|
|
|
153
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
148
|
+
Defined in: [data-structures/heap/heap.ts:211](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L211)
|
|
154
149
|
|
|
155
150
|
Get the comparator used to order elements.
|
|
156
151
|
|
|
@@ -178,7 +173,7 @@ Comparator function.
|
|
|
178
173
|
get elements(): E[];
|
|
179
174
|
```
|
|
180
175
|
|
|
181
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
176
|
+
Defined in: [data-structures/heap/heap.ts:175](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L175)
|
|
182
177
|
|
|
183
178
|
Get the backing array of the heap.
|
|
184
179
|
|
|
@@ -206,7 +201,7 @@ Internal elements array.
|
|
|
206
201
|
get leaf(): E | undefined;
|
|
207
202
|
```
|
|
208
203
|
|
|
209
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
204
|
+
Defined in: [data-structures/heap/heap.ts:202](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L202)
|
|
210
205
|
|
|
211
206
|
Get the last leaf element.
|
|
212
207
|
|
|
@@ -234,7 +229,7 @@ Last element or undefined.
|
|
|
234
229
|
get size(): number;
|
|
235
230
|
```
|
|
236
231
|
|
|
237
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
232
|
+
Defined in: [data-structures/heap/heap.ts:193](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L193)
|
|
238
233
|
|
|
239
234
|
Get the number of elements.
|
|
240
235
|
|
|
@@ -261,8 +256,6 @@ Time O(1), Space O(1)
|
|
|
261
256
|
|
|
262
257
|
Heap size.
|
|
263
258
|
|
|
264
|
-
*
|
|
265
|
-
|
|
266
259
|
#### Inherited from
|
|
267
260
|
|
|
268
261
|
[`PriorityQueue`](PriorityQueue.md).[`size`](PriorityQueue.md#size)
|
|
@@ -337,7 +330,7 @@ Producing the iterator is O(1); consuming the entire iterator is Time O(n) with
|
|
|
337
330
|
add(element): boolean;
|
|
338
331
|
```
|
|
339
332
|
|
|
340
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
333
|
+
Defined in: [data-structures/heap/heap.ts:267](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L267)
|
|
341
334
|
|
|
342
335
|
Insert an element.
|
|
343
336
|
|
|
@@ -355,8 +348,6 @@ Element to insert.
|
|
|
355
348
|
|
|
356
349
|
True.
|
|
357
350
|
|
|
358
|
-
*
|
|
359
|
-
|
|
360
351
|
#### Remarks
|
|
361
352
|
|
|
362
353
|
Time O(log N) amortized, Space O(1)
|
|
@@ -392,7 +383,7 @@ Time O(log N) amortized, Space O(1)
|
|
|
392
383
|
addMany(elements): boolean[];
|
|
393
384
|
```
|
|
394
385
|
|
|
395
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
386
|
+
Defined in: [data-structures/heap/heap.ts:284](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L284)
|
|
396
387
|
|
|
397
388
|
Insert many elements from an iterable.
|
|
398
389
|
|
|
@@ -410,8 +401,6 @@ Iterable of elements or raw values.
|
|
|
410
401
|
|
|
411
402
|
Array of per-element success flags.
|
|
412
403
|
|
|
413
|
-
*
|
|
414
|
-
|
|
415
404
|
#### Remarks
|
|
416
405
|
|
|
417
406
|
Time O(N log N), Space O(1)
|
|
@@ -438,7 +427,7 @@ Time O(N log N), Space O(1)
|
|
|
438
427
|
clear(): void;
|
|
439
428
|
```
|
|
440
429
|
|
|
441
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
430
|
+
Defined in: [data-structures/heap/heap.ts:469](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L469)
|
|
442
431
|
|
|
443
432
|
Remove all elements.
|
|
444
433
|
|
|
@@ -448,8 +437,6 @@ Remove all elements.
|
|
|
448
437
|
|
|
449
438
|
void
|
|
450
439
|
|
|
451
|
-
*
|
|
452
|
-
|
|
453
440
|
#### Remarks
|
|
454
441
|
|
|
455
442
|
Time O(1), Space O(1)
|
|
@@ -475,7 +462,7 @@ Time O(1), Space O(1)
|
|
|
475
462
|
clone(): this;
|
|
476
463
|
```
|
|
477
464
|
|
|
478
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
465
|
+
Defined in: [data-structures/heap/heap.ts:648](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L648)
|
|
479
466
|
|
|
480
467
|
Deep clone this heap.
|
|
481
468
|
|
|
@@ -485,8 +472,6 @@ Deep clone this heap.
|
|
|
485
472
|
|
|
486
473
|
A new heap with the same elements.
|
|
487
474
|
|
|
488
|
-
*
|
|
489
|
-
|
|
490
475
|
#### Remarks
|
|
491
476
|
|
|
492
477
|
Time O(N), Space O(N)
|
|
@@ -514,7 +499,7 @@ Time O(N), Space O(N)
|
|
|
514
499
|
delete(element): boolean;
|
|
515
500
|
```
|
|
516
501
|
|
|
517
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
502
|
+
Defined in: [data-structures/heap/heap.ts:500](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L500)
|
|
518
503
|
|
|
519
504
|
Delete one occurrence of an element.
|
|
520
505
|
|
|
@@ -532,8 +517,6 @@ Element to delete.
|
|
|
532
517
|
|
|
533
518
|
True if an element was removed.
|
|
534
519
|
|
|
535
|
-
*
|
|
536
|
-
|
|
537
520
|
#### Remarks
|
|
538
521
|
|
|
539
522
|
Time O(N), Space O(1)
|
|
@@ -559,7 +542,7 @@ Time O(N), Space O(1)
|
|
|
559
542
|
deleteBy(predicate): boolean;
|
|
560
543
|
```
|
|
561
544
|
|
|
562
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
545
|
+
Defined in: [data-structures/heap/heap.ts:524](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L524)
|
|
563
546
|
|
|
564
547
|
#### Parameters
|
|
565
548
|
|
|
@@ -587,7 +570,7 @@ Use `deleteWhere` instead. Will be removed in a future major version.
|
|
|
587
570
|
deleteWhere(predicate): boolean;
|
|
588
571
|
```
|
|
589
572
|
|
|
590
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
573
|
+
Defined in: [data-structures/heap/heap.ts:534](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L534)
|
|
591
574
|
|
|
592
575
|
Delete the first element that matches a predicate.
|
|
593
576
|
|
|
@@ -621,7 +604,7 @@ Time O(N), Space O(1)
|
|
|
621
604
|
dfs(order?): E[];
|
|
622
605
|
```
|
|
623
606
|
|
|
624
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
607
|
+
Defined in: [data-structures/heap/heap.ts:577](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L577)
|
|
625
608
|
|
|
626
609
|
Traverse the binary heap as a complete binary tree and collect elements.
|
|
627
610
|
|
|
@@ -639,8 +622,6 @@ Traversal order: 'PRE' | 'IN' | 'POST'.
|
|
|
639
622
|
|
|
640
623
|
Array of visited elements.
|
|
641
624
|
|
|
642
|
-
*
|
|
643
|
-
|
|
644
625
|
#### Remarks
|
|
645
626
|
|
|
646
627
|
Time O(N), Space O(H)
|
|
@@ -666,7 +647,7 @@ Time O(N), Space O(H)
|
|
|
666
647
|
entries(): IterableIterator<[number, E]>;
|
|
667
648
|
```
|
|
668
649
|
|
|
669
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
650
|
+
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)
|
|
670
651
|
|
|
671
652
|
Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
672
653
|
|
|
@@ -730,7 +711,7 @@ Time O(n) in the worst case; may exit early when the first failure is found. Spa
|
|
|
730
711
|
filter(callback, thisArg?): this;
|
|
731
712
|
```
|
|
732
713
|
|
|
733
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
714
|
+
Defined in: [data-structures/heap/heap.ts:666](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L666)
|
|
734
715
|
|
|
735
716
|
Filter elements into a new heap of the same class.
|
|
736
717
|
|
|
@@ -754,8 +735,6 @@ Value for `this` inside the callback.
|
|
|
754
735
|
|
|
755
736
|
A new heap with the kept elements.
|
|
756
737
|
|
|
757
|
-
*
|
|
758
|
-
|
|
759
738
|
#### Remarks
|
|
760
739
|
|
|
761
740
|
Time O(N log N), Space O(N)
|
|
@@ -871,7 +850,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
|
871
850
|
fix(): boolean[];
|
|
872
851
|
```
|
|
873
852
|
|
|
874
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
853
|
+
Defined in: [data-structures/heap/heap.ts:607](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L607)
|
|
875
854
|
|
|
876
855
|
Restore heap order bottom-up (heapify in-place).
|
|
877
856
|
|
|
@@ -937,7 +916,7 @@ Time O(n), Space O(1).
|
|
|
937
916
|
has(element): boolean;
|
|
938
917
|
```
|
|
939
918
|
|
|
940
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
919
|
+
Defined in: [data-structures/heap/heap.ts:484](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L484)
|
|
941
920
|
|
|
942
921
|
Check if an equal element exists in the heap.
|
|
943
922
|
|
|
@@ -955,8 +934,6 @@ Element to search for.
|
|
|
955
934
|
|
|
956
935
|
True if found.
|
|
957
936
|
|
|
958
|
-
*
|
|
959
|
-
|
|
960
937
|
#### Remarks
|
|
961
938
|
|
|
962
939
|
Time O(N), Space O(1)
|
|
@@ -982,7 +959,7 @@ Time O(N), Space O(1)
|
|
|
982
959
|
includes(element): boolean;
|
|
983
960
|
```
|
|
984
961
|
|
|
985
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
962
|
+
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)
|
|
986
963
|
|
|
987
964
|
Check whether a value exists (Array-compatible alias for `has`).
|
|
988
965
|
|
|
@@ -1016,7 +993,7 @@ Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
|
1016
993
|
isEmpty(): boolean;
|
|
1017
994
|
```
|
|
1018
995
|
|
|
1019
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
996
|
+
Defined in: [data-structures/heap/heap.ts:455](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L455)
|
|
1020
997
|
|
|
1021
998
|
Check whether the heap is empty.
|
|
1022
999
|
|
|
@@ -1026,8 +1003,6 @@ Check whether the heap is empty.
|
|
|
1026
1003
|
|
|
1027
1004
|
True if size is 0.
|
|
1028
1005
|
|
|
1029
|
-
*
|
|
1030
|
-
|
|
1031
1006
|
#### Remarks
|
|
1032
1007
|
|
|
1033
1008
|
Time O(1), Space O(1)
|
|
@@ -1054,7 +1029,7 @@ Time O(1), Space O(1)
|
|
|
1054
1029
|
keys(): IterableIterator<number>;
|
|
1055
1030
|
```
|
|
1056
1031
|
|
|
1057
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1032
|
+
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)
|
|
1058
1033
|
|
|
1059
1034
|
Return an iterator of numeric indices (Array-compatible).
|
|
1060
1035
|
|
|
@@ -1081,7 +1056,7 @@ map<EM, RM>(
|
|
|
1081
1056
|
thisArg?): Heap<EM, RM>;
|
|
1082
1057
|
```
|
|
1083
1058
|
|
|
1084
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1059
|
+
Defined in: [data-structures/heap/heap.ts:694](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L694)
|
|
1085
1060
|
|
|
1086
1061
|
Map elements into a new heap of possibly different element type.
|
|
1087
1062
|
|
|
@@ -1121,8 +1096,6 @@ Value for `this` inside the callback.
|
|
|
1121
1096
|
|
|
1122
1097
|
A new heap with mapped elements.
|
|
1123
1098
|
|
|
1124
|
-
*
|
|
1125
|
-
|
|
1126
1099
|
#### Remarks
|
|
1127
1100
|
|
|
1128
1101
|
Time O(N log N), Space O(N)
|
|
@@ -1148,7 +1121,7 @@ Time O(N log N), Space O(N)
|
|
|
1148
1121
|
mapSame(callback, thisArg?): this;
|
|
1149
1122
|
```
|
|
1150
1123
|
|
|
1151
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1124
|
+
Defined in: [data-structures/heap/heap.ts:717](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L717)
|
|
1152
1125
|
|
|
1153
1126
|
Map elements into a new heap of the same element type.
|
|
1154
1127
|
|
|
@@ -1188,7 +1161,7 @@ Time O(N log N), Space O(N)
|
|
|
1188
1161
|
peek(): E | undefined;
|
|
1189
1162
|
```
|
|
1190
1163
|
|
|
1191
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1164
|
+
Defined in: [data-structures/heap/heap.ts:440](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L440)
|
|
1192
1165
|
|
|
1193
1166
|
Get the current top element without removing it.
|
|
1194
1167
|
|
|
@@ -1198,8 +1171,6 @@ Get the current top element without removing it.
|
|
|
1198
1171
|
|
|
1199
1172
|
Top element or undefined.
|
|
1200
1173
|
|
|
1201
|
-
*
|
|
1202
|
-
|
|
1203
1174
|
#### Remarks
|
|
1204
1175
|
|
|
1205
1176
|
Time O(1), Space O(1)
|
|
@@ -1279,7 +1250,7 @@ Time O(1), Space O(1)
|
|
|
1279
1250
|
poll(): E | undefined;
|
|
1280
1251
|
```
|
|
1281
1252
|
|
|
1282
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1253
|
+
Defined in: [data-structures/heap/heap.ts:356](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L356)
|
|
1283
1254
|
|
|
1284
1255
|
#### Returns
|
|
1285
1256
|
|
|
@@ -1289,8 +1260,6 @@ Defined in: [data-structures/heap/heap.ts:523](https://github.com/zrwusa/data-st
|
|
|
1289
1260
|
|
|
1290
1261
|
Use `pop` instead. Will be removed in a future major version.
|
|
1291
1262
|
|
|
1292
|
-
*
|
|
1293
|
-
|
|
1294
1263
|
#### Example
|
|
1295
1264
|
|
|
1296
1265
|
```ts
|
|
@@ -1332,7 +1301,7 @@ Use `pop` instead. Will be removed in a future major version.
|
|
|
1332
1301
|
pop(): E | undefined;
|
|
1333
1302
|
```
|
|
1334
1303
|
|
|
1335
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1304
|
+
Defined in: [data-structures/heap/heap.ts:365](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L365)
|
|
1336
1305
|
|
|
1337
1306
|
Remove and return the top element (min or max depending on comparator).
|
|
1338
1307
|
|
|
@@ -1358,7 +1327,7 @@ Time O(log N) amortized, Space O(1)
|
|
|
1358
1327
|
print(): void;
|
|
1359
1328
|
```
|
|
1360
1329
|
|
|
1361
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1330
|
+
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)
|
|
1362
1331
|
|
|
1363
1332
|
Prints `toVisual()` to the console. Intended for quick debugging.
|
|
1364
1333
|
|
|
@@ -1416,7 +1385,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
|
|
|
1416
1385
|
reduce(callbackfn): E;
|
|
1417
1386
|
```
|
|
1418
1387
|
|
|
1419
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1388
|
+
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)
|
|
1420
1389
|
|
|
1421
1390
|
##### Parameters
|
|
1422
1391
|
|
|
@@ -1438,7 +1407,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:226](https://github.c
|
|
|
1438
1407
|
reduce(callbackfn, initialValue): E;
|
|
1439
1408
|
```
|
|
1440
1409
|
|
|
1441
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1410
|
+
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)
|
|
1442
1411
|
|
|
1443
1412
|
##### Parameters
|
|
1444
1413
|
|
|
@@ -1464,7 +1433,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:227](https://github.c
|
|
|
1464
1433
|
reduce<U>(callbackfn, initialValue): U;
|
|
1465
1434
|
```
|
|
1466
1435
|
|
|
1467
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1436
|
+
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)
|
|
1468
1437
|
|
|
1469
1438
|
##### Type Parameters
|
|
1470
1439
|
|
|
@@ -1498,7 +1467,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:228](https://github.c
|
|
|
1498
1467
|
setEquality(equals): this;
|
|
1499
1468
|
```
|
|
1500
1469
|
|
|
1501
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1470
|
+
Defined in: [data-structures/heap/heap.ts:561](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L561)
|
|
1502
1471
|
|
|
1503
1472
|
Set the equality comparator used by has/delete operations.
|
|
1504
1473
|
|
|
@@ -1572,7 +1541,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
|
|
|
1572
1541
|
sort(): E[];
|
|
1573
1542
|
```
|
|
1574
1543
|
|
|
1575
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1544
|
+
Defined in: [data-structures/heap/heap.ts:625](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L625)
|
|
1576
1545
|
|
|
1577
1546
|
Return all elements in ascending order by repeatedly polling.
|
|
1578
1547
|
|
|
@@ -1582,8 +1551,6 @@ Return all elements in ascending order by repeatedly polling.
|
|
|
1582
1551
|
|
|
1583
1552
|
Sorted array of elements.
|
|
1584
1553
|
|
|
1585
|
-
*
|
|
1586
|
-
|
|
1587
1554
|
#### Remarks
|
|
1588
1555
|
|
|
1589
1556
|
Time O(N log N), Space O(N)
|
|
@@ -1609,7 +1576,7 @@ Time O(N log N), Space O(N)
|
|
|
1609
1576
|
toArray(): E[];
|
|
1610
1577
|
```
|
|
1611
1578
|
|
|
1612
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1579
|
+
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)
|
|
1613
1580
|
|
|
1614
1581
|
Materializes the elements into a new array.
|
|
1615
1582
|
|
|
@@ -1635,7 +1602,7 @@ Time O(n), Space O(n).
|
|
|
1635
1602
|
toVisual(): E[];
|
|
1636
1603
|
```
|
|
1637
1604
|
|
|
1638
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1605
|
+
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)
|
|
1639
1606
|
|
|
1640
1607
|
Returns a representation of the structure suitable for quick visualization.
|
|
1641
1608
|
Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
@@ -1691,7 +1658,7 @@ static from<T, R, S>(
|
|
|
1691
1658
|
options?): S;
|
|
1692
1659
|
```
|
|
1693
1660
|
|
|
1694
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1661
|
+
Defined in: [data-structures/heap/heap.ts:225](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L225)
|
|
1695
1662
|
|
|
1696
1663
|
Create a heap of the same class from an iterable.
|
|
1697
1664
|
|
|
@@ -1749,7 +1716,7 @@ Time O(N), Space O(N)
|
|
|
1749
1716
|
static heapify<EE, RR>(elements, options): Heap<EE, RR>;
|
|
1750
1717
|
```
|
|
1751
1718
|
|
|
1752
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1719
|
+
Defined in: [data-structures/heap/heap.ts:242](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L242)
|
|
1753
1720
|
|
|
1754
1721
|
Build a Heap from an iterable in linear time given a comparator.
|
|
1755
1722
|
|
|
@@ -1832,7 +1799,7 @@ Time O(1), Space O(1).
|
|
|
1832
1799
|
protected _createInstance(options?): this;
|
|
1833
1800
|
```
|
|
1834
1801
|
|
|
1835
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1802
|
+
Defined in: [data-structures/heap/heap.ts:779](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L779)
|
|
1836
1803
|
|
|
1837
1804
|
(Protected) Create an empty instance of the same concrete class.
|
|
1838
1805
|
|
|
@@ -1866,7 +1833,7 @@ Time O(1), Space O(1)
|
|
|
1866
1833
|
protected _createLike<EM, RM>(elements?, options?): Heap<EM, RM>;
|
|
1867
1834
|
```
|
|
1868
1835
|
|
|
1869
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1836
|
+
Defined in: [data-structures/heap/heap.ts:793](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L793)
|
|
1870
1837
|
|
|
1871
1838
|
(Protected) Create a like-kind instance seeded by elements.
|
|
1872
1839
|
|
|
@@ -1916,7 +1883,7 @@ Time O(N log N), Space O(N)
|
|
|
1916
1883
|
protected _getIterator(): IterableIterator<E>;
|
|
1917
1884
|
```
|
|
1918
1885
|
|
|
1919
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1886
|
+
Defined in: [data-structures/heap/heap.ts:738](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L738)
|
|
1920
1887
|
|
|
1921
1888
|
Internal iterator factory used by the default iterator.
|
|
1922
1889
|
|
|
@@ -1942,7 +1909,7 @@ Implementations should yield in O(1) per element with O(1) extra space when poss
|
|
|
1942
1909
|
protected _spawnLike<EM, RM>(options?): Heap<EM, RM>;
|
|
1943
1910
|
```
|
|
1944
1911
|
|
|
1945
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1912
|
+
Defined in: [data-structures/heap/heap.ts:812](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L812)
|
|
1946
1913
|
|
|
1947
1914
|
(Protected) Spawn an empty like-kind heap instance.
|
|
1948
1915
|
|