data-structure-typed 2.6.0 → 2.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +7 -2
- package/.github/workflows/release-package.yml +9 -2
- package/CHANGELOG.md +9 -1
- package/dist/cjs/binary-tree.cjs +2927 -23688
- package/dist/cjs/graph.cjs +845 -2634
- package/dist/cjs/hash.cjs +185 -616
- package/dist/cjs/heap.cjs +266 -818
- package/dist/cjs/index.cjs +5116 -31358
- package/dist/cjs/linked-list.cjs +644 -2615
- package/dist/cjs/matrix.cjs +220 -535
- package/dist/cjs/priority-queue.cjs +266 -818
- package/dist/cjs/queue.cjs +637 -2343
- package/dist/cjs/stack.cjs +124 -530
- package/dist/cjs/trie.cjs +145 -592
- package/dist/cjs-legacy/binary-tree.cjs +4352 -25113
- package/dist/cjs-legacy/graph.cjs +847 -2636
- package/dist/cjs-legacy/hash.cjs +181 -612
- package/dist/cjs-legacy/heap.cjs +266 -818
- package/dist/cjs-legacy/index.cjs +6657 -32899
- package/dist/cjs-legacy/linked-list.cjs +640 -2611
- package/dist/cjs-legacy/matrix.cjs +220 -535
- package/dist/cjs-legacy/priority-queue.cjs +266 -818
- package/dist/cjs-legacy/queue.cjs +634 -2340
- package/dist/cjs-legacy/stack.cjs +124 -530
- package/dist/cjs-legacy/trie.cjs +145 -592
- package/dist/esm/binary-tree.mjs +2927 -23688
- package/dist/esm/graph.mjs +845 -2634
- package/dist/esm/hash.mjs +185 -616
- package/dist/esm/heap.mjs +266 -818
- package/dist/esm/index.mjs +5116 -31358
- package/dist/esm/linked-list.mjs +644 -2615
- package/dist/esm/matrix.mjs +220 -535
- package/dist/esm/priority-queue.mjs +266 -818
- package/dist/esm/queue.mjs +637 -2343
- package/dist/esm/stack.mjs +124 -530
- package/dist/esm/trie.mjs +145 -592
- package/dist/esm-legacy/binary-tree.mjs +4352 -25113
- package/dist/esm-legacy/graph.mjs +847 -2636
- package/dist/esm-legacy/hash.mjs +181 -612
- package/dist/esm-legacy/heap.mjs +266 -818
- package/dist/esm-legacy/index.mjs +6657 -32899
- package/dist/esm-legacy/linked-list.mjs +640 -2611
- package/dist/esm-legacy/matrix.mjs +220 -535
- package/dist/esm-legacy/priority-queue.mjs +266 -818
- package/dist/esm-legacy/queue.mjs +634 -2340
- package/dist/esm-legacy/stack.mjs +124 -530
- package/dist/esm-legacy/trie.mjs +145 -592
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +29 -500
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +38 -563
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +230 -1212
- package/dist/types/data-structures/binary-tree/bst.d.ts +124 -1063
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +99 -854
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +62 -314
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +366 -5057
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +277 -4885
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +253 -3929
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +261 -4782
- package/dist/types/data-structures/graph/abstract-graph.d.ts +44 -44
- package/dist/types/data-structures/graph/directed-graph.d.ts +130 -527
- package/dist/types/data-structures/graph/undirected-graph.d.ts +125 -482
- package/dist/types/data-structures/hash/hash-map.d.ts +132 -562
- package/dist/types/data-structures/heap/heap.d.ts +194 -746
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +120 -809
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +121 -733
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +193 -863
- package/dist/types/data-structures/matrix/matrix.d.ts +159 -474
- package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -6
- package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +6 -11
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
- package/dist/types/data-structures/queue/deque.d.ts +196 -804
- package/dist/types/data-structures/queue/queue.d.ts +99 -585
- package/dist/types/data-structures/stack/stack.d.ts +75 -481
- package/dist/types/data-structures/trie/trie.d.ts +98 -584
- package/dist/umd/data-structure-typed.js +6580 -32822
- package/dist/umd/data-structure-typed.min.js +3 -3
- package/docs-site-docusaurus/docs/api/classes/AVLTree.md +162 -215
- package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +9 -9
- package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +47 -47
- package/docs-site-docusaurus/docs/api/classes/BST.md +155 -208
- package/docs-site-docusaurus/docs/api/classes/BSTNode.md +7 -7
- package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +13 -29
- package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +104 -158
- package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/Deque.md +253 -101
- package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +60 -80
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +244 -114
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +6 -6
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +9 -9
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
- package/docs-site-docusaurus/docs/api/classes/HashMap.md +52 -48
- package/docs-site-docusaurus/docs/api/classes/Heap.md +119 -64
- package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +84 -14
- package/docs-site-docusaurus/docs/api/classes/LinearBase.md +138 -34
- package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +149 -41
- package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +23 -23
- package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +172 -92
- package/docs-site-docusaurus/docs/api/classes/MapGraph.md +60 -80
- package/docs-site-docusaurus/docs/api/classes/Matrix.md +57 -52
- package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +117 -62
- package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +120 -70
- package/docs-site-docusaurus/docs/api/classes/MinHeap.md +117 -62
- package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +125 -75
- package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +119 -64
- package/docs-site-docusaurus/docs/api/classes/Queue.md +158 -74
- package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +171 -225
- package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -22
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +172 -94
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +4 -4
- package/docs-site-docusaurus/docs/api/classes/SkipList.md +98 -75
- package/docs-site-docusaurus/docs/api/classes/Stack.md +112 -50
- package/docs-site-docusaurus/docs/api/classes/TreeMap.md +104 -129
- package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +90 -121
- package/docs-site-docusaurus/docs/api/classes/TreeSet.md +298 -107
- package/docs-site-docusaurus/docs/api/classes/Trie.md +116 -58
- package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +59 -77
- package/package.json +45 -46
- package/src/common/error.ts +15 -32
- package/src/common/index.ts +0 -3
- package/src/data-structures/base/iterable-element-base.ts +0 -3
- package/src/data-structures/base/linear-base.ts +2 -36
- package/src/data-structures/binary-tree/avl-tree.ts +31 -529
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +47 -572
- package/src/data-structures/binary-tree/binary-tree.ts +326 -1311
- package/src/data-structures/binary-tree/bst.ts +158 -1082
- package/src/data-structures/binary-tree/red-black-tree.ts +451 -1290
- package/src/data-structures/binary-tree/segment-tree.ts +73 -351
- package/src/data-structures/binary-tree/tree-map.ts +462 -5124
- package/src/data-structures/binary-tree/tree-multi-map.ts +302 -4914
- package/src/data-structures/binary-tree/tree-multi-set.ts +299 -3983
- package/src/data-structures/binary-tree/tree-set.ts +338 -4836
- package/src/data-structures/graph/abstract-graph.ts +98 -167
- package/src/data-structures/graph/directed-graph.ts +137 -562
- package/src/data-structures/graph/map-graph.ts +0 -3
- package/src/data-structures/graph/undirected-graph.ts +132 -511
- package/src/data-structures/hash/hash-map.ts +154 -582
- package/src/data-structures/heap/heap.ts +200 -795
- package/src/data-structures/linked-list/doubly-linked-list.ts +121 -865
- package/src/data-structures/linked-list/singly-linked-list.ts +122 -794
- package/src/data-structures/linked-list/skip-linked-list.ts +211 -918
- package/src/data-structures/matrix/matrix.ts +179 -518
- package/src/data-structures/matrix/navigator.ts +0 -1
- package/src/data-structures/priority-queue/max-priority-queue.ts +1 -6
- package/src/data-structures/priority-queue/min-priority-queue.ts +6 -11
- package/src/data-structures/priority-queue/priority-queue.ts +1 -2
- package/src/data-structures/queue/deque.ts +214 -882
- package/src/data-structures/queue/queue.ts +102 -625
- package/src/data-structures/stack/stack.ts +76 -505
- package/src/data-structures/trie/trie.ts +98 -628
- package/src/types/common.ts +0 -10
- package/src/types/data-structures/binary-tree/bst.ts +0 -7
- package/src/types/data-structures/binary-tree/red-black-tree.ts +0 -1
- package/src/types/data-structures/graph/abstract-graph.ts +0 -2
- package/src/types/data-structures/hash/hash-map.ts +0 -3
- package/src/types/data-structures/hash/index.ts +0 -1
- package/src/types/data-structures/matrix/navigator.ts +0 -2
- package/src/types/utils/utils.ts +0 -7
- package/src/types/utils/validate-type.ts +0 -7
- package/src/utils/number.ts +0 -2
- package/src/utils/utils.ts +0 -5
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: 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)
|
|
@@ -660,6 +641,30 @@ Time O(N), Space O(H)
|
|
|
660
641
|
|
|
661
642
|
***
|
|
662
643
|
|
|
644
|
+
### entries()
|
|
645
|
+
|
|
646
|
+
```ts
|
|
647
|
+
entries(): IterableIterator<[number, E]>;
|
|
648
|
+
```
|
|
649
|
+
|
|
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)
|
|
651
|
+
|
|
652
|
+
Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
653
|
+
|
|
654
|
+
#### Returns
|
|
655
|
+
|
|
656
|
+
`IterableIterator`\<\[`number`, `E`\]\>
|
|
657
|
+
|
|
658
|
+
#### Remarks
|
|
659
|
+
|
|
660
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
661
|
+
|
|
662
|
+
#### Inherited from
|
|
663
|
+
|
|
664
|
+
[`PriorityQueue`](PriorityQueue.md).[`entries`](PriorityQueue.md#entries)
|
|
665
|
+
|
|
666
|
+
***
|
|
667
|
+
|
|
663
668
|
### every()
|
|
664
669
|
|
|
665
670
|
```ts
|
|
@@ -706,7 +711,7 @@ Time O(n) in the worst case; may exit early when the first failure is found. Spa
|
|
|
706
711
|
filter(callback, thisArg?): this;
|
|
707
712
|
```
|
|
708
713
|
|
|
709
|
-
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)
|
|
710
715
|
|
|
711
716
|
Filter elements into a new heap of the same class.
|
|
712
717
|
|
|
@@ -730,8 +735,6 @@ Value for `this` inside the callback.
|
|
|
730
735
|
|
|
731
736
|
A new heap with the kept elements.
|
|
732
737
|
|
|
733
|
-
*
|
|
734
|
-
|
|
735
738
|
#### Remarks
|
|
736
739
|
|
|
737
740
|
Time O(N log N), Space O(N)
|
|
@@ -847,7 +850,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
|
847
850
|
fix(): boolean[];
|
|
848
851
|
```
|
|
849
852
|
|
|
850
|
-
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)
|
|
851
854
|
|
|
852
855
|
Restore heap order bottom-up (heapify in-place).
|
|
853
856
|
|
|
@@ -913,7 +916,7 @@ Time O(n), Space O(1).
|
|
|
913
916
|
has(element): boolean;
|
|
914
917
|
```
|
|
915
918
|
|
|
916
|
-
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)
|
|
917
920
|
|
|
918
921
|
Check if an equal element exists in the heap.
|
|
919
922
|
|
|
@@ -931,8 +934,6 @@ Element to search for.
|
|
|
931
934
|
|
|
932
935
|
True if found.
|
|
933
936
|
|
|
934
|
-
*
|
|
935
|
-
|
|
936
937
|
#### Remarks
|
|
937
938
|
|
|
938
939
|
Time O(N), Space O(1)
|
|
@@ -952,13 +953,47 @@ Time O(N), Space O(1)
|
|
|
952
953
|
|
|
953
954
|
***
|
|
954
955
|
|
|
956
|
+
### includes()
|
|
957
|
+
|
|
958
|
+
```ts
|
|
959
|
+
includes(element): boolean;
|
|
960
|
+
```
|
|
961
|
+
|
|
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)
|
|
963
|
+
|
|
964
|
+
Check whether a value exists (Array-compatible alias for `has`).
|
|
965
|
+
|
|
966
|
+
#### Parameters
|
|
967
|
+
|
|
968
|
+
##### element
|
|
969
|
+
|
|
970
|
+
`E`
|
|
971
|
+
|
|
972
|
+
Element to search for (uses `===`).
|
|
973
|
+
|
|
974
|
+
#### Returns
|
|
975
|
+
|
|
976
|
+
`boolean`
|
|
977
|
+
|
|
978
|
+
`true` if found.
|
|
979
|
+
|
|
980
|
+
#### Remarks
|
|
981
|
+
|
|
982
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
983
|
+
|
|
984
|
+
#### Inherited from
|
|
985
|
+
|
|
986
|
+
[`PriorityQueue`](PriorityQueue.md).[`includes`](PriorityQueue.md#includes)
|
|
987
|
+
|
|
988
|
+
***
|
|
989
|
+
|
|
955
990
|
### isEmpty()
|
|
956
991
|
|
|
957
992
|
```ts
|
|
958
993
|
isEmpty(): boolean;
|
|
959
994
|
```
|
|
960
995
|
|
|
961
|
-
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)
|
|
962
997
|
|
|
963
998
|
Check whether the heap is empty.
|
|
964
999
|
|
|
@@ -968,8 +1003,6 @@ Check whether the heap is empty.
|
|
|
968
1003
|
|
|
969
1004
|
True if size is 0.
|
|
970
1005
|
|
|
971
|
-
*
|
|
972
|
-
|
|
973
1006
|
#### Remarks
|
|
974
1007
|
|
|
975
1008
|
Time O(1), Space O(1)
|
|
@@ -990,6 +1023,30 @@ Time O(1), Space O(1)
|
|
|
990
1023
|
|
|
991
1024
|
***
|
|
992
1025
|
|
|
1026
|
+
### keys()
|
|
1027
|
+
|
|
1028
|
+
```ts
|
|
1029
|
+
keys(): IterableIterator<number>;
|
|
1030
|
+
```
|
|
1031
|
+
|
|
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)
|
|
1033
|
+
|
|
1034
|
+
Return an iterator of numeric indices (Array-compatible).
|
|
1035
|
+
|
|
1036
|
+
#### Returns
|
|
1037
|
+
|
|
1038
|
+
`IterableIterator`\<`number`\>
|
|
1039
|
+
|
|
1040
|
+
#### Remarks
|
|
1041
|
+
|
|
1042
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
1043
|
+
|
|
1044
|
+
#### Inherited from
|
|
1045
|
+
|
|
1046
|
+
[`PriorityQueue`](PriorityQueue.md).[`keys`](PriorityQueue.md#keys)
|
|
1047
|
+
|
|
1048
|
+
***
|
|
1049
|
+
|
|
993
1050
|
### map()
|
|
994
1051
|
|
|
995
1052
|
```ts
|
|
@@ -999,7 +1056,7 @@ map<EM, RM>(
|
|
|
999
1056
|
thisArg?): Heap<EM, RM>;
|
|
1000
1057
|
```
|
|
1001
1058
|
|
|
1002
|
-
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)
|
|
1003
1060
|
|
|
1004
1061
|
Map elements into a new heap of possibly different element type.
|
|
1005
1062
|
|
|
@@ -1039,8 +1096,6 @@ Value for `this` inside the callback.
|
|
|
1039
1096
|
|
|
1040
1097
|
A new heap with mapped elements.
|
|
1041
1098
|
|
|
1042
|
-
*
|
|
1043
|
-
|
|
1044
1099
|
#### Remarks
|
|
1045
1100
|
|
|
1046
1101
|
Time O(N log N), Space O(N)
|
|
@@ -1066,7 +1121,7 @@ Time O(N log N), Space O(N)
|
|
|
1066
1121
|
mapSame(callback, thisArg?): this;
|
|
1067
1122
|
```
|
|
1068
1123
|
|
|
1069
|
-
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)
|
|
1070
1125
|
|
|
1071
1126
|
Map elements into a new heap of the same element type.
|
|
1072
1127
|
|
|
@@ -1106,7 +1161,7 @@ Time O(N log N), Space O(N)
|
|
|
1106
1161
|
peek(): E | undefined;
|
|
1107
1162
|
```
|
|
1108
1163
|
|
|
1109
|
-
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)
|
|
1110
1165
|
|
|
1111
1166
|
Get the current top element without removing it.
|
|
1112
1167
|
|
|
@@ -1116,8 +1171,6 @@ Get the current top element without removing it.
|
|
|
1116
1171
|
|
|
1117
1172
|
Top element or undefined.
|
|
1118
1173
|
|
|
1119
|
-
*
|
|
1120
|
-
|
|
1121
1174
|
#### Remarks
|
|
1122
1175
|
|
|
1123
1176
|
Time O(1), Space O(1)
|
|
@@ -1197,7 +1250,7 @@ Time O(1), Space O(1)
|
|
|
1197
1250
|
poll(): E | undefined;
|
|
1198
1251
|
```
|
|
1199
1252
|
|
|
1200
|
-
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)
|
|
1201
1254
|
|
|
1202
1255
|
#### Returns
|
|
1203
1256
|
|
|
@@ -1206,7 +1259,6 @@ Defined in: [data-structures/heap/heap.ts:511](https://github.com/zrwusa/data-st
|
|
|
1206
1259
|
#### Deprecated
|
|
1207
1260
|
|
|
1208
1261
|
Use `pop` instead. Will be removed in a future major version.
|
|
1209
|
-
*
|
|
1210
1262
|
|
|
1211
1263
|
#### Example
|
|
1212
1264
|
|
|
@@ -1249,7 +1301,7 @@ Use `pop` instead. Will be removed in a future major version.
|
|
|
1249
1301
|
pop(): E | undefined;
|
|
1250
1302
|
```
|
|
1251
1303
|
|
|
1252
|
-
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)
|
|
1253
1305
|
|
|
1254
1306
|
Remove and return the top element (min or max depending on comparator).
|
|
1255
1307
|
|
|
@@ -1275,7 +1327,7 @@ Time O(log N) amortized, Space O(1)
|
|
|
1275
1327
|
print(): void;
|
|
1276
1328
|
```
|
|
1277
1329
|
|
|
1278
|
-
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)
|
|
1279
1331
|
|
|
1280
1332
|
Prints `toVisual()` to the console. Intended for quick debugging.
|
|
1281
1333
|
|
|
@@ -1333,7 +1385,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
|
|
|
1333
1385
|
reduce(callbackfn): E;
|
|
1334
1386
|
```
|
|
1335
1387
|
|
|
1336
|
-
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)
|
|
1337
1389
|
|
|
1338
1390
|
##### Parameters
|
|
1339
1391
|
|
|
@@ -1355,7 +1407,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
|
|
|
1355
1407
|
reduce(callbackfn, initialValue): E;
|
|
1356
1408
|
```
|
|
1357
1409
|
|
|
1358
|
-
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)
|
|
1359
1411
|
|
|
1360
1412
|
##### Parameters
|
|
1361
1413
|
|
|
@@ -1381,7 +1433,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
|
|
|
1381
1433
|
reduce<U>(callbackfn, initialValue): U;
|
|
1382
1434
|
```
|
|
1383
1435
|
|
|
1384
|
-
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)
|
|
1385
1437
|
|
|
1386
1438
|
##### Type Parameters
|
|
1387
1439
|
|
|
@@ -1415,7 +1467,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.c
|
|
|
1415
1467
|
setEquality(equals): this;
|
|
1416
1468
|
```
|
|
1417
1469
|
|
|
1418
|
-
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)
|
|
1419
1471
|
|
|
1420
1472
|
Set the equality comparator used by has/delete operations.
|
|
1421
1473
|
|
|
@@ -1489,7 +1541,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
|
|
|
1489
1541
|
sort(): E[];
|
|
1490
1542
|
```
|
|
1491
1543
|
|
|
1492
|
-
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)
|
|
1493
1545
|
|
|
1494
1546
|
Return all elements in ascending order by repeatedly polling.
|
|
1495
1547
|
|
|
@@ -1499,8 +1551,6 @@ Return all elements in ascending order by repeatedly polling.
|
|
|
1499
1551
|
|
|
1500
1552
|
Sorted array of elements.
|
|
1501
1553
|
|
|
1502
|
-
*
|
|
1503
|
-
|
|
1504
1554
|
#### Remarks
|
|
1505
1555
|
|
|
1506
1556
|
Time O(N log N), Space O(N)
|
|
@@ -1526,7 +1576,7 @@ Time O(N log N), Space O(N)
|
|
|
1526
1576
|
toArray(): E[];
|
|
1527
1577
|
```
|
|
1528
1578
|
|
|
1529
|
-
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)
|
|
1530
1580
|
|
|
1531
1581
|
Materializes the elements into a new array.
|
|
1532
1582
|
|
|
@@ -1552,7 +1602,7 @@ Time O(n), Space O(n).
|
|
|
1552
1602
|
toVisual(): E[];
|
|
1553
1603
|
```
|
|
1554
1604
|
|
|
1555
|
-
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)
|
|
1556
1606
|
|
|
1557
1607
|
Returns a representation of the structure suitable for quick visualization.
|
|
1558
1608
|
Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
@@ -1608,7 +1658,7 @@ static from<T, R, S>(
|
|
|
1608
1658
|
options?): S;
|
|
1609
1659
|
```
|
|
1610
1660
|
|
|
1611
|
-
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)
|
|
1612
1662
|
|
|
1613
1663
|
Create a heap of the same class from an iterable.
|
|
1614
1664
|
|
|
@@ -1666,7 +1716,7 @@ Time O(N), Space O(N)
|
|
|
1666
1716
|
static heapify<EE, RR>(elements, options): Heap<EE, RR>;
|
|
1667
1717
|
```
|
|
1668
1718
|
|
|
1669
|
-
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)
|
|
1670
1720
|
|
|
1671
1721
|
Build a Heap from an iterable in linear time given a comparator.
|
|
1672
1722
|
|
|
@@ -1749,7 +1799,7 @@ Time O(1), Space O(1).
|
|
|
1749
1799
|
protected _createInstance(options?): this;
|
|
1750
1800
|
```
|
|
1751
1801
|
|
|
1752
|
-
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)
|
|
1753
1803
|
|
|
1754
1804
|
(Protected) Create an empty instance of the same concrete class.
|
|
1755
1805
|
|
|
@@ -1783,7 +1833,7 @@ Time O(1), Space O(1)
|
|
|
1783
1833
|
protected _createLike<EM, RM>(elements?, options?): Heap<EM, RM>;
|
|
1784
1834
|
```
|
|
1785
1835
|
|
|
1786
|
-
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)
|
|
1787
1837
|
|
|
1788
1838
|
(Protected) Create a like-kind instance seeded by elements.
|
|
1789
1839
|
|
|
@@ -1833,7 +1883,7 @@ Time O(N log N), Space O(N)
|
|
|
1833
1883
|
protected _getIterator(): IterableIterator<E>;
|
|
1834
1884
|
```
|
|
1835
1885
|
|
|
1836
|
-
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)
|
|
1837
1887
|
|
|
1838
1888
|
Internal iterator factory used by the default iterator.
|
|
1839
1889
|
|
|
@@ -1859,7 +1909,7 @@ Implementations should yield in O(1) per element with O(1) extra space when poss
|
|
|
1859
1909
|
protected _spawnLike<EM, RM>(options?): Heap<EM, RM>;
|
|
1860
1910
|
```
|
|
1861
1911
|
|
|
1862
|
-
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)
|
|
1863
1913
|
|
|
1864
1914
|
(Protected) Spawn an empty like-kind heap instance.
|
|
1865
1915
|
|