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: 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)
|
|
@@ -616,6 +602,30 @@ Time O(N), Space O(H)
|
|
|
616
602
|
|
|
617
603
|
***
|
|
618
604
|
|
|
605
|
+
### entries()
|
|
606
|
+
|
|
607
|
+
```ts
|
|
608
|
+
entries(): IterableIterator<[number, E]>;
|
|
609
|
+
```
|
|
610
|
+
|
|
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)
|
|
612
|
+
|
|
613
|
+
Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
614
|
+
|
|
615
|
+
#### Returns
|
|
616
|
+
|
|
617
|
+
`IterableIterator`\<\[`number`, `E`\]\>
|
|
618
|
+
|
|
619
|
+
#### Remarks
|
|
620
|
+
|
|
621
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
622
|
+
|
|
623
|
+
#### Inherited from
|
|
624
|
+
|
|
625
|
+
[`Heap`](Heap.md).[`entries`](Heap.md#entries)
|
|
626
|
+
|
|
627
|
+
***
|
|
628
|
+
|
|
619
629
|
### every()
|
|
620
630
|
|
|
621
631
|
```ts
|
|
@@ -662,7 +672,7 @@ Time O(n) in the worst case; may exit early when the first failure is found. Spa
|
|
|
662
672
|
filter(callback, thisArg?): this;
|
|
663
673
|
```
|
|
664
674
|
|
|
665
|
-
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)
|
|
666
676
|
|
|
667
677
|
Filter elements into a new heap of the same class.
|
|
668
678
|
|
|
@@ -686,8 +696,6 @@ Value for `this` inside the callback.
|
|
|
686
696
|
|
|
687
697
|
A new heap with the kept elements.
|
|
688
698
|
|
|
689
|
-
*
|
|
690
|
-
|
|
691
699
|
#### Remarks
|
|
692
700
|
|
|
693
701
|
Time O(N log N), Space O(N)
|
|
@@ -803,7 +811,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
|
803
811
|
fix(): boolean[];
|
|
804
812
|
```
|
|
805
813
|
|
|
806
|
-
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)
|
|
807
815
|
|
|
808
816
|
Restore heap order bottom-up (heapify in-place).
|
|
809
817
|
|
|
@@ -869,7 +877,7 @@ Time O(n), Space O(1).
|
|
|
869
877
|
has(element): boolean;
|
|
870
878
|
```
|
|
871
879
|
|
|
872
|
-
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)
|
|
873
881
|
|
|
874
882
|
Check if an equal element exists in the heap.
|
|
875
883
|
|
|
@@ -887,8 +895,6 @@ Element to search for.
|
|
|
887
895
|
|
|
888
896
|
True if found.
|
|
889
897
|
|
|
890
|
-
*
|
|
891
|
-
|
|
892
898
|
#### Remarks
|
|
893
899
|
|
|
894
900
|
Time O(N), Space O(1)
|
|
@@ -908,13 +914,47 @@ Time O(N), Space O(1)
|
|
|
908
914
|
|
|
909
915
|
***
|
|
910
916
|
|
|
917
|
+
### includes()
|
|
918
|
+
|
|
919
|
+
```ts
|
|
920
|
+
includes(element): boolean;
|
|
921
|
+
```
|
|
922
|
+
|
|
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)
|
|
924
|
+
|
|
925
|
+
Check whether a value exists (Array-compatible alias for `has`).
|
|
926
|
+
|
|
927
|
+
#### Parameters
|
|
928
|
+
|
|
929
|
+
##### element
|
|
930
|
+
|
|
931
|
+
`E`
|
|
932
|
+
|
|
933
|
+
Element to search for (uses `===`).
|
|
934
|
+
|
|
935
|
+
#### Returns
|
|
936
|
+
|
|
937
|
+
`boolean`
|
|
938
|
+
|
|
939
|
+
`true` if found.
|
|
940
|
+
|
|
941
|
+
#### Remarks
|
|
942
|
+
|
|
943
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
944
|
+
|
|
945
|
+
#### Inherited from
|
|
946
|
+
|
|
947
|
+
[`Heap`](Heap.md).[`includes`](Heap.md#includes)
|
|
948
|
+
|
|
949
|
+
***
|
|
950
|
+
|
|
911
951
|
### isEmpty()
|
|
912
952
|
|
|
913
953
|
```ts
|
|
914
954
|
isEmpty(): boolean;
|
|
915
955
|
```
|
|
916
956
|
|
|
917
|
-
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)
|
|
918
958
|
|
|
919
959
|
Check whether the heap is empty.
|
|
920
960
|
|
|
@@ -924,8 +964,6 @@ Check whether the heap is empty.
|
|
|
924
964
|
|
|
925
965
|
True if size is 0.
|
|
926
966
|
|
|
927
|
-
*
|
|
928
|
-
|
|
929
967
|
#### Remarks
|
|
930
968
|
|
|
931
969
|
Time O(1), Space O(1)
|
|
@@ -946,6 +984,30 @@ Time O(1), Space O(1)
|
|
|
946
984
|
|
|
947
985
|
***
|
|
948
986
|
|
|
987
|
+
### keys()
|
|
988
|
+
|
|
989
|
+
```ts
|
|
990
|
+
keys(): IterableIterator<number>;
|
|
991
|
+
```
|
|
992
|
+
|
|
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)
|
|
994
|
+
|
|
995
|
+
Return an iterator of numeric indices (Array-compatible).
|
|
996
|
+
|
|
997
|
+
#### Returns
|
|
998
|
+
|
|
999
|
+
`IterableIterator`\<`number`\>
|
|
1000
|
+
|
|
1001
|
+
#### Remarks
|
|
1002
|
+
|
|
1003
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
1004
|
+
|
|
1005
|
+
#### Inherited from
|
|
1006
|
+
|
|
1007
|
+
[`Heap`](Heap.md).[`keys`](Heap.md#keys)
|
|
1008
|
+
|
|
1009
|
+
***
|
|
1010
|
+
|
|
949
1011
|
### map()
|
|
950
1012
|
|
|
951
1013
|
```ts
|
|
@@ -955,7 +1017,7 @@ map<EM, RM>(
|
|
|
955
1017
|
thisArg?): Heap<EM, RM>;
|
|
956
1018
|
```
|
|
957
1019
|
|
|
958
|
-
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)
|
|
959
1021
|
|
|
960
1022
|
Map elements into a new heap of possibly different element type.
|
|
961
1023
|
|
|
@@ -995,8 +1057,6 @@ Value for `this` inside the callback.
|
|
|
995
1057
|
|
|
996
1058
|
A new heap with mapped elements.
|
|
997
1059
|
|
|
998
|
-
*
|
|
999
|
-
|
|
1000
1060
|
#### Remarks
|
|
1001
1061
|
|
|
1002
1062
|
Time O(N log N), Space O(N)
|
|
@@ -1022,7 +1082,7 @@ Time O(N log N), Space O(N)
|
|
|
1022
1082
|
mapSame(callback, thisArg?): this;
|
|
1023
1083
|
```
|
|
1024
1084
|
|
|
1025
|
-
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)
|
|
1026
1086
|
|
|
1027
1087
|
Map elements into a new heap of the same element type.
|
|
1028
1088
|
|
|
@@ -1062,7 +1122,7 @@ Time O(N log N), Space O(N)
|
|
|
1062
1122
|
peek(): E | undefined;
|
|
1063
1123
|
```
|
|
1064
1124
|
|
|
1065
|
-
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)
|
|
1066
1126
|
|
|
1067
1127
|
Get the current top element without removing it.
|
|
1068
1128
|
|
|
@@ -1072,8 +1132,6 @@ Get the current top element without removing it.
|
|
|
1072
1132
|
|
|
1073
1133
|
Top element or undefined.
|
|
1074
1134
|
|
|
1075
|
-
*
|
|
1076
|
-
|
|
1077
1135
|
#### Remarks
|
|
1078
1136
|
|
|
1079
1137
|
Time O(1), Space O(1)
|
|
@@ -1153,7 +1211,7 @@ Time O(1), Space O(1)
|
|
|
1153
1211
|
poll(): E | undefined;
|
|
1154
1212
|
```
|
|
1155
1213
|
|
|
1156
|
-
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)
|
|
1157
1215
|
|
|
1158
1216
|
#### Returns
|
|
1159
1217
|
|
|
@@ -1162,7 +1220,6 @@ Defined in: [data-structures/heap/heap.ts:511](https://github.com/zrwusa/data-st
|
|
|
1162
1220
|
#### Deprecated
|
|
1163
1221
|
|
|
1164
1222
|
Use `pop` instead. Will be removed in a future major version.
|
|
1165
|
-
*
|
|
1166
1223
|
|
|
1167
1224
|
#### Example
|
|
1168
1225
|
|
|
@@ -1205,7 +1262,7 @@ Use `pop` instead. Will be removed in a future major version.
|
|
|
1205
1262
|
pop(): E | undefined;
|
|
1206
1263
|
```
|
|
1207
1264
|
|
|
1208
|
-
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)
|
|
1209
1266
|
|
|
1210
1267
|
Remove and return the top element (min or max depending on comparator).
|
|
1211
1268
|
|
|
@@ -1231,7 +1288,7 @@ Time O(log N) amortized, Space O(1)
|
|
|
1231
1288
|
print(): void;
|
|
1232
1289
|
```
|
|
1233
1290
|
|
|
1234
|
-
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)
|
|
1235
1292
|
|
|
1236
1293
|
Prints `toVisual()` to the console. Intended for quick debugging.
|
|
1237
1294
|
|
|
@@ -1289,7 +1346,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
|
|
|
1289
1346
|
reduce(callbackfn): E;
|
|
1290
1347
|
```
|
|
1291
1348
|
|
|
1292
|
-
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)
|
|
1293
1350
|
|
|
1294
1351
|
##### Parameters
|
|
1295
1352
|
|
|
@@ -1311,7 +1368,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
|
|
|
1311
1368
|
reduce(callbackfn, initialValue): E;
|
|
1312
1369
|
```
|
|
1313
1370
|
|
|
1314
|
-
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)
|
|
1315
1372
|
|
|
1316
1373
|
##### Parameters
|
|
1317
1374
|
|
|
@@ -1337,7 +1394,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
|
|
|
1337
1394
|
reduce<U>(callbackfn, initialValue): U;
|
|
1338
1395
|
```
|
|
1339
1396
|
|
|
1340
|
-
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)
|
|
1341
1398
|
|
|
1342
1399
|
##### Type Parameters
|
|
1343
1400
|
|
|
@@ -1371,7 +1428,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.c
|
|
|
1371
1428
|
setEquality(equals): this;
|
|
1372
1429
|
```
|
|
1373
1430
|
|
|
1374
|
-
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)
|
|
1375
1432
|
|
|
1376
1433
|
Set the equality comparator used by has/delete operations.
|
|
1377
1434
|
|
|
@@ -1445,7 +1502,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
|
|
|
1445
1502
|
sort(): E[];
|
|
1446
1503
|
```
|
|
1447
1504
|
|
|
1448
|
-
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)
|
|
1449
1506
|
|
|
1450
1507
|
Return all elements in ascending order by repeatedly polling.
|
|
1451
1508
|
|
|
@@ -1455,8 +1512,6 @@ Return all elements in ascending order by repeatedly polling.
|
|
|
1455
1512
|
|
|
1456
1513
|
Sorted array of elements.
|
|
1457
1514
|
|
|
1458
|
-
*
|
|
1459
|
-
|
|
1460
1515
|
#### Remarks
|
|
1461
1516
|
|
|
1462
1517
|
Time O(N log N), Space O(N)
|
|
@@ -1482,7 +1537,7 @@ Time O(N log N), Space O(N)
|
|
|
1482
1537
|
toArray(): E[];
|
|
1483
1538
|
```
|
|
1484
1539
|
|
|
1485
|
-
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)
|
|
1486
1541
|
|
|
1487
1542
|
Materializes the elements into a new array.
|
|
1488
1543
|
|
|
@@ -1508,7 +1563,7 @@ Time O(n), Space O(n).
|
|
|
1508
1563
|
toVisual(): E[];
|
|
1509
1564
|
```
|
|
1510
1565
|
|
|
1511
|
-
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)
|
|
1512
1567
|
|
|
1513
1568
|
Returns a representation of the structure suitable for quick visualization.
|
|
1514
1569
|
Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
@@ -1564,7 +1619,7 @@ static from<T, R, S>(
|
|
|
1564
1619
|
options?): S;
|
|
1565
1620
|
```
|
|
1566
1621
|
|
|
1567
|
-
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)
|
|
1568
1623
|
|
|
1569
1624
|
Create a heap of the same class from an iterable.
|
|
1570
1625
|
|
|
@@ -1622,7 +1677,7 @@ Time O(N), Space O(N)
|
|
|
1622
1677
|
static heapify<EE, RR>(elements, options): Heap<EE, RR>;
|
|
1623
1678
|
```
|
|
1624
1679
|
|
|
1625
|
-
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)
|
|
1626
1681
|
|
|
1627
1682
|
Build a Heap from an iterable in linear time given a comparator.
|
|
1628
1683
|
|
|
@@ -1705,7 +1760,7 @@ Time O(1), Space O(1).
|
|
|
1705
1760
|
protected _createInstance(options?): this;
|
|
1706
1761
|
```
|
|
1707
1762
|
|
|
1708
|
-
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)
|
|
1709
1764
|
|
|
1710
1765
|
(Protected) Create an empty instance of the same concrete class.
|
|
1711
1766
|
|
|
@@ -1739,7 +1794,7 @@ Time O(1), Space O(1)
|
|
|
1739
1794
|
protected _createLike<EM, RM>(elements?, options?): Heap<EM, RM>;
|
|
1740
1795
|
```
|
|
1741
1796
|
|
|
1742
|
-
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)
|
|
1743
1798
|
|
|
1744
1799
|
(Protected) Create a like-kind instance seeded by elements.
|
|
1745
1800
|
|
|
@@ -1789,7 +1844,7 @@ Time O(N log N), Space O(N)
|
|
|
1789
1844
|
protected _getIterator(): IterableIterator<E>;
|
|
1790
1845
|
```
|
|
1791
1846
|
|
|
1792
|
-
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)
|
|
1793
1848
|
|
|
1794
1849
|
Internal iterator factory used by the default iterator.
|
|
1795
1850
|
|
|
@@ -1815,7 +1870,7 @@ Implementations should yield in O(1) per element with O(1) extra space when poss
|
|
|
1815
1870
|
protected _spawnLike<EM, RM>(options?): Heap<EM, RM>;
|
|
1816
1871
|
```
|
|
1817
1872
|
|
|
1818
|
-
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)
|
|
1819
1874
|
|
|
1820
1875
|
(Protected) Spawn an empty like-kind heap instance.
|
|
1821
1876
|
|