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
|
@@ -133,7 +133,7 @@ Optional configuration.
|
|
|
133
133
|
get comparator(): Comparator<E>;
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
136
|
+
Defined in: [data-structures/heap/heap.ts:211](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L211)
|
|
137
137
|
|
|
138
138
|
Get the comparator used to order elements.
|
|
139
139
|
|
|
@@ -161,7 +161,7 @@ Comparator function.
|
|
|
161
161
|
get elements(): E[];
|
|
162
162
|
```
|
|
163
163
|
|
|
164
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
164
|
+
Defined in: [data-structures/heap/heap.ts:175](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L175)
|
|
165
165
|
|
|
166
166
|
Get the backing array of the heap.
|
|
167
167
|
|
|
@@ -189,7 +189,7 @@ Internal elements array.
|
|
|
189
189
|
get leaf(): E | undefined;
|
|
190
190
|
```
|
|
191
191
|
|
|
192
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
192
|
+
Defined in: [data-structures/heap/heap.ts:202](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L202)
|
|
193
193
|
|
|
194
194
|
Get the last leaf element.
|
|
195
195
|
|
|
@@ -217,7 +217,7 @@ Last element or undefined.
|
|
|
217
217
|
get size(): number;
|
|
218
218
|
```
|
|
219
219
|
|
|
220
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
220
|
+
Defined in: [data-structures/heap/heap.ts:193](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L193)
|
|
221
221
|
|
|
222
222
|
Get the number of elements.
|
|
223
223
|
|
|
@@ -244,8 +244,6 @@ Time O(1), Space O(1)
|
|
|
244
244
|
|
|
245
245
|
Heap size.
|
|
246
246
|
|
|
247
|
-
*
|
|
248
|
-
|
|
249
247
|
#### Inherited from
|
|
250
248
|
|
|
251
249
|
[`Heap`](Heap.md).[`size`](Heap.md#size)
|
|
@@ -320,7 +318,7 @@ Producing the iterator is O(1); consuming the entire iterator is Time O(n) with
|
|
|
320
318
|
add(element): boolean;
|
|
321
319
|
```
|
|
322
320
|
|
|
323
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
321
|
+
Defined in: [data-structures/heap/heap.ts:267](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L267)
|
|
324
322
|
|
|
325
323
|
Insert an element.
|
|
326
324
|
|
|
@@ -338,8 +336,6 @@ Element to insert.
|
|
|
338
336
|
|
|
339
337
|
True.
|
|
340
338
|
|
|
341
|
-
*
|
|
342
|
-
|
|
343
339
|
#### Remarks
|
|
344
340
|
|
|
345
341
|
Time O(log N) amortized, Space O(1)
|
|
@@ -375,7 +371,7 @@ Time O(log N) amortized, Space O(1)
|
|
|
375
371
|
addMany(elements): boolean[];
|
|
376
372
|
```
|
|
377
373
|
|
|
378
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
374
|
+
Defined in: [data-structures/heap/heap.ts:284](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L284)
|
|
379
375
|
|
|
380
376
|
Insert many elements from an iterable.
|
|
381
377
|
|
|
@@ -393,8 +389,6 @@ Iterable of elements or raw values.
|
|
|
393
389
|
|
|
394
390
|
Array of per-element success flags.
|
|
395
391
|
|
|
396
|
-
*
|
|
397
|
-
|
|
398
392
|
#### Remarks
|
|
399
393
|
|
|
400
394
|
Time O(N log N), Space O(1)
|
|
@@ -421,7 +415,7 @@ Time O(N log N), Space O(1)
|
|
|
421
415
|
clear(): void;
|
|
422
416
|
```
|
|
423
417
|
|
|
424
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
418
|
+
Defined in: [data-structures/heap/heap.ts:469](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L469)
|
|
425
419
|
|
|
426
420
|
Remove all elements.
|
|
427
421
|
|
|
@@ -431,8 +425,6 @@ Remove all elements.
|
|
|
431
425
|
|
|
432
426
|
void
|
|
433
427
|
|
|
434
|
-
*
|
|
435
|
-
|
|
436
428
|
#### Remarks
|
|
437
429
|
|
|
438
430
|
Time O(1), Space O(1)
|
|
@@ -458,7 +450,7 @@ Time O(1), Space O(1)
|
|
|
458
450
|
clone(): this;
|
|
459
451
|
```
|
|
460
452
|
|
|
461
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
453
|
+
Defined in: [data-structures/heap/heap.ts:648](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L648)
|
|
462
454
|
|
|
463
455
|
Deep clone this heap.
|
|
464
456
|
|
|
@@ -468,8 +460,6 @@ Deep clone this heap.
|
|
|
468
460
|
|
|
469
461
|
A new heap with the same elements.
|
|
470
462
|
|
|
471
|
-
*
|
|
472
|
-
|
|
473
463
|
#### Remarks
|
|
474
464
|
|
|
475
465
|
Time O(N), Space O(N)
|
|
@@ -497,7 +487,7 @@ Time O(N), Space O(N)
|
|
|
497
487
|
delete(element): boolean;
|
|
498
488
|
```
|
|
499
489
|
|
|
500
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
490
|
+
Defined in: [data-structures/heap/heap.ts:500](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L500)
|
|
501
491
|
|
|
502
492
|
Delete one occurrence of an element.
|
|
503
493
|
|
|
@@ -515,8 +505,6 @@ Element to delete.
|
|
|
515
505
|
|
|
516
506
|
True if an element was removed.
|
|
517
507
|
|
|
518
|
-
*
|
|
519
|
-
|
|
520
508
|
#### Remarks
|
|
521
509
|
|
|
522
510
|
Time O(N), Space O(1)
|
|
@@ -542,7 +530,7 @@ Time O(N), Space O(1)
|
|
|
542
530
|
deleteBy(predicate): boolean;
|
|
543
531
|
```
|
|
544
532
|
|
|
545
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
533
|
+
Defined in: [data-structures/heap/heap.ts:524](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L524)
|
|
546
534
|
|
|
547
535
|
#### Parameters
|
|
548
536
|
|
|
@@ -570,7 +558,7 @@ Use `deleteWhere` instead. Will be removed in a future major version.
|
|
|
570
558
|
deleteWhere(predicate): boolean;
|
|
571
559
|
```
|
|
572
560
|
|
|
573
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
561
|
+
Defined in: [data-structures/heap/heap.ts:534](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L534)
|
|
574
562
|
|
|
575
563
|
Delete the first element that matches a predicate.
|
|
576
564
|
|
|
@@ -604,7 +592,7 @@ Time O(N), Space O(1)
|
|
|
604
592
|
dfs(order?): E[];
|
|
605
593
|
```
|
|
606
594
|
|
|
607
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
595
|
+
Defined in: [data-structures/heap/heap.ts:577](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L577)
|
|
608
596
|
|
|
609
597
|
Traverse the binary heap as a complete binary tree and collect elements.
|
|
610
598
|
|
|
@@ -622,8 +610,6 @@ Traversal order: 'PRE' | 'IN' | 'POST'.
|
|
|
622
610
|
|
|
623
611
|
Array of visited elements.
|
|
624
612
|
|
|
625
|
-
*
|
|
626
|
-
|
|
627
613
|
#### Remarks
|
|
628
614
|
|
|
629
615
|
Time O(N), Space O(H)
|
|
@@ -643,6 +629,30 @@ Time O(N), Space O(H)
|
|
|
643
629
|
|
|
644
630
|
***
|
|
645
631
|
|
|
632
|
+
### entries()
|
|
633
|
+
|
|
634
|
+
```ts
|
|
635
|
+
entries(): IterableIterator<[number, E]>;
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
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)
|
|
639
|
+
|
|
640
|
+
Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
641
|
+
|
|
642
|
+
#### Returns
|
|
643
|
+
|
|
644
|
+
`IterableIterator`\<\[`number`, `E`\]\>
|
|
645
|
+
|
|
646
|
+
#### Remarks
|
|
647
|
+
|
|
648
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
649
|
+
|
|
650
|
+
#### Inherited from
|
|
651
|
+
|
|
652
|
+
[`Heap`](Heap.md).[`entries`](Heap.md#entries)
|
|
653
|
+
|
|
654
|
+
***
|
|
655
|
+
|
|
646
656
|
### every()
|
|
647
657
|
|
|
648
658
|
```ts
|
|
@@ -689,7 +699,7 @@ Time O(n) in the worst case; may exit early when the first failure is found. Spa
|
|
|
689
699
|
filter(callback, thisArg?): this;
|
|
690
700
|
```
|
|
691
701
|
|
|
692
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
702
|
+
Defined in: [data-structures/heap/heap.ts:666](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L666)
|
|
693
703
|
|
|
694
704
|
Filter elements into a new heap of the same class.
|
|
695
705
|
|
|
@@ -713,8 +723,6 @@ Value for `this` inside the callback.
|
|
|
713
723
|
|
|
714
724
|
A new heap with the kept elements.
|
|
715
725
|
|
|
716
|
-
*
|
|
717
|
-
|
|
718
726
|
#### Remarks
|
|
719
727
|
|
|
720
728
|
Time O(N log N), Space O(N)
|
|
@@ -830,7 +838,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
|
830
838
|
fix(): boolean[];
|
|
831
839
|
```
|
|
832
840
|
|
|
833
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
841
|
+
Defined in: [data-structures/heap/heap.ts:607](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L607)
|
|
834
842
|
|
|
835
843
|
Restore heap order bottom-up (heapify in-place).
|
|
836
844
|
|
|
@@ -896,7 +904,7 @@ Time O(n), Space O(1).
|
|
|
896
904
|
has(element): boolean;
|
|
897
905
|
```
|
|
898
906
|
|
|
899
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
907
|
+
Defined in: [data-structures/heap/heap.ts:484](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L484)
|
|
900
908
|
|
|
901
909
|
Check if an equal element exists in the heap.
|
|
902
910
|
|
|
@@ -914,8 +922,6 @@ Element to search for.
|
|
|
914
922
|
|
|
915
923
|
True if found.
|
|
916
924
|
|
|
917
|
-
*
|
|
918
|
-
|
|
919
925
|
#### Remarks
|
|
920
926
|
|
|
921
927
|
Time O(N), Space O(1)
|
|
@@ -935,13 +941,47 @@ Time O(N), Space O(1)
|
|
|
935
941
|
|
|
936
942
|
***
|
|
937
943
|
|
|
944
|
+
### includes()
|
|
945
|
+
|
|
946
|
+
```ts
|
|
947
|
+
includes(element): boolean;
|
|
948
|
+
```
|
|
949
|
+
|
|
950
|
+
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)
|
|
951
|
+
|
|
952
|
+
Check whether a value exists (Array-compatible alias for `has`).
|
|
953
|
+
|
|
954
|
+
#### Parameters
|
|
955
|
+
|
|
956
|
+
##### element
|
|
957
|
+
|
|
958
|
+
`E`
|
|
959
|
+
|
|
960
|
+
Element to search for (uses `===`).
|
|
961
|
+
|
|
962
|
+
#### Returns
|
|
963
|
+
|
|
964
|
+
`boolean`
|
|
965
|
+
|
|
966
|
+
`true` if found.
|
|
967
|
+
|
|
968
|
+
#### Remarks
|
|
969
|
+
|
|
970
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
971
|
+
|
|
972
|
+
#### Inherited from
|
|
973
|
+
|
|
974
|
+
[`Heap`](Heap.md).[`includes`](Heap.md#includes)
|
|
975
|
+
|
|
976
|
+
***
|
|
977
|
+
|
|
938
978
|
### isEmpty()
|
|
939
979
|
|
|
940
980
|
```ts
|
|
941
981
|
isEmpty(): boolean;
|
|
942
982
|
```
|
|
943
983
|
|
|
944
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
984
|
+
Defined in: [data-structures/heap/heap.ts:455](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L455)
|
|
945
985
|
|
|
946
986
|
Check whether the heap is empty.
|
|
947
987
|
|
|
@@ -951,8 +991,6 @@ Check whether the heap is empty.
|
|
|
951
991
|
|
|
952
992
|
True if size is 0.
|
|
953
993
|
|
|
954
|
-
*
|
|
955
|
-
|
|
956
994
|
#### Remarks
|
|
957
995
|
|
|
958
996
|
Time O(1), Space O(1)
|
|
@@ -973,6 +1011,30 @@ Time O(1), Space O(1)
|
|
|
973
1011
|
|
|
974
1012
|
***
|
|
975
1013
|
|
|
1014
|
+
### keys()
|
|
1015
|
+
|
|
1016
|
+
```ts
|
|
1017
|
+
keys(): IterableIterator<number>;
|
|
1018
|
+
```
|
|
1019
|
+
|
|
1020
|
+
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)
|
|
1021
|
+
|
|
1022
|
+
Return an iterator of numeric indices (Array-compatible).
|
|
1023
|
+
|
|
1024
|
+
#### Returns
|
|
1025
|
+
|
|
1026
|
+
`IterableIterator`\<`number`\>
|
|
1027
|
+
|
|
1028
|
+
#### Remarks
|
|
1029
|
+
|
|
1030
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
1031
|
+
|
|
1032
|
+
#### Inherited from
|
|
1033
|
+
|
|
1034
|
+
[`Heap`](Heap.md).[`keys`](Heap.md#keys)
|
|
1035
|
+
|
|
1036
|
+
***
|
|
1037
|
+
|
|
976
1038
|
### map()
|
|
977
1039
|
|
|
978
1040
|
```ts
|
|
@@ -982,7 +1044,7 @@ map<EM, RM>(
|
|
|
982
1044
|
thisArg?): Heap<EM, RM>;
|
|
983
1045
|
```
|
|
984
1046
|
|
|
985
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1047
|
+
Defined in: [data-structures/heap/heap.ts:694](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L694)
|
|
986
1048
|
|
|
987
1049
|
Map elements into a new heap of possibly different element type.
|
|
988
1050
|
|
|
@@ -1022,8 +1084,6 @@ Value for `this` inside the callback.
|
|
|
1022
1084
|
|
|
1023
1085
|
A new heap with mapped elements.
|
|
1024
1086
|
|
|
1025
|
-
*
|
|
1026
|
-
|
|
1027
1087
|
#### Remarks
|
|
1028
1088
|
|
|
1029
1089
|
Time O(N log N), Space O(N)
|
|
@@ -1049,7 +1109,7 @@ Time O(N log N), Space O(N)
|
|
|
1049
1109
|
mapSame(callback, thisArg?): this;
|
|
1050
1110
|
```
|
|
1051
1111
|
|
|
1052
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1112
|
+
Defined in: [data-structures/heap/heap.ts:717](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L717)
|
|
1053
1113
|
|
|
1054
1114
|
Map elements into a new heap of the same element type.
|
|
1055
1115
|
|
|
@@ -1089,7 +1149,7 @@ Time O(N log N), Space O(N)
|
|
|
1089
1149
|
peek(): E | undefined;
|
|
1090
1150
|
```
|
|
1091
1151
|
|
|
1092
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1152
|
+
Defined in: [data-structures/heap/heap.ts:440](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L440)
|
|
1093
1153
|
|
|
1094
1154
|
Get the current top element without removing it.
|
|
1095
1155
|
|
|
@@ -1099,8 +1159,6 @@ Get the current top element without removing it.
|
|
|
1099
1159
|
|
|
1100
1160
|
Top element or undefined.
|
|
1101
1161
|
|
|
1102
|
-
*
|
|
1103
|
-
|
|
1104
1162
|
#### Remarks
|
|
1105
1163
|
|
|
1106
1164
|
Time O(1), Space O(1)
|
|
@@ -1180,7 +1238,7 @@ Time O(1), Space O(1)
|
|
|
1180
1238
|
poll(): E | undefined;
|
|
1181
1239
|
```
|
|
1182
1240
|
|
|
1183
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1241
|
+
Defined in: [data-structures/heap/heap.ts:356](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L356)
|
|
1184
1242
|
|
|
1185
1243
|
#### Returns
|
|
1186
1244
|
|
|
@@ -1189,7 +1247,6 @@ Defined in: [data-structures/heap/heap.ts:511](https://github.com/zrwusa/data-st
|
|
|
1189
1247
|
#### Deprecated
|
|
1190
1248
|
|
|
1191
1249
|
Use `pop` instead. Will be removed in a future major version.
|
|
1192
|
-
*
|
|
1193
1250
|
|
|
1194
1251
|
#### Example
|
|
1195
1252
|
|
|
@@ -1232,7 +1289,7 @@ Use `pop` instead. Will be removed in a future major version.
|
|
|
1232
1289
|
pop(): E | undefined;
|
|
1233
1290
|
```
|
|
1234
1291
|
|
|
1235
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1292
|
+
Defined in: [data-structures/heap/heap.ts:365](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L365)
|
|
1236
1293
|
|
|
1237
1294
|
Remove and return the top element (min or max depending on comparator).
|
|
1238
1295
|
|
|
@@ -1258,7 +1315,7 @@ Time O(log N) amortized, Space O(1)
|
|
|
1258
1315
|
print(): void;
|
|
1259
1316
|
```
|
|
1260
1317
|
|
|
1261
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1318
|
+
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)
|
|
1262
1319
|
|
|
1263
1320
|
Prints `toVisual()` to the console. Intended for quick debugging.
|
|
1264
1321
|
|
|
@@ -1316,7 +1373,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
|
|
|
1316
1373
|
reduce(callbackfn): E;
|
|
1317
1374
|
```
|
|
1318
1375
|
|
|
1319
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1376
|
+
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)
|
|
1320
1377
|
|
|
1321
1378
|
##### Parameters
|
|
1322
1379
|
|
|
@@ -1338,7 +1395,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
|
|
|
1338
1395
|
reduce(callbackfn, initialValue): E;
|
|
1339
1396
|
```
|
|
1340
1397
|
|
|
1341
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1398
|
+
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)
|
|
1342
1399
|
|
|
1343
1400
|
##### Parameters
|
|
1344
1401
|
|
|
@@ -1364,7 +1421,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
|
|
|
1364
1421
|
reduce<U>(callbackfn, initialValue): U;
|
|
1365
1422
|
```
|
|
1366
1423
|
|
|
1367
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1424
|
+
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)
|
|
1368
1425
|
|
|
1369
1426
|
##### Type Parameters
|
|
1370
1427
|
|
|
@@ -1398,7 +1455,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.c
|
|
|
1398
1455
|
setEquality(equals): this;
|
|
1399
1456
|
```
|
|
1400
1457
|
|
|
1401
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1458
|
+
Defined in: [data-structures/heap/heap.ts:561](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L561)
|
|
1402
1459
|
|
|
1403
1460
|
Set the equality comparator used by has/delete operations.
|
|
1404
1461
|
|
|
@@ -1472,7 +1529,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
|
|
|
1472
1529
|
sort(): E[];
|
|
1473
1530
|
```
|
|
1474
1531
|
|
|
1475
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1532
|
+
Defined in: [data-structures/heap/heap.ts:625](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L625)
|
|
1476
1533
|
|
|
1477
1534
|
Return all elements in ascending order by repeatedly polling.
|
|
1478
1535
|
|
|
@@ -1482,8 +1539,6 @@ Return all elements in ascending order by repeatedly polling.
|
|
|
1482
1539
|
|
|
1483
1540
|
Sorted array of elements.
|
|
1484
1541
|
|
|
1485
|
-
*
|
|
1486
|
-
|
|
1487
1542
|
#### Remarks
|
|
1488
1543
|
|
|
1489
1544
|
Time O(N log N), Space O(N)
|
|
@@ -1509,7 +1564,7 @@ Time O(N log N), Space O(N)
|
|
|
1509
1564
|
toArray(): E[];
|
|
1510
1565
|
```
|
|
1511
1566
|
|
|
1512
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1567
|
+
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)
|
|
1513
1568
|
|
|
1514
1569
|
Materializes the elements into a new array.
|
|
1515
1570
|
|
|
@@ -1535,7 +1590,7 @@ Time O(n), Space O(n).
|
|
|
1535
1590
|
toVisual(): E[];
|
|
1536
1591
|
```
|
|
1537
1592
|
|
|
1538
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1593
|
+
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)
|
|
1539
1594
|
|
|
1540
1595
|
Returns a representation of the structure suitable for quick visualization.
|
|
1541
1596
|
Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
@@ -1591,7 +1646,7 @@ static from<T, R, S>(
|
|
|
1591
1646
|
options?): S;
|
|
1592
1647
|
```
|
|
1593
1648
|
|
|
1594
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1649
|
+
Defined in: [data-structures/heap/heap.ts:225](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L225)
|
|
1595
1650
|
|
|
1596
1651
|
Create a heap of the same class from an iterable.
|
|
1597
1652
|
|
|
@@ -1649,7 +1704,7 @@ Time O(N), Space O(N)
|
|
|
1649
1704
|
static heapify<EE, RR>(elements, options): Heap<EE, RR>;
|
|
1650
1705
|
```
|
|
1651
1706
|
|
|
1652
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1707
|
+
Defined in: [data-structures/heap/heap.ts:242](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L242)
|
|
1653
1708
|
|
|
1654
1709
|
Build a Heap from an iterable in linear time given a comparator.
|
|
1655
1710
|
|
|
@@ -1732,7 +1787,7 @@ Time O(1), Space O(1).
|
|
|
1732
1787
|
protected _createInstance(options?): this;
|
|
1733
1788
|
```
|
|
1734
1789
|
|
|
1735
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1790
|
+
Defined in: [data-structures/heap/heap.ts:779](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L779)
|
|
1736
1791
|
|
|
1737
1792
|
(Protected) Create an empty instance of the same concrete class.
|
|
1738
1793
|
|
|
@@ -1766,7 +1821,7 @@ Time O(1), Space O(1)
|
|
|
1766
1821
|
protected _createLike<EM, RM>(elements?, options?): Heap<EM, RM>;
|
|
1767
1822
|
```
|
|
1768
1823
|
|
|
1769
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1824
|
+
Defined in: [data-structures/heap/heap.ts:793](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L793)
|
|
1770
1825
|
|
|
1771
1826
|
(Protected) Create a like-kind instance seeded by elements.
|
|
1772
1827
|
|
|
@@ -1816,7 +1871,7 @@ Time O(N log N), Space O(N)
|
|
|
1816
1871
|
protected _getIterator(): IterableIterator<E>;
|
|
1817
1872
|
```
|
|
1818
1873
|
|
|
1819
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1874
|
+
Defined in: [data-structures/heap/heap.ts:738](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L738)
|
|
1820
1875
|
|
|
1821
1876
|
Internal iterator factory used by the default iterator.
|
|
1822
1877
|
|
|
@@ -1842,7 +1897,7 @@ Implementations should yield in O(1) per element with O(1) extra space when poss
|
|
|
1842
1897
|
protected _spawnLike<EM, RM>(options?): Heap<EM, RM>;
|
|
1843
1898
|
```
|
|
1844
1899
|
|
|
1845
|
-
Defined in: [data-structures/heap/heap.ts:
|
|
1900
|
+
Defined in: [data-structures/heap/heap.ts:812](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/heap/heap.ts#L812)
|
|
1846
1901
|
|
|
1847
1902
|
(Protected) Spawn an empty like-kind heap instance.
|
|
1848
1903
|
|