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: Deque\<E, R\>
|
|
8
8
|
|
|
9
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
9
|
+
Defined in: [data-structures/queue/deque.ts:84](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L84)
|
|
10
10
|
|
|
11
11
|
Deque implemented with circular buckets allowing O(1) amortized push/pop at both ends.
|
|
12
12
|
|
|
@@ -103,7 +103,7 @@ Time O(1), Space O(1)
|
|
|
103
103
|
new Deque<E, R>(elements?, options?): Deque<E, R>;
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
106
|
+
Defined in: [data-structures/queue/deque.ts:98](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L98)
|
|
107
107
|
|
|
108
108
|
Create a Deque and optionally bulk-insert elements.
|
|
109
109
|
|
|
@@ -145,7 +145,7 @@ Time O(N), Space O(N)
|
|
|
145
145
|
get autoCompactRatio(): number;
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
148
|
+
Defined in: [data-structures/queue/deque.ts:148](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L148)
|
|
149
149
|
|
|
150
150
|
Get the auto-compaction ratio.
|
|
151
151
|
When `elements / (bucketCount * bucketSize)` drops below this ratio after
|
|
@@ -167,7 +167,7 @@ Current ratio threshold. 0 means auto-compact is disabled.
|
|
|
167
167
|
set autoCompactRatio(value): void;
|
|
168
168
|
```
|
|
169
169
|
|
|
170
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
170
|
+
Defined in: [data-structures/queue/deque.ts:157](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L157)
|
|
171
171
|
|
|
172
172
|
Set the auto-compaction ratio.
|
|
173
173
|
|
|
@@ -197,7 +197,7 @@ Ratio in [0,1]. 0 disables auto-compact.
|
|
|
197
197
|
get bucketCount(): number;
|
|
198
198
|
```
|
|
199
199
|
|
|
200
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
200
|
+
Defined in: [data-structures/queue/deque.ts:212](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L212)
|
|
201
201
|
|
|
202
202
|
Get the number of buckets allocated.
|
|
203
203
|
|
|
@@ -221,7 +221,7 @@ Bucket count.
|
|
|
221
221
|
get bucketFirst(): number;
|
|
222
222
|
```
|
|
223
223
|
|
|
224
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
224
|
+
Defined in: [data-structures/queue/deque.ts:168](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L168)
|
|
225
225
|
|
|
226
226
|
Get the index of the first bucket in use.
|
|
227
227
|
|
|
@@ -245,7 +245,7 @@ Zero-based bucket index.
|
|
|
245
245
|
get bucketLast(): number;
|
|
246
246
|
```
|
|
247
247
|
|
|
248
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
248
|
+
Defined in: [data-structures/queue/deque.ts:190](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L190)
|
|
249
249
|
|
|
250
250
|
Get the index of the last bucket in use.
|
|
251
251
|
|
|
@@ -269,7 +269,7 @@ Zero-based bucket index.
|
|
|
269
269
|
get buckets(): E[][];
|
|
270
270
|
```
|
|
271
271
|
|
|
272
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
272
|
+
Defined in: [data-structures/queue/deque.ts:223](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L223)
|
|
273
273
|
|
|
274
274
|
Get the internal buckets array.
|
|
275
275
|
|
|
@@ -293,7 +293,7 @@ Array of buckets storing values.
|
|
|
293
293
|
get bucketSize(): number;
|
|
294
294
|
```
|
|
295
295
|
|
|
296
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
296
|
+
Defined in: [data-structures/queue/deque.ts:135](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L135)
|
|
297
297
|
|
|
298
298
|
Get the current bucket size.
|
|
299
299
|
|
|
@@ -317,7 +317,7 @@ Bucket capacity per bucket.
|
|
|
317
317
|
get first(): E | undefined;
|
|
318
318
|
```
|
|
319
319
|
|
|
320
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
320
|
+
Defined in: [data-structures/queue/deque.ts:255](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L255)
|
|
321
321
|
|
|
322
322
|
Deque peek at both ends
|
|
323
323
|
|
|
@@ -353,7 +353,7 @@ Deque peek at both ends
|
|
|
353
353
|
get firstInBucket(): number;
|
|
354
354
|
```
|
|
355
355
|
|
|
356
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
356
|
+
Defined in: [data-structures/queue/deque.ts:179](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L179)
|
|
357
357
|
|
|
358
358
|
Get the index inside the first bucket.
|
|
359
359
|
|
|
@@ -377,7 +377,7 @@ Zero-based index within the first bucket.
|
|
|
377
377
|
get last(): E | undefined;
|
|
378
378
|
```
|
|
379
379
|
|
|
380
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
380
|
+
Defined in: [data-structures/queue/deque.ts:270](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L270)
|
|
381
381
|
|
|
382
382
|
Get the last element without removing it.
|
|
383
383
|
|
|
@@ -400,8 +400,6 @@ Time O(1), Space O(1)
|
|
|
400
400
|
|
|
401
401
|
Last element or undefined.
|
|
402
402
|
|
|
403
|
-
*
|
|
404
|
-
|
|
405
403
|
***
|
|
406
404
|
|
|
407
405
|
### lastInBucket
|
|
@@ -412,7 +410,7 @@ Last element or undefined.
|
|
|
412
410
|
get lastInBucket(): number;
|
|
413
411
|
```
|
|
414
412
|
|
|
415
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
413
|
+
Defined in: [data-structures/queue/deque.ts:201](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L201)
|
|
416
414
|
|
|
417
415
|
Get the index inside the last bucket.
|
|
418
416
|
|
|
@@ -436,7 +434,7 @@ Zero-based index within the last bucket.
|
|
|
436
434
|
get length(): number;
|
|
437
435
|
```
|
|
438
436
|
|
|
439
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
437
|
+
Defined in: [data-structures/queue/deque.ts:234](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L234)
|
|
440
438
|
|
|
441
439
|
Get the number of elements in the deque.
|
|
442
440
|
|
|
@@ -555,7 +553,7 @@ addAt(
|
|
|
555
553
|
num?): boolean;
|
|
556
554
|
```
|
|
557
555
|
|
|
558
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
556
|
+
Defined in: [data-structures/queue/deque.ts:570](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L570)
|
|
559
557
|
|
|
560
558
|
Insert repeated copies of an element at a position.
|
|
561
559
|
|
|
@@ -601,7 +599,7 @@ Time O(N), Space O(1)
|
|
|
601
599
|
at(pos): E | undefined;
|
|
602
600
|
```
|
|
603
601
|
|
|
604
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
602
|
+
Defined in: [data-structures/queue/deque.ts:542](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L542)
|
|
605
603
|
|
|
606
604
|
Get the element at a given position.
|
|
607
605
|
|
|
@@ -619,8 +617,6 @@ Zero-based position from the front.
|
|
|
619
617
|
|
|
620
618
|
Element or undefined.
|
|
621
619
|
|
|
622
|
-
*
|
|
623
|
-
|
|
624
620
|
#### Remarks
|
|
625
621
|
|
|
626
622
|
Time O(1), Space O(1)
|
|
@@ -646,7 +642,7 @@ Time O(1), Space O(1)
|
|
|
646
642
|
clear(): void;
|
|
647
643
|
```
|
|
648
644
|
|
|
649
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
645
|
+
Defined in: [data-structures/queue/deque.ts:524](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L524)
|
|
650
646
|
|
|
651
647
|
Remove all elements and reset structure.
|
|
652
648
|
|
|
@@ -656,8 +652,6 @@ Remove all elements and reset structure.
|
|
|
656
652
|
|
|
657
653
|
void
|
|
658
654
|
|
|
659
|
-
*
|
|
660
|
-
|
|
661
655
|
#### Remarks
|
|
662
656
|
|
|
663
657
|
Time O(1), Space O(1)
|
|
@@ -683,7 +677,7 @@ Time O(1), Space O(1)
|
|
|
683
677
|
clone(): this;
|
|
684
678
|
```
|
|
685
679
|
|
|
686
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
680
|
+
Defined in: [data-structures/queue/deque.ts:934](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L934)
|
|
687
681
|
|
|
688
682
|
Deep clone this deque, preserving options.
|
|
689
683
|
|
|
@@ -693,8 +687,6 @@ Deep clone this deque, preserving options.
|
|
|
693
687
|
|
|
694
688
|
A new deque with the same content and options.
|
|
695
689
|
|
|
696
|
-
*
|
|
697
|
-
|
|
698
690
|
#### Remarks
|
|
699
691
|
|
|
700
692
|
Time O(N), Space O(N)
|
|
@@ -722,7 +714,7 @@ Time O(N), Space O(N)
|
|
|
722
714
|
compact(): boolean;
|
|
723
715
|
```
|
|
724
716
|
|
|
725
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
717
|
+
Defined in: [data-structures/queue/deque.ts:894](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L894)
|
|
726
718
|
|
|
727
719
|
Compact the deque by removing unused buckets.
|
|
728
720
|
|
|
@@ -732,8 +724,6 @@ Compact the deque by removing unused buckets.
|
|
|
732
724
|
|
|
733
725
|
True if compaction was performed (bucket count reduced).
|
|
734
726
|
|
|
735
|
-
*
|
|
736
|
-
|
|
737
727
|
#### Remarks
|
|
738
728
|
|
|
739
729
|
Time O(N), Space O(1)
|
|
@@ -757,7 +747,7 @@ Time O(N), Space O(1)
|
|
|
757
747
|
concat(...items): this;
|
|
758
748
|
```
|
|
759
749
|
|
|
760
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
750
|
+
Defined in: [data-structures/base/linear-base.ts:161](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L161)
|
|
761
751
|
|
|
762
752
|
Concatenate elements and/or containers.
|
|
763
753
|
|
|
@@ -791,7 +781,7 @@ Time O(sum(length)), Space O(sum(length))
|
|
|
791
781
|
cut(pos, isCutSelf?): Deque<E>;
|
|
792
782
|
```
|
|
793
783
|
|
|
794
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
784
|
+
Defined in: [data-structures/queue/deque.ts:597](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L597)
|
|
795
785
|
|
|
796
786
|
Cut the deque to keep items up to index; optionally mutate in-place.
|
|
797
787
|
|
|
@@ -827,7 +817,7 @@ Time O(N), Space O(1)
|
|
|
827
817
|
cutRest(pos, isCutSelf?): Deque<E>;
|
|
828
818
|
```
|
|
829
819
|
|
|
830
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
820
|
+
Defined in: [data-structures/queue/deque.ts:655](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L655)
|
|
831
821
|
|
|
832
822
|
Cut the deque to keep items from index onward; optionally mutate in-place.
|
|
833
823
|
|
|
@@ -863,7 +853,7 @@ Time O(N), Space O(1)
|
|
|
863
853
|
delete(element): boolean;
|
|
864
854
|
```
|
|
865
855
|
|
|
866
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
856
|
+
Defined in: [data-structures/queue/deque.ts:717](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L717)
|
|
867
857
|
|
|
868
858
|
Delete the first occurrence of a value.
|
|
869
859
|
|
|
@@ -881,8 +871,6 @@ Element to remove (using the configured equality).
|
|
|
881
871
|
|
|
882
872
|
True if an element was removed.
|
|
883
873
|
|
|
884
|
-
*
|
|
885
|
-
|
|
886
874
|
#### Remarks
|
|
887
875
|
|
|
888
876
|
Time O(N), Space O(1)
|
|
@@ -908,7 +896,7 @@ Time O(N), Space O(1)
|
|
|
908
896
|
deleteAt(pos): E | undefined;
|
|
909
897
|
```
|
|
910
898
|
|
|
911
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
899
|
+
Defined in: [data-structures/queue/deque.ts:683](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L683)
|
|
912
900
|
|
|
913
901
|
Delete the element at a given position.
|
|
914
902
|
|
|
@@ -942,7 +930,7 @@ Time O(N), Space O(1)
|
|
|
942
930
|
deleteWhere(predicate): boolean;
|
|
943
931
|
```
|
|
944
932
|
|
|
945
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
933
|
+
Defined in: [data-structures/queue/deque.ts:740](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L740)
|
|
946
934
|
|
|
947
935
|
Delete the first element matching a predicate.
|
|
948
936
|
|
|
@@ -966,6 +954,30 @@ Time O(N), Space O(1)
|
|
|
966
954
|
|
|
967
955
|
***
|
|
968
956
|
|
|
957
|
+
### entries()
|
|
958
|
+
|
|
959
|
+
```ts
|
|
960
|
+
entries(): IterableIterator<[number, E]>;
|
|
961
|
+
```
|
|
962
|
+
|
|
963
|
+
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)
|
|
964
|
+
|
|
965
|
+
Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
966
|
+
|
|
967
|
+
#### Returns
|
|
968
|
+
|
|
969
|
+
`IterableIterator`\<\[`number`, `E`\]\>
|
|
970
|
+
|
|
971
|
+
#### Remarks
|
|
972
|
+
|
|
973
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
974
|
+
|
|
975
|
+
#### Inherited from
|
|
976
|
+
|
|
977
|
+
[`LinearBase`](LinearBase.md).[`entries`](LinearBase.md#entries)
|
|
978
|
+
|
|
979
|
+
***
|
|
980
|
+
|
|
969
981
|
### every()
|
|
970
982
|
|
|
971
983
|
```ts
|
|
@@ -1015,7 +1027,7 @@ fill(
|
|
|
1015
1027
|
end?): this;
|
|
1016
1028
|
```
|
|
1017
1029
|
|
|
1018
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1030
|
+
Defined in: [data-structures/base/linear-base.ts:279](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L279)
|
|
1019
1031
|
|
|
1020
1032
|
Fill a range with a value.
|
|
1021
1033
|
|
|
@@ -1061,7 +1073,7 @@ Time O(n), Space O(1)
|
|
|
1061
1073
|
filter(predicate, thisArg?): this;
|
|
1062
1074
|
```
|
|
1063
1075
|
|
|
1064
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
1076
|
+
Defined in: [data-structures/queue/deque.ts:954](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L954)
|
|
1065
1077
|
|
|
1066
1078
|
Filter elements into a new deque of the same class.
|
|
1067
1079
|
|
|
@@ -1085,8 +1097,6 @@ Value for `this` inside the predicate.
|
|
|
1085
1097
|
|
|
1086
1098
|
A new deque with kept elements.
|
|
1087
1099
|
|
|
1088
|
-
*
|
|
1089
|
-
|
|
1090
1100
|
#### Remarks
|
|
1091
1101
|
|
|
1092
1102
|
Time O(N), Space O(N)
|
|
@@ -1202,7 +1212,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
|
1202
1212
|
findIndex(predicate, thisArg?): number;
|
|
1203
1213
|
```
|
|
1204
1214
|
|
|
1205
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1215
|
+
Defined in: [data-structures/base/linear-base.ts:147](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L147)
|
|
1206
1216
|
|
|
1207
1217
|
Find the first index matching a predicate.
|
|
1208
1218
|
|
|
@@ -1236,6 +1246,84 @@ Time O(n), Space O(1)
|
|
|
1236
1246
|
|
|
1237
1247
|
***
|
|
1238
1248
|
|
|
1249
|
+
### findLast()
|
|
1250
|
+
|
|
1251
|
+
```ts
|
|
1252
|
+
findLast(predicate): E | undefined;
|
|
1253
|
+
```
|
|
1254
|
+
|
|
1255
|
+
Defined in: [data-structures/queue/deque.ts:796](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L796)
|
|
1256
|
+
|
|
1257
|
+
Find the last value matching a predicate (scans back-to-front).
|
|
1258
|
+
|
|
1259
|
+
#### Parameters
|
|
1260
|
+
|
|
1261
|
+
##### predicate
|
|
1262
|
+
|
|
1263
|
+
(`value`, `index`, `deque`) => `boolean`
|
|
1264
|
+
|
|
1265
|
+
Function called with (value, index, deque).
|
|
1266
|
+
|
|
1267
|
+
#### Returns
|
|
1268
|
+
|
|
1269
|
+
`E` \| `undefined`
|
|
1270
|
+
|
|
1271
|
+
Matching value or undefined.
|
|
1272
|
+
|
|
1273
|
+
#### Remarks
|
|
1274
|
+
|
|
1275
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
1276
|
+
|
|
1277
|
+
#### Example
|
|
1278
|
+
|
|
1279
|
+
```ts
|
|
1280
|
+
// Find last matching value
|
|
1281
|
+
const d = new Deque([1, 2, 3, 4, 5]);
|
|
1282
|
+
console.log(d.findLast(v => v > 2)); // 5;
|
|
1283
|
+
console.log(d.findLast(v => v % 2 === 0)); // 4;
|
|
1284
|
+
```
|
|
1285
|
+
|
|
1286
|
+
***
|
|
1287
|
+
|
|
1288
|
+
### findLastIndex()
|
|
1289
|
+
|
|
1290
|
+
```ts
|
|
1291
|
+
findLastIndex(predicate): number;
|
|
1292
|
+
```
|
|
1293
|
+
|
|
1294
|
+
Defined in: [data-structures/queue/deque.ts:815](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L815)
|
|
1295
|
+
|
|
1296
|
+
Find the index of the last value matching a predicate (scans back-to-front).
|
|
1297
|
+
|
|
1298
|
+
#### Parameters
|
|
1299
|
+
|
|
1300
|
+
##### predicate
|
|
1301
|
+
|
|
1302
|
+
(`value`, `index`, `deque`) => `boolean`
|
|
1303
|
+
|
|
1304
|
+
Function called with (value, index, deque).
|
|
1305
|
+
|
|
1306
|
+
#### Returns
|
|
1307
|
+
|
|
1308
|
+
`number`
|
|
1309
|
+
|
|
1310
|
+
Matching index, or -1 if not found.
|
|
1311
|
+
|
|
1312
|
+
#### Remarks
|
|
1313
|
+
|
|
1314
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
1315
|
+
|
|
1316
|
+
#### Example
|
|
1317
|
+
|
|
1318
|
+
```ts
|
|
1319
|
+
// Find last matching index
|
|
1320
|
+
const d = new Deque([10, 20, 30, 20, 10]);
|
|
1321
|
+
console.log(d.findLastIndex(v => v === 20)); // 3;
|
|
1322
|
+
console.log(d.findLastIndex(v => v === 10)); // 4;
|
|
1323
|
+
```
|
|
1324
|
+
|
|
1325
|
+
***
|
|
1326
|
+
|
|
1239
1327
|
### forEach()
|
|
1240
1328
|
|
|
1241
1329
|
```ts
|
|
@@ -1282,7 +1370,7 @@ Time O(n), Space O(1).
|
|
|
1282
1370
|
has(element): boolean;
|
|
1283
1371
|
```
|
|
1284
1372
|
|
|
1285
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1373
|
+
Defined in: [data-structures/base/iterable-element-base.ts:188](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L188)
|
|
1286
1374
|
|
|
1287
1375
|
Checks whether a strictly-equal element exists in the structure.
|
|
1288
1376
|
|
|
@@ -1310,6 +1398,40 @@ Time O(n) in the worst case. Space O(1).
|
|
|
1310
1398
|
|
|
1311
1399
|
***
|
|
1312
1400
|
|
|
1401
|
+
### includes()
|
|
1402
|
+
|
|
1403
|
+
```ts
|
|
1404
|
+
includes(element): boolean;
|
|
1405
|
+
```
|
|
1406
|
+
|
|
1407
|
+
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)
|
|
1408
|
+
|
|
1409
|
+
Check whether a value exists (Array-compatible alias for `has`).
|
|
1410
|
+
|
|
1411
|
+
#### Parameters
|
|
1412
|
+
|
|
1413
|
+
##### element
|
|
1414
|
+
|
|
1415
|
+
`E`
|
|
1416
|
+
|
|
1417
|
+
Element to search for (uses `===`).
|
|
1418
|
+
|
|
1419
|
+
#### Returns
|
|
1420
|
+
|
|
1421
|
+
`boolean`
|
|
1422
|
+
|
|
1423
|
+
`true` if found.
|
|
1424
|
+
|
|
1425
|
+
#### Remarks
|
|
1426
|
+
|
|
1427
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
1428
|
+
|
|
1429
|
+
#### Inherited from
|
|
1430
|
+
|
|
1431
|
+
[`LinearBase`](LinearBase.md).[`includes`](LinearBase.md#includes)
|
|
1432
|
+
|
|
1433
|
+
***
|
|
1434
|
+
|
|
1313
1435
|
### indexOf()
|
|
1314
1436
|
|
|
1315
1437
|
```ts
|
|
@@ -1356,7 +1478,7 @@ Time O(n), Space O(1)
|
|
|
1356
1478
|
isEmpty(): boolean;
|
|
1357
1479
|
```
|
|
1358
1480
|
|
|
1359
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
1481
|
+
Defined in: [data-structures/queue/deque.ts:510](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L510)
|
|
1360
1482
|
|
|
1361
1483
|
Check whether the deque is empty.
|
|
1362
1484
|
|
|
@@ -1366,8 +1488,6 @@ Check whether the deque is empty.
|
|
|
1366
1488
|
|
|
1367
1489
|
True if length is 0.
|
|
1368
1490
|
|
|
1369
|
-
*
|
|
1370
|
-
|
|
1371
1491
|
#### Remarks
|
|
1372
1492
|
|
|
1373
1493
|
Time O(1), Space O(1)
|
|
@@ -1392,7 +1512,7 @@ Time O(1), Space O(1)
|
|
|
1392
1512
|
join(separator?): string;
|
|
1393
1513
|
```
|
|
1394
1514
|
|
|
1395
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1515
|
+
Defined in: [data-structures/base/linear-base.ts:218](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L218)
|
|
1396
1516
|
|
|
1397
1517
|
Join all elements into a string.
|
|
1398
1518
|
|
|
@@ -1420,13 +1540,37 @@ Time O(n), Space O(n)
|
|
|
1420
1540
|
|
|
1421
1541
|
***
|
|
1422
1542
|
|
|
1543
|
+
### keys()
|
|
1544
|
+
|
|
1545
|
+
```ts
|
|
1546
|
+
keys(): IterableIterator<number>;
|
|
1547
|
+
```
|
|
1548
|
+
|
|
1549
|
+
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)
|
|
1550
|
+
|
|
1551
|
+
Return an iterator of numeric indices (Array-compatible).
|
|
1552
|
+
|
|
1553
|
+
#### Returns
|
|
1554
|
+
|
|
1555
|
+
`IterableIterator`\<`number`\>
|
|
1556
|
+
|
|
1557
|
+
#### Remarks
|
|
1558
|
+
|
|
1559
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
1560
|
+
|
|
1561
|
+
#### Inherited from
|
|
1562
|
+
|
|
1563
|
+
[`LinearBase`](LinearBase.md).[`keys`](LinearBase.md#keys)
|
|
1564
|
+
|
|
1565
|
+
***
|
|
1566
|
+
|
|
1423
1567
|
### lastIndexOf()
|
|
1424
1568
|
|
|
1425
1569
|
```ts
|
|
1426
1570
|
lastIndexOf(searchElement, fromIndex?): number;
|
|
1427
1571
|
```
|
|
1428
1572
|
|
|
1429
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1573
|
+
Defined in: [data-structures/base/linear-base.ts:129](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L129)
|
|
1430
1574
|
|
|
1431
1575
|
Last index of a value from the right.
|
|
1432
1576
|
|
|
@@ -1469,7 +1613,7 @@ map<EM, RM>(
|
|
|
1469
1613
|
thisArg?): Deque<EM, RM>;
|
|
1470
1614
|
```
|
|
1471
1615
|
|
|
1472
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
1616
|
+
Defined in: [data-structures/queue/deque.ts:998](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L998)
|
|
1473
1617
|
|
|
1474
1618
|
Map elements into a new deque (possibly different element type).
|
|
1475
1619
|
|
|
@@ -1509,8 +1653,6 @@ Value for `this` inside the callback.
|
|
|
1509
1653
|
|
|
1510
1654
|
A new Deque with mapped elements.
|
|
1511
1655
|
|
|
1512
|
-
*
|
|
1513
|
-
|
|
1514
1656
|
#### Remarks
|
|
1515
1657
|
|
|
1516
1658
|
Time O(N), Space O(N)
|
|
@@ -1536,7 +1678,7 @@ Time O(N), Space O(N)
|
|
|
1536
1678
|
mapSame(callback, thisArg?): this;
|
|
1537
1679
|
```
|
|
1538
1680
|
|
|
1539
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
1681
|
+
Defined in: [data-structures/queue/deque.ts:972](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L972)
|
|
1540
1682
|
|
|
1541
1683
|
Map elements into a new deque of the same element type.
|
|
1542
1684
|
|
|
@@ -1576,7 +1718,7 @@ Time O(N), Space O(N)
|
|
|
1576
1718
|
peek(): E | undefined;
|
|
1577
1719
|
```
|
|
1578
1720
|
|
|
1579
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
1721
|
+
Defined in: [data-structures/queue/deque.ts:320](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L320)
|
|
1580
1722
|
|
|
1581
1723
|
Peek at the front element without removing it (alias for `first`).
|
|
1582
1724
|
|
|
@@ -1598,7 +1740,7 @@ Time O(1), Space O(1)
|
|
|
1598
1740
|
pop(): E | undefined;
|
|
1599
1741
|
```
|
|
1600
1742
|
|
|
1601
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
1743
|
+
Defined in: [data-structures/queue/deque.ts:377](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L377)
|
|
1602
1744
|
|
|
1603
1745
|
Remove and return the last element.
|
|
1604
1746
|
|
|
@@ -1608,8 +1750,6 @@ Remove and return the last element.
|
|
|
1608
1750
|
|
|
1609
1751
|
Removed element or undefined.
|
|
1610
1752
|
|
|
1611
|
-
*
|
|
1612
|
-
|
|
1613
1753
|
#### Remarks
|
|
1614
1754
|
|
|
1615
1755
|
Time O(1), Space O(1)
|
|
@@ -1631,7 +1771,7 @@ Time O(1), Space O(1)
|
|
|
1631
1771
|
print(): void;
|
|
1632
1772
|
```
|
|
1633
1773
|
|
|
1634
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1774
|
+
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)
|
|
1635
1775
|
|
|
1636
1776
|
Prints `toVisual()` to the console. Intended for quick debugging.
|
|
1637
1777
|
|
|
@@ -1657,7 +1797,7 @@ Time O(n) due to materialization, Space O(n) for the intermediate representation
|
|
|
1657
1797
|
push(element): boolean;
|
|
1658
1798
|
```
|
|
1659
1799
|
|
|
1660
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
1800
|
+
Defined in: [data-structures/queue/deque.ts:348](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L348)
|
|
1661
1801
|
|
|
1662
1802
|
Append one element at the back.
|
|
1663
1803
|
|
|
@@ -1675,8 +1815,6 @@ Element to append.
|
|
|
1675
1815
|
|
|
1676
1816
|
True when appended.
|
|
1677
1817
|
|
|
1678
|
-
*
|
|
1679
|
-
|
|
1680
1818
|
#### Remarks
|
|
1681
1819
|
|
|
1682
1820
|
Time O(1) amortized, Space O(1)
|
|
@@ -1715,7 +1853,7 @@ Time O(1) amortized, Space O(1)
|
|
|
1715
1853
|
pushMany(elements): boolean[];
|
|
1716
1854
|
```
|
|
1717
1855
|
|
|
1718
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
1856
|
+
Defined in: [data-structures/queue/deque.ts:471](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L471)
|
|
1719
1857
|
|
|
1720
1858
|
Append a sequence of elements.
|
|
1721
1859
|
|
|
@@ -1781,7 +1919,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
|
|
|
1781
1919
|
reduce(callbackfn): E;
|
|
1782
1920
|
```
|
|
1783
1921
|
|
|
1784
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1922
|
+
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)
|
|
1785
1923
|
|
|
1786
1924
|
##### Parameters
|
|
1787
1925
|
|
|
@@ -1803,7 +1941,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
|
|
|
1803
1941
|
reduce(callbackfn, initialValue): E;
|
|
1804
1942
|
```
|
|
1805
1943
|
|
|
1806
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1944
|
+
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)
|
|
1807
1945
|
|
|
1808
1946
|
##### Parameters
|
|
1809
1947
|
|
|
@@ -1829,7 +1967,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
|
|
|
1829
1967
|
reduce<U>(callbackfn, initialValue): U;
|
|
1830
1968
|
```
|
|
1831
1969
|
|
|
1832
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1970
|
+
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)
|
|
1833
1971
|
|
|
1834
1972
|
##### Type Parameters
|
|
1835
1973
|
|
|
@@ -1863,7 +2001,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.c
|
|
|
1863
2001
|
reduceRight<U>(callbackfn, initialValue): U;
|
|
1864
2002
|
```
|
|
1865
2003
|
|
|
1866
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
2004
|
+
Defined in: [data-structures/base/linear-base.ts:245](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L245)
|
|
1867
2005
|
|
|
1868
2006
|
Right-to-left reduction over elements.
|
|
1869
2007
|
|
|
@@ -1909,22 +2047,14 @@ Time O(n), Space O(1)
|
|
|
1909
2047
|
reverse(): this;
|
|
1910
2048
|
```
|
|
1911
2049
|
|
|
1912
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2050
|
+
Defined in: [data-structures/queue/deque.ts:843](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L843)
|
|
1913
2051
|
|
|
1914
|
-
|
|
2052
|
+
Deque for...of iteration and reverse
|
|
1915
2053
|
|
|
1916
2054
|
#### Returns
|
|
1917
2055
|
|
|
1918
2056
|
`this`
|
|
1919
2057
|
|
|
1920
|
-
This deque.
|
|
1921
|
-
|
|
1922
|
-
*
|
|
1923
|
-
|
|
1924
|
-
#### Remarks
|
|
1925
|
-
|
|
1926
|
-
Time O(N), Space O(N)
|
|
1927
|
-
|
|
1928
2058
|
#### Example
|
|
1929
2059
|
|
|
1930
2060
|
```ts
|
|
@@ -1959,7 +2089,7 @@ Time O(N), Space O(N)
|
|
|
1959
2089
|
setAt(pos, element): boolean;
|
|
1960
2090
|
```
|
|
1961
2091
|
|
|
1962
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2092
|
+
Defined in: [data-structures/queue/deque.ts:555](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L555)
|
|
1963
2093
|
|
|
1964
2094
|
Replace the element at a given position.
|
|
1965
2095
|
|
|
@@ -1999,7 +2129,7 @@ Time O(1), Space O(1)
|
|
|
1999
2129
|
setEquality(equals): this;
|
|
2000
2130
|
```
|
|
2001
2131
|
|
|
2002
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2132
|
+
Defined in: [data-structures/queue/deque.ts:757](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L757)
|
|
2003
2133
|
|
|
2004
2134
|
Set the equality comparator used by delete operations.
|
|
2005
2135
|
|
|
@@ -2029,7 +2159,7 @@ Time O(1), Space O(1)
|
|
|
2029
2159
|
shift(): E | undefined;
|
|
2030
2160
|
```
|
|
2031
2161
|
|
|
2032
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2162
|
+
Defined in: [data-structures/queue/deque.ts:406](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L406)
|
|
2033
2163
|
|
|
2034
2164
|
Remove and return the first element.
|
|
2035
2165
|
|
|
@@ -2039,8 +2169,6 @@ Remove and return the first element.
|
|
|
2039
2169
|
|
|
2040
2170
|
Removed element or undefined.
|
|
2041
2171
|
|
|
2042
|
-
*
|
|
2043
|
-
|
|
2044
2172
|
#### Remarks
|
|
2045
2173
|
|
|
2046
2174
|
Time O(1) amortized, Space O(1)
|
|
@@ -2062,7 +2190,7 @@ Time O(1) amortized, Space O(1)
|
|
|
2062
2190
|
slice(start?, end?): this;
|
|
2063
2191
|
```
|
|
2064
2192
|
|
|
2065
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
2193
|
+
Defined in: [data-structures/base/linear-base.ts:261](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L261)
|
|
2066
2194
|
|
|
2067
2195
|
Create a shallow copy of a subrange.
|
|
2068
2196
|
|
|
@@ -2142,7 +2270,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
|
|
|
2142
2270
|
sort(compareFn?): this;
|
|
2143
2271
|
```
|
|
2144
2272
|
|
|
2145
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
2273
|
+
Defined in: [data-structures/base/linear-base.ts:179](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L179)
|
|
2146
2274
|
|
|
2147
2275
|
In-place stable order via array sort semantics.
|
|
2148
2276
|
|
|
@@ -2179,7 +2307,7 @@ splice(
|
|
|
2179
2307
|
items?): this;
|
|
2180
2308
|
```
|
|
2181
2309
|
|
|
2182
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2310
|
+
Defined in: [data-structures/queue/deque.ts:627](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L627)
|
|
2183
2311
|
|
|
2184
2312
|
Remove and/or insert elements at a position (array-like behavior).
|
|
2185
2313
|
|
|
@@ -2225,7 +2353,7 @@ Time O(N + M), Space O(M)
|
|
|
2225
2353
|
toArray(): E[];
|
|
2226
2354
|
```
|
|
2227
2355
|
|
|
2228
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
2356
|
+
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)
|
|
2229
2357
|
|
|
2230
2358
|
Materializes the elements into a new array.
|
|
2231
2359
|
|
|
@@ -2245,13 +2373,39 @@ Time O(n), Space O(n).
|
|
|
2245
2373
|
|
|
2246
2374
|
***
|
|
2247
2375
|
|
|
2376
|
+
### toReversed()
|
|
2377
|
+
|
|
2378
|
+
```ts
|
|
2379
|
+
toReversed(): this;
|
|
2380
|
+
```
|
|
2381
|
+
|
|
2382
|
+
Defined in: [data-structures/base/linear-base.ts:319](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L319)
|
|
2383
|
+
|
|
2384
|
+
Return a new instance of the same type with elements in reverse order (non-mutating).
|
|
2385
|
+
|
|
2386
|
+
#### Returns
|
|
2387
|
+
|
|
2388
|
+
`this`
|
|
2389
|
+
|
|
2390
|
+
A new reversed instance.
|
|
2391
|
+
|
|
2392
|
+
#### Remarks
|
|
2393
|
+
|
|
2394
|
+
Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
|
|
2395
|
+
|
|
2396
|
+
#### Inherited from
|
|
2397
|
+
|
|
2398
|
+
[`LinearBase`](LinearBase.md).[`toReversed`](LinearBase.md#toreversed)
|
|
2399
|
+
|
|
2400
|
+
***
|
|
2401
|
+
|
|
2248
2402
|
### toReversedArray()
|
|
2249
2403
|
|
|
2250
2404
|
```ts
|
|
2251
2405
|
toReversedArray(): E[];
|
|
2252
2406
|
```
|
|
2253
2407
|
|
|
2254
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
2408
|
+
Defined in: [data-structures/base/linear-base.ts:227](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L227)
|
|
2255
2409
|
|
|
2256
2410
|
Snapshot elements into a reversed array.
|
|
2257
2411
|
|
|
@@ -2277,7 +2431,7 @@ Time O(n), Space O(n)
|
|
|
2277
2431
|
toVisual(): E[];
|
|
2278
2432
|
```
|
|
2279
2433
|
|
|
2280
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
2434
|
+
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)
|
|
2281
2435
|
|
|
2282
2436
|
Returns a representation of the structure suitable for quick visualization.
|
|
2283
2437
|
Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
@@ -2304,7 +2458,7 @@ Time O(n), Space O(n).
|
|
|
2304
2458
|
unique(): this;
|
|
2305
2459
|
```
|
|
2306
2460
|
|
|
2307
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2461
|
+
Defined in: [data-structures/queue/deque.ts:860](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L860)
|
|
2308
2462
|
|
|
2309
2463
|
Deduplicate consecutive equal elements in-place.
|
|
2310
2464
|
|
|
@@ -2326,7 +2480,7 @@ Time O(N), Space O(1)
|
|
|
2326
2480
|
unshift(element): boolean;
|
|
2327
2481
|
```
|
|
2328
2482
|
|
|
2329
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2483
|
+
Defined in: [data-structures/queue/deque.ts:446](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L446)
|
|
2330
2484
|
|
|
2331
2485
|
Prepend one element at the front.
|
|
2332
2486
|
|
|
@@ -2344,8 +2498,6 @@ Element to prepend.
|
|
|
2344
2498
|
|
|
2345
2499
|
True when prepended.
|
|
2346
2500
|
|
|
2347
|
-
*
|
|
2348
|
-
|
|
2349
2501
|
#### Remarks
|
|
2350
2502
|
|
|
2351
2503
|
Time O(1) amortized, Space O(1)
|
|
@@ -2377,7 +2529,7 @@ Time O(1) amortized, Space O(1)
|
|
|
2377
2529
|
unshiftMany(elements?): boolean[];
|
|
2378
2530
|
```
|
|
2379
2531
|
|
|
2380
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2532
|
+
Defined in: [data-structures/queue/deque.ts:489](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L489)
|
|
2381
2533
|
|
|
2382
2534
|
Prepend a sequence of elements.
|
|
2383
2535
|
|
|
@@ -2436,7 +2588,7 @@ static fromArray<E, R>(
|
|
|
2436
2588
|
options?): any;
|
|
2437
2589
|
```
|
|
2438
2590
|
|
|
2439
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2591
|
+
Defined in: [data-structures/queue/deque.ts:285](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L285)
|
|
2440
2592
|
|
|
2441
2593
|
Create a Deque from an array of elements.
|
|
2442
2594
|
|
|
@@ -2491,7 +2643,7 @@ Time O(N), Space O(N)
|
|
|
2491
2643
|
protected _compactCounter: number = 0;
|
|
2492
2644
|
```
|
|
2493
2645
|
|
|
2494
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2646
|
+
Defined in: [data-structures/queue/deque.ts:89](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L89)
|
|
2495
2647
|
|
|
2496
2648
|
Counter for shift/pop operations since last compaction check.
|
|
2497
2649
|
Only checks ratio every `_bucketSize` operations to minimize overhead.
|
|
@@ -2534,7 +2686,7 @@ Time O(1), Space O(1).
|
|
|
2534
2686
|
protected _autoCompact(): void;
|
|
2535
2687
|
```
|
|
2536
2688
|
|
|
2537
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2689
|
+
Defined in: [data-structures/queue/deque.ts:1029](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1029)
|
|
2538
2690
|
|
|
2539
2691
|
(Protected) Trigger auto-compaction if space utilization drops below threshold.
|
|
2540
2692
|
Only checks every `_bucketSize` operations to minimize hot-path overhead.
|
|
@@ -2552,7 +2704,7 @@ Uses element-based ratio: `elements / (bucketCount * bucketSize)`.
|
|
|
2552
2704
|
protected _createInstance(options?): this;
|
|
2553
2705
|
```
|
|
2554
2706
|
|
|
2555
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2707
|
+
Defined in: [data-structures/queue/deque.ts:1126](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1126)
|
|
2556
2708
|
|
|
2557
2709
|
(Protected) Create an empty instance of the same concrete class.
|
|
2558
2710
|
|
|
@@ -2586,7 +2738,7 @@ Time O(1), Space O(1)
|
|
|
2586
2738
|
protected _createLike<T, RR>(elements?, options?): Deque<T, RR>;
|
|
2587
2739
|
```
|
|
2588
2740
|
|
|
2589
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2741
|
+
Defined in: [data-structures/queue/deque.ts:1143](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1143)
|
|
2590
2742
|
|
|
2591
2743
|
(Protected) Create a like-kind deque seeded by elements.
|
|
2592
2744
|
|
|
@@ -2632,7 +2784,7 @@ Time O(N), Space O(N)
|
|
|
2632
2784
|
protected _getBucketAndPosition(pos): object;
|
|
2633
2785
|
```
|
|
2634
2786
|
|
|
2635
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2787
|
+
Defined in: [data-structures/queue/deque.ts:1105](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1105)
|
|
2636
2788
|
|
|
2637
2789
|
(Protected) Translate a logical position to bucket/offset.
|
|
2638
2790
|
|
|
@@ -2674,7 +2826,7 @@ Time O(1), Space O(1)
|
|
|
2674
2826
|
protected _getIterator(): IterableIterator<E>;
|
|
2675
2827
|
```
|
|
2676
2828
|
|
|
2677
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2829
|
+
Defined in: [data-structures/queue/deque.ts:1064](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1064)
|
|
2678
2830
|
|
|
2679
2831
|
(Protected) Iterate elements from front to back.
|
|
2680
2832
|
|
|
@@ -2700,7 +2852,7 @@ Time O(N), Space O(1)
|
|
|
2700
2852
|
protected _getReverseIterator(): IterableIterator<E>;
|
|
2701
2853
|
```
|
|
2702
2854
|
|
|
2703
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2855
|
+
Defined in: [data-structures/queue/deque.ts:1159](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1159)
|
|
2704
2856
|
|
|
2705
2857
|
(Protected) Iterate elements from back to front.
|
|
2706
2858
|
|
|
@@ -2726,7 +2878,7 @@ Time O(N), Space O(1)
|
|
|
2726
2878
|
protected _reallocate(needBucketNum?): void;
|
|
2727
2879
|
```
|
|
2728
2880
|
|
|
2729
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2881
|
+
Defined in: [data-structures/queue/deque.ts:1077](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1077)
|
|
2730
2882
|
|
|
2731
2883
|
(Protected) Reallocate buckets to make room near the ends.
|
|
2732
2884
|
|
|
@@ -2756,7 +2908,7 @@ Time O(N), Space O(N)
|
|
|
2756
2908
|
protected _setBucketSize(size): void;
|
|
2757
2909
|
```
|
|
2758
2910
|
|
|
2759
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2911
|
+
Defined in: [data-structures/queue/deque.ts:1046](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1046)
|
|
2760
2912
|
|
|
2761
2913
|
(Protected) Set the internal bucket size.
|
|
2762
2914
|
|