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: DoublyLinkedList\<E, R\>
|
|
8
8
|
|
|
9
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
9
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:144](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L144)
|
|
10
10
|
|
|
11
11
|
Doubly linked list with O(1) push/pop/unshift/shift and linear scans.
|
|
12
12
|
|
|
@@ -112,7 +112,7 @@ Caution: Although our linked list classes provide methods such as at, setAt, add
|
|
|
112
112
|
new DoublyLinkedList<E, R>(elements?, options?): DoublyLinkedList<E, R>;
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
115
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:152](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L152)
|
|
116
116
|
|
|
117
117
|
Create a DoublyLinkedList and optionally bulk-insert elements.
|
|
118
118
|
|
|
@@ -158,7 +158,7 @@ LinearLinkedBase<E, R, DoublyLinkedListNode<E>>.constructor
|
|
|
158
158
|
get first(): E | undefined;
|
|
159
159
|
```
|
|
160
160
|
|
|
161
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
161
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:204](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L204)
|
|
162
162
|
|
|
163
163
|
Get the first element value.
|
|
164
164
|
|
|
@@ -182,7 +182,7 @@ First element or undefined.
|
|
|
182
182
|
get head(): DoublyLinkedListNode<E> | undefined;
|
|
183
183
|
```
|
|
184
184
|
|
|
185
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
185
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:173](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L173)
|
|
186
186
|
|
|
187
187
|
Get the head node.
|
|
188
188
|
|
|
@@ -206,7 +206,7 @@ Head node or undefined.
|
|
|
206
206
|
get last(): E | undefined;
|
|
207
207
|
```
|
|
208
208
|
|
|
209
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
209
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:213](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L213)
|
|
210
210
|
|
|
211
211
|
Get the last element value.
|
|
212
212
|
|
|
@@ -230,7 +230,7 @@ Last element or undefined.
|
|
|
230
230
|
get length(): number;
|
|
231
231
|
```
|
|
232
232
|
|
|
233
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
233
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:195](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L195)
|
|
234
234
|
|
|
235
235
|
Get the number of elements.
|
|
236
236
|
|
|
@@ -286,7 +286,7 @@ Maximum allowed length.
|
|
|
286
286
|
get tail(): DoublyLinkedListNode<E> | undefined;
|
|
287
287
|
```
|
|
288
288
|
|
|
289
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
289
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:184](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L184)
|
|
290
290
|
|
|
291
291
|
Get the tail node.
|
|
292
292
|
|
|
@@ -370,7 +370,7 @@ Producing the iterator is O(1); consuming the entire iterator is Time O(n) with
|
|
|
370
370
|
addAfter(existingElementOrNode, newElementOrNode): boolean;
|
|
371
371
|
```
|
|
372
372
|
|
|
373
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
373
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:526](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L526)
|
|
374
374
|
|
|
375
375
|
Insert a new element/node after an existing one.
|
|
376
376
|
|
|
@@ -410,7 +410,7 @@ Time O(N), Space O(1)
|
|
|
410
410
|
addAt(index, newElementOrNode): boolean;
|
|
411
411
|
```
|
|
412
412
|
|
|
413
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
413
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:479](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L479)
|
|
414
414
|
|
|
415
415
|
Insert a new element/node at an index, shifting following nodes.
|
|
416
416
|
|
|
@@ -434,8 +434,6 @@ Element or node to insert.
|
|
|
434
434
|
|
|
435
435
|
True if inserted.
|
|
436
436
|
|
|
437
|
-
*
|
|
438
|
-
|
|
439
437
|
#### Remarks
|
|
440
438
|
|
|
441
439
|
Time O(N), Space O(1)
|
|
@@ -461,7 +459,7 @@ Time O(N), Space O(1)
|
|
|
461
459
|
addBefore(existingElementOrNode, newElementOrNode): boolean;
|
|
462
460
|
```
|
|
463
461
|
|
|
464
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
462
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:501](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L501)
|
|
465
463
|
|
|
466
464
|
Insert a new element/node before an existing one.
|
|
467
465
|
|
|
@@ -501,7 +499,7 @@ Time O(N), Space O(1)
|
|
|
501
499
|
at(index): E | undefined;
|
|
502
500
|
```
|
|
503
501
|
|
|
504
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
502
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:409](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L409)
|
|
505
503
|
|
|
506
504
|
Get the element at a given index.
|
|
507
505
|
|
|
@@ -519,8 +517,6 @@ Zero-based index.
|
|
|
519
517
|
|
|
520
518
|
Element or undefined.
|
|
521
519
|
|
|
522
|
-
*
|
|
523
|
-
|
|
524
520
|
#### Remarks
|
|
525
521
|
|
|
526
522
|
Time O(N), Space O(1)
|
|
@@ -546,7 +542,7 @@ Time O(N), Space O(1)
|
|
|
546
542
|
clear(): void;
|
|
547
543
|
```
|
|
548
544
|
|
|
549
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
545
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:627](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L627)
|
|
550
546
|
|
|
551
547
|
Remove all nodes and reset length.
|
|
552
548
|
|
|
@@ -556,8 +552,6 @@ Remove all nodes and reset length.
|
|
|
556
552
|
|
|
557
553
|
void
|
|
558
554
|
|
|
559
|
-
*
|
|
560
|
-
|
|
561
555
|
#### Remarks
|
|
562
556
|
|
|
563
557
|
Time O(N), Space O(1)
|
|
@@ -583,7 +577,7 @@ Time O(N), Space O(1)
|
|
|
583
577
|
clone(): this;
|
|
584
578
|
```
|
|
585
579
|
|
|
586
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
580
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:781](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L781)
|
|
587
581
|
|
|
588
582
|
Deep clone this list (values are copied by reference).
|
|
589
583
|
|
|
@@ -593,8 +587,6 @@ Deep clone this list (values are copied by reference).
|
|
|
593
587
|
|
|
594
588
|
A new list with the same element sequence.
|
|
595
589
|
|
|
596
|
-
*
|
|
597
|
-
|
|
598
590
|
#### Remarks
|
|
599
591
|
|
|
600
592
|
Time O(N), Space O(N)
|
|
@@ -621,7 +613,7 @@ Time O(N), Space O(N)
|
|
|
621
613
|
concat(...items): this;
|
|
622
614
|
```
|
|
623
615
|
|
|
624
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
616
|
+
Defined in: [data-structures/base/linear-base.ts:462](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L462)
|
|
625
617
|
|
|
626
618
|
Concatenate lists/elements preserving order.
|
|
627
619
|
|
|
@@ -657,7 +649,7 @@ Time O(sum(length)), Space O(sum(length))
|
|
|
657
649
|
delete(elementOrNode?): boolean;
|
|
658
650
|
```
|
|
659
651
|
|
|
660
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
652
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:590](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L590)
|
|
661
653
|
|
|
662
654
|
Delete the first match by value/node.
|
|
663
655
|
|
|
@@ -675,8 +667,6 @@ Element or node to remove.
|
|
|
675
667
|
|
|
676
668
|
True if removed.
|
|
677
669
|
|
|
678
|
-
*
|
|
679
|
-
|
|
680
670
|
#### Remarks
|
|
681
671
|
|
|
682
672
|
Time O(N), Space O(1)
|
|
@@ -702,7 +692,7 @@ Time O(N), Space O(1)
|
|
|
702
692
|
deleteAt(index): E | undefined;
|
|
703
693
|
```
|
|
704
694
|
|
|
705
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
695
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:566](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L566)
|
|
706
696
|
|
|
707
697
|
Delete the element at an index.
|
|
708
698
|
|
|
@@ -720,8 +710,6 @@ Zero-based index.
|
|
|
720
710
|
|
|
721
711
|
Removed element or undefined.
|
|
722
712
|
|
|
723
|
-
*
|
|
724
|
-
|
|
725
713
|
#### Remarks
|
|
726
714
|
|
|
727
715
|
Time O(N), Space O(1)
|
|
@@ -747,7 +735,7 @@ Time O(N), Space O(1)
|
|
|
747
735
|
deleteWhere(predicate): boolean;
|
|
748
736
|
```
|
|
749
737
|
|
|
750
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
738
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:745](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L745)
|
|
751
739
|
|
|
752
740
|
Delete the first element that satisfies a predicate.
|
|
753
741
|
|
|
@@ -771,6 +759,30 @@ Time O(N), Space O(1)
|
|
|
771
759
|
|
|
772
760
|
***
|
|
773
761
|
|
|
762
|
+
### entries()
|
|
763
|
+
|
|
764
|
+
```ts
|
|
765
|
+
entries(): IterableIterator<[number, E]>;
|
|
766
|
+
```
|
|
767
|
+
|
|
768
|
+
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)
|
|
769
|
+
|
|
770
|
+
Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
771
|
+
|
|
772
|
+
#### Returns
|
|
773
|
+
|
|
774
|
+
`IterableIterator`\<\[`number`, `E`\]\>
|
|
775
|
+
|
|
776
|
+
#### Remarks
|
|
777
|
+
|
|
778
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
779
|
+
|
|
780
|
+
#### Inherited from
|
|
781
|
+
|
|
782
|
+
[`LinearLinkedBase`](LinearLinkedBase.md).[`entries`](LinearLinkedBase.md#entries)
|
|
783
|
+
|
|
784
|
+
***
|
|
785
|
+
|
|
774
786
|
### every()
|
|
775
787
|
|
|
776
788
|
```ts
|
|
@@ -820,7 +832,7 @@ fill(
|
|
|
820
832
|
end?): this;
|
|
821
833
|
```
|
|
822
834
|
|
|
823
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
835
|
+
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)
|
|
824
836
|
|
|
825
837
|
Fill a range with a value.
|
|
826
838
|
|
|
@@ -866,7 +878,7 @@ Time O(n), Space O(1)
|
|
|
866
878
|
filter(callback, thisArg?): this;
|
|
867
879
|
```
|
|
868
880
|
|
|
869
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
881
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:799](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L799)
|
|
870
882
|
|
|
871
883
|
Filter values into a new list of the same class.
|
|
872
884
|
|
|
@@ -890,8 +902,6 @@ Value for `this` inside the callback.
|
|
|
890
902
|
|
|
891
903
|
A new list with kept values.
|
|
892
904
|
|
|
893
|
-
*
|
|
894
|
-
|
|
895
905
|
#### Remarks
|
|
896
906
|
|
|
897
907
|
Time O(N), Space O(N)
|
|
@@ -1007,7 +1017,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
|
1007
1017
|
findIndex(predicate, thisArg?): number;
|
|
1008
1018
|
```
|
|
1009
1019
|
|
|
1010
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1020
|
+
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)
|
|
1011
1021
|
|
|
1012
1022
|
Find the first index matching a predicate.
|
|
1013
1023
|
|
|
@@ -1041,6 +1051,78 @@ Time O(n), Space O(1)
|
|
|
1041
1051
|
|
|
1042
1052
|
***
|
|
1043
1053
|
|
|
1054
|
+
### findLast()
|
|
1055
|
+
|
|
1056
|
+
```ts
|
|
1057
|
+
findLast(elementNodeOrPredicate): E | undefined;
|
|
1058
|
+
```
|
|
1059
|
+
|
|
1060
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:689](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L689)
|
|
1061
|
+
|
|
1062
|
+
Find the first value matching a predicate scanning backward (tail → head).
|
|
1063
|
+
|
|
1064
|
+
#### Parameters
|
|
1065
|
+
|
|
1066
|
+
##### elementNodeOrPredicate
|
|
1067
|
+
|
|
1068
|
+
\| `E`
|
|
1069
|
+
\| [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>
|
|
1070
|
+
\| ((`node`) => `boolean`)
|
|
1071
|
+
|
|
1072
|
+
Element, node, or predicate to match.
|
|
1073
|
+
|
|
1074
|
+
#### Returns
|
|
1075
|
+
|
|
1076
|
+
`E` \| `undefined`
|
|
1077
|
+
|
|
1078
|
+
Matching value or undefined.
|
|
1079
|
+
|
|
1080
|
+
#### Remarks
|
|
1081
|
+
|
|
1082
|
+
Time O(N), Space O(1)
|
|
1083
|
+
|
|
1084
|
+
#### Example
|
|
1085
|
+
|
|
1086
|
+
```ts
|
|
1087
|
+
// Find value scanning from tail
|
|
1088
|
+
const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
|
|
1089
|
+
// findLast scans from tail to head, returns first match
|
|
1090
|
+
const found = list.findLast(node => node.value < 4);
|
|
1091
|
+
console.log(found); // 3;
|
|
1092
|
+
```
|
|
1093
|
+
|
|
1094
|
+
***
|
|
1095
|
+
|
|
1096
|
+
### findLastIndex()
|
|
1097
|
+
|
|
1098
|
+
```ts
|
|
1099
|
+
findLastIndex(predicate): number;
|
|
1100
|
+
```
|
|
1101
|
+
|
|
1102
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:707](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L707)
|
|
1103
|
+
|
|
1104
|
+
Find the index of the last value matching a predicate (scans tail → head).
|
|
1105
|
+
|
|
1106
|
+
#### Parameters
|
|
1107
|
+
|
|
1108
|
+
##### predicate
|
|
1109
|
+
|
|
1110
|
+
(`value`, `index`, `list`) => `boolean`
|
|
1111
|
+
|
|
1112
|
+
Function called with (value, index, list).
|
|
1113
|
+
|
|
1114
|
+
#### Returns
|
|
1115
|
+
|
|
1116
|
+
`number`
|
|
1117
|
+
|
|
1118
|
+
Matching index, or -1 if not found.
|
|
1119
|
+
|
|
1120
|
+
#### Remarks
|
|
1121
|
+
|
|
1122
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
1123
|
+
|
|
1124
|
+
***
|
|
1125
|
+
|
|
1044
1126
|
### forEach()
|
|
1045
1127
|
|
|
1046
1128
|
```ts
|
|
@@ -1081,15 +1163,13 @@ Time O(n), Space O(1).
|
|
|
1081
1163
|
|
|
1082
1164
|
***
|
|
1083
1165
|
|
|
1084
|
-
### getBackward()
|
|
1166
|
+
### ~~getBackward()~~
|
|
1085
1167
|
|
|
1086
1168
|
```ts
|
|
1087
1169
|
getBackward(elementNodeOrPredicate): E | undefined;
|
|
1088
1170
|
```
|
|
1089
1171
|
|
|
1090
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
1091
|
-
|
|
1092
|
-
Find the first value matching a predicate scanning backward.
|
|
1172
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:671](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L671)
|
|
1093
1173
|
|
|
1094
1174
|
#### Parameters
|
|
1095
1175
|
|
|
@@ -1099,29 +1179,13 @@ Find the first value matching a predicate scanning backward.
|
|
|
1099
1179
|
\| [`DoublyLinkedListNode`](DoublyLinkedListNode.md)\<`E`\>
|
|
1100
1180
|
\| ((`node`) => `boolean`)
|
|
1101
1181
|
|
|
1102
|
-
Element, node, or predicate to match.
|
|
1103
|
-
|
|
1104
1182
|
#### Returns
|
|
1105
1183
|
|
|
1106
1184
|
`E` \| `undefined`
|
|
1107
1185
|
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
*
|
|
1111
|
-
|
|
1112
|
-
#### Remarks
|
|
1186
|
+
#### Deprecated
|
|
1113
1187
|
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
#### Example
|
|
1117
|
-
|
|
1118
|
-
```ts
|
|
1119
|
-
// Find value scanning from tail
|
|
1120
|
-
const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
|
|
1121
|
-
// getBackward scans from tail to head, returns first match
|
|
1122
|
-
const found = list.getBackward(node => node.value < 4);
|
|
1123
|
-
console.log(found); // 3;
|
|
1124
|
-
```
|
|
1188
|
+
Use `findLast` instead. Will be removed in a future major version.
|
|
1125
1189
|
|
|
1126
1190
|
***
|
|
1127
1191
|
|
|
@@ -1131,7 +1195,7 @@ Time O(N), Space O(1)
|
|
|
1131
1195
|
getNode(elementNodeOrPredicate?): DoublyLinkedListNode<E> | undefined;
|
|
1132
1196
|
```
|
|
1133
1197
|
|
|
1134
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
1198
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:439](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L439)
|
|
1135
1199
|
|
|
1136
1200
|
Find a node by value, reference, or predicate.
|
|
1137
1201
|
|
|
@@ -1163,7 +1227,7 @@ Time O(N), Space O(1)
|
|
|
1163
1227
|
getNodeAt(index): DoublyLinkedListNode<E> | undefined;
|
|
1164
1228
|
```
|
|
1165
1229
|
|
|
1166
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
1230
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:426](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L426)
|
|
1167
1231
|
|
|
1168
1232
|
Get the node reference at a given index.
|
|
1169
1233
|
|
|
@@ -1181,8 +1245,6 @@ Zero-based index.
|
|
|
1181
1245
|
|
|
1182
1246
|
Node or undefined.
|
|
1183
1247
|
|
|
1184
|
-
*
|
|
1185
|
-
|
|
1186
1248
|
#### Remarks
|
|
1187
1249
|
|
|
1188
1250
|
Time O(N), Space O(1)
|
|
@@ -1207,7 +1269,7 @@ Time O(N), Space O(1)
|
|
|
1207
1269
|
has(element): boolean;
|
|
1208
1270
|
```
|
|
1209
1271
|
|
|
1210
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1272
|
+
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)
|
|
1211
1273
|
|
|
1212
1274
|
Checks whether a strictly-equal element exists in the structure.
|
|
1213
1275
|
|
|
@@ -1235,13 +1297,47 @@ Time O(n) in the worst case. Space O(1).
|
|
|
1235
1297
|
|
|
1236
1298
|
***
|
|
1237
1299
|
|
|
1300
|
+
### includes()
|
|
1301
|
+
|
|
1302
|
+
```ts
|
|
1303
|
+
includes(element): boolean;
|
|
1304
|
+
```
|
|
1305
|
+
|
|
1306
|
+
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)
|
|
1307
|
+
|
|
1308
|
+
Check whether a value exists (Array-compatible alias for `has`).
|
|
1309
|
+
|
|
1310
|
+
#### Parameters
|
|
1311
|
+
|
|
1312
|
+
##### element
|
|
1313
|
+
|
|
1314
|
+
`E`
|
|
1315
|
+
|
|
1316
|
+
Element to search for (uses `===`).
|
|
1317
|
+
|
|
1318
|
+
#### Returns
|
|
1319
|
+
|
|
1320
|
+
`boolean`
|
|
1321
|
+
|
|
1322
|
+
`true` if found.
|
|
1323
|
+
|
|
1324
|
+
#### Remarks
|
|
1325
|
+
|
|
1326
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
1327
|
+
|
|
1328
|
+
#### Inherited from
|
|
1329
|
+
|
|
1330
|
+
[`LinearLinkedBase`](LinearLinkedBase.md).[`includes`](LinearLinkedBase.md#includes)
|
|
1331
|
+
|
|
1332
|
+
***
|
|
1333
|
+
|
|
1238
1334
|
### indexOf()
|
|
1239
1335
|
|
|
1240
1336
|
```ts
|
|
1241
1337
|
indexOf(searchElement, fromIndex?): number;
|
|
1242
1338
|
```
|
|
1243
1339
|
|
|
1244
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1340
|
+
Defined in: [data-structures/base/linear-base.ts:417](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L417)
|
|
1245
1341
|
|
|
1246
1342
|
Linked-list optimized `indexOf` (forwards scan).
|
|
1247
1343
|
|
|
@@ -1281,7 +1377,7 @@ Time O(n), Space O(1)
|
|
|
1281
1377
|
isEmpty(): boolean;
|
|
1282
1378
|
```
|
|
1283
1379
|
|
|
1284
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
1380
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:613](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L613)
|
|
1285
1381
|
|
|
1286
1382
|
Check whether the list is empty.
|
|
1287
1383
|
|
|
@@ -1291,8 +1387,6 @@ Check whether the list is empty.
|
|
|
1291
1387
|
|
|
1292
1388
|
True if length is 0.
|
|
1293
1389
|
|
|
1294
|
-
*
|
|
1295
|
-
|
|
1296
1390
|
#### Remarks
|
|
1297
1391
|
|
|
1298
1392
|
Time O(1), Space O(1)
|
|
@@ -1316,7 +1410,7 @@ Time O(1), Space O(1)
|
|
|
1316
1410
|
isNode(elementNodeOrPredicate): elementNodeOrPredicate is DoublyLinkedListNode<E>;
|
|
1317
1411
|
```
|
|
1318
1412
|
|
|
1319
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
1413
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:242](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L242)
|
|
1320
1414
|
|
|
1321
1415
|
Type guard: check whether the input is a DoublyLinkedListNode.
|
|
1322
1416
|
|
|
@@ -1348,7 +1442,7 @@ Time O(1), Space O(1)
|
|
|
1348
1442
|
join(separator?): string;
|
|
1349
1443
|
```
|
|
1350
1444
|
|
|
1351
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1445
|
+
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)
|
|
1352
1446
|
|
|
1353
1447
|
Join all elements into a string.
|
|
1354
1448
|
|
|
@@ -1376,13 +1470,37 @@ Time O(n), Space O(n)
|
|
|
1376
1470
|
|
|
1377
1471
|
***
|
|
1378
1472
|
|
|
1473
|
+
### keys()
|
|
1474
|
+
|
|
1475
|
+
```ts
|
|
1476
|
+
keys(): IterableIterator<number>;
|
|
1477
|
+
```
|
|
1478
|
+
|
|
1479
|
+
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)
|
|
1480
|
+
|
|
1481
|
+
Return an iterator of numeric indices (Array-compatible).
|
|
1482
|
+
|
|
1483
|
+
#### Returns
|
|
1484
|
+
|
|
1485
|
+
`IterableIterator`\<`number`\>
|
|
1486
|
+
|
|
1487
|
+
#### Remarks
|
|
1488
|
+
|
|
1489
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
1490
|
+
|
|
1491
|
+
#### Inherited from
|
|
1492
|
+
|
|
1493
|
+
[`LinearLinkedBase`](LinearLinkedBase.md).[`keys`](LinearLinkedBase.md#keys)
|
|
1494
|
+
|
|
1495
|
+
***
|
|
1496
|
+
|
|
1379
1497
|
### lastIndexOf()
|
|
1380
1498
|
|
|
1381
1499
|
```ts
|
|
1382
1500
|
lastIndexOf(searchElement, fromIndex?): number;
|
|
1383
1501
|
```
|
|
1384
1502
|
|
|
1385
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1503
|
+
Defined in: [data-structures/base/linear-base.ts:440](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L440)
|
|
1386
1504
|
|
|
1387
1505
|
Linked-list optimized `lastIndexOf` (reverse scan).
|
|
1388
1506
|
|
|
@@ -1425,7 +1543,7 @@ map<EM, RM>(
|
|
|
1425
1543
|
thisArg?): DoublyLinkedList<EM, RM>;
|
|
1426
1544
|
```
|
|
1427
1545
|
|
|
1428
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
1546
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:847](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L847)
|
|
1429
1547
|
|
|
1430
1548
|
Map values into a new list (possibly different element type).
|
|
1431
1549
|
|
|
@@ -1465,8 +1583,6 @@ Value for `this` inside the callback.
|
|
|
1465
1583
|
|
|
1466
1584
|
A new DoublyLinkedList with mapped values.
|
|
1467
1585
|
|
|
1468
|
-
*
|
|
1469
|
-
|
|
1470
1586
|
#### Remarks
|
|
1471
1587
|
|
|
1472
1588
|
Time O(N), Space O(N)
|
|
@@ -1501,7 +1617,7 @@ Time O(N), Space O(N)
|
|
|
1501
1617
|
mapSame(callback, thisArg?): this;
|
|
1502
1618
|
```
|
|
1503
1619
|
|
|
1504
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
1620
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:813](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L813)
|
|
1505
1621
|
|
|
1506
1622
|
Map values into a new list of the same class.
|
|
1507
1623
|
|
|
@@ -1541,7 +1657,7 @@ Time O(N), Space O(N)
|
|
|
1541
1657
|
pop(): E | undefined;
|
|
1542
1658
|
```
|
|
1543
1659
|
|
|
1544
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
1660
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:304](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L304)
|
|
1545
1661
|
|
|
1546
1662
|
Remove and return the tail element.
|
|
1547
1663
|
|
|
@@ -1551,8 +1667,6 @@ Remove and return the tail element.
|
|
|
1551
1667
|
|
|
1552
1668
|
Removed element or undefined.
|
|
1553
1669
|
|
|
1554
|
-
*
|
|
1555
|
-
|
|
1556
1670
|
#### Remarks
|
|
1557
1671
|
|
|
1558
1672
|
Time O(1), Space O(1)
|
|
@@ -1584,7 +1698,7 @@ Time O(1), Space O(1)
|
|
|
1584
1698
|
print(): void;
|
|
1585
1699
|
```
|
|
1586
1700
|
|
|
1587
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1701
|
+
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)
|
|
1588
1702
|
|
|
1589
1703
|
Prints `toVisual()` to the console. Intended for quick debugging.
|
|
1590
1704
|
|
|
@@ -1610,7 +1724,7 @@ Time O(n) due to materialization, Space O(n) for the intermediate representation
|
|
|
1610
1724
|
push(elementOrNode): boolean;
|
|
1611
1725
|
```
|
|
1612
1726
|
|
|
1613
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
1727
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:269](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L269)
|
|
1614
1728
|
|
|
1615
1729
|
Append an element/node to the tail.
|
|
1616
1730
|
|
|
@@ -1628,8 +1742,6 @@ Element or node to append.
|
|
|
1628
1742
|
|
|
1629
1743
|
True when appended.
|
|
1630
1744
|
|
|
1631
|
-
*
|
|
1632
|
-
|
|
1633
1745
|
#### Remarks
|
|
1634
1746
|
|
|
1635
1747
|
Time O(1), Space O(1)
|
|
@@ -1665,7 +1777,7 @@ Time O(1), Space O(1)
|
|
|
1665
1777
|
pushMany(elements): boolean[];
|
|
1666
1778
|
```
|
|
1667
1779
|
|
|
1668
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
1780
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:374](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L374)
|
|
1669
1781
|
|
|
1670
1782
|
Append a sequence of elements/nodes.
|
|
1671
1783
|
|
|
@@ -1733,7 +1845,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
|
|
|
1733
1845
|
reduce(callbackfn): E;
|
|
1734
1846
|
```
|
|
1735
1847
|
|
|
1736
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1848
|
+
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)
|
|
1737
1849
|
|
|
1738
1850
|
##### Parameters
|
|
1739
1851
|
|
|
@@ -1755,7 +1867,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
|
|
|
1755
1867
|
reduce(callbackfn, initialValue): E;
|
|
1756
1868
|
```
|
|
1757
1869
|
|
|
1758
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1870
|
+
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)
|
|
1759
1871
|
|
|
1760
1872
|
##### Parameters
|
|
1761
1873
|
|
|
@@ -1781,7 +1893,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
|
|
|
1781
1893
|
reduce<U>(callbackfn, initialValue): U;
|
|
1782
1894
|
```
|
|
1783
1895
|
|
|
1784
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1896
|
+
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)
|
|
1785
1897
|
|
|
1786
1898
|
##### Type Parameters
|
|
1787
1899
|
|
|
@@ -1815,7 +1927,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.c
|
|
|
1815
1927
|
reduceRight<U>(callbackfn, initialValue): U;
|
|
1816
1928
|
```
|
|
1817
1929
|
|
|
1818
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1930
|
+
Defined in: [data-structures/base/linear-base.ts:552](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L552)
|
|
1819
1931
|
|
|
1820
1932
|
Right-to-left reduction using reverse iterator.
|
|
1821
1933
|
|
|
@@ -1861,7 +1973,7 @@ Time O(n), Space O(1)
|
|
|
1861
1973
|
reverse(): this;
|
|
1862
1974
|
```
|
|
1863
1975
|
|
|
1864
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
1976
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:728](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L728)
|
|
1865
1977
|
|
|
1866
1978
|
Reverse the list in place.
|
|
1867
1979
|
|
|
@@ -1871,8 +1983,6 @@ Reverse the list in place.
|
|
|
1871
1983
|
|
|
1872
1984
|
This list.
|
|
1873
1985
|
|
|
1874
|
-
*
|
|
1875
|
-
|
|
1876
1986
|
#### Remarks
|
|
1877
1987
|
|
|
1878
1988
|
Time O(N), Space O(1)
|
|
@@ -1898,7 +2008,7 @@ Time O(N), Space O(1)
|
|
|
1898
2008
|
search(elementNodeOrPredicate): E | undefined;
|
|
1899
2009
|
```
|
|
1900
2010
|
|
|
1901
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
2011
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:644](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L644)
|
|
1902
2012
|
|
|
1903
2013
|
Find the first value matching a predicate scanning forward.
|
|
1904
2014
|
|
|
@@ -1918,8 +2028,6 @@ Element, node, or predicate to match.
|
|
|
1918
2028
|
|
|
1919
2029
|
Matched value or undefined.
|
|
1920
2030
|
|
|
1921
|
-
*
|
|
1922
|
-
|
|
1923
2031
|
#### Remarks
|
|
1924
2032
|
|
|
1925
2033
|
Time O(N), Space O(1)
|
|
@@ -1941,7 +2049,7 @@ Time O(N), Space O(1)
|
|
|
1941
2049
|
setAt(index, value): boolean;
|
|
1942
2050
|
```
|
|
1943
2051
|
|
|
1944
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
2052
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:548](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L548)
|
|
1945
2053
|
|
|
1946
2054
|
Set the element value at an index.
|
|
1947
2055
|
|
|
@@ -1981,7 +2089,7 @@ Time O(N), Space O(1)
|
|
|
1981
2089
|
setEquality(equals): this;
|
|
1982
2090
|
```
|
|
1983
2091
|
|
|
1984
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
2092
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:765](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L765)
|
|
1985
2093
|
|
|
1986
2094
|
Set the equality comparator used to compare values.
|
|
1987
2095
|
|
|
@@ -2011,7 +2119,7 @@ Time O(1), Space O(1)
|
|
|
2011
2119
|
shift(): E | undefined;
|
|
2012
2120
|
```
|
|
2013
2121
|
|
|
2014
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
2122
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:328](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L328)
|
|
2015
2123
|
|
|
2016
2124
|
Remove and return the head element.
|
|
2017
2125
|
|
|
@@ -2021,8 +2129,6 @@ Remove and return the head element.
|
|
|
2021
2129
|
|
|
2022
2130
|
Removed element or undefined.
|
|
2023
2131
|
|
|
2024
|
-
*
|
|
2025
|
-
|
|
2026
2132
|
#### Remarks
|
|
2027
2133
|
|
|
2028
2134
|
Time O(1), Space O(1)
|
|
@@ -2044,7 +2150,7 @@ Time O(1), Space O(1)
|
|
|
2044
2150
|
slice(start?, end?): this;
|
|
2045
2151
|
```
|
|
2046
2152
|
|
|
2047
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
2153
|
+
Defined in: [data-structures/base/linear-base.ts:481](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L481)
|
|
2048
2154
|
|
|
2049
2155
|
Slice via forward iteration (no random access required).
|
|
2050
2156
|
|
|
@@ -2124,7 +2230,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
|
|
|
2124
2230
|
sort(compareFn?): this;
|
|
2125
2231
|
```
|
|
2126
2232
|
|
|
2127
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
2233
|
+
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)
|
|
2128
2234
|
|
|
2129
2235
|
In-place stable order via array sort semantics.
|
|
2130
2236
|
|
|
@@ -2161,7 +2267,7 @@ splice(
|
|
|
2161
2267
|
items): this;
|
|
2162
2268
|
```
|
|
2163
2269
|
|
|
2164
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
2270
|
+
Defined in: [data-structures/base/linear-base.ts:507](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L507)
|
|
2165
2271
|
|
|
2166
2272
|
Splice by walking node iterators from the start index.
|
|
2167
2273
|
|
|
@@ -2207,7 +2313,7 @@ Time O(n + m), Space O(min(n, m)) where `m = items.length`
|
|
|
2207
2313
|
toArray(): E[];
|
|
2208
2314
|
```
|
|
2209
2315
|
|
|
2210
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
2316
|
+
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)
|
|
2211
2317
|
|
|
2212
2318
|
Materializes the elements into a new array.
|
|
2213
2319
|
|
|
@@ -2227,13 +2333,39 @@ Time O(n), Space O(n).
|
|
|
2227
2333
|
|
|
2228
2334
|
***
|
|
2229
2335
|
|
|
2336
|
+
### toReversed()
|
|
2337
|
+
|
|
2338
|
+
```ts
|
|
2339
|
+
toReversed(): this;
|
|
2340
|
+
```
|
|
2341
|
+
|
|
2342
|
+
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)
|
|
2343
|
+
|
|
2344
|
+
Return a new instance of the same type with elements in reverse order (non-mutating).
|
|
2345
|
+
|
|
2346
|
+
#### Returns
|
|
2347
|
+
|
|
2348
|
+
`this`
|
|
2349
|
+
|
|
2350
|
+
A new reversed instance.
|
|
2351
|
+
|
|
2352
|
+
#### Remarks
|
|
2353
|
+
|
|
2354
|
+
Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
|
|
2355
|
+
|
|
2356
|
+
#### Inherited from
|
|
2357
|
+
|
|
2358
|
+
[`LinearLinkedBase`](LinearLinkedBase.md).[`toReversed`](LinearLinkedBase.md#toreversed)
|
|
2359
|
+
|
|
2360
|
+
***
|
|
2361
|
+
|
|
2230
2362
|
### toReversedArray()
|
|
2231
2363
|
|
|
2232
2364
|
```ts
|
|
2233
2365
|
toReversedArray(): E[];
|
|
2234
2366
|
```
|
|
2235
2367
|
|
|
2236
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
2368
|
+
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)
|
|
2237
2369
|
|
|
2238
2370
|
Snapshot elements into a reversed array.
|
|
2239
2371
|
|
|
@@ -2259,7 +2391,7 @@ Time O(n), Space O(n)
|
|
|
2259
2391
|
toVisual(): E[];
|
|
2260
2392
|
```
|
|
2261
2393
|
|
|
2262
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
2394
|
+
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)
|
|
2263
2395
|
|
|
2264
2396
|
Returns a representation of the structure suitable for quick visualization.
|
|
2265
2397
|
Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
@@ -2286,7 +2418,7 @@ Time O(n), Space O(n).
|
|
|
2286
2418
|
unshift(elementOrNode): boolean;
|
|
2287
2419
|
```
|
|
2288
2420
|
|
|
2289
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
2421
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:353](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L353)
|
|
2290
2422
|
|
|
2291
2423
|
Prepend an element/node to the head.
|
|
2292
2424
|
|
|
@@ -2304,8 +2436,6 @@ Element or node to prepend.
|
|
|
2304
2436
|
|
|
2305
2437
|
True when prepended.
|
|
2306
2438
|
|
|
2307
|
-
*
|
|
2308
|
-
|
|
2309
2439
|
#### Remarks
|
|
2310
2440
|
|
|
2311
2441
|
Time O(1), Space O(1)
|
|
@@ -2327,7 +2457,7 @@ Time O(1), Space O(1)
|
|
|
2327
2457
|
unshiftMany(elements): boolean[];
|
|
2328
2458
|
```
|
|
2329
2459
|
|
|
2330
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
2460
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:389](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L389)
|
|
2331
2461
|
|
|
2332
2462
|
Prepend a sequence of elements/nodes.
|
|
2333
2463
|
|
|
@@ -2385,7 +2515,7 @@ Creating the iterator is O(1); full iteration is Time O(n), Space O(1).
|
|
|
2385
2515
|
static fromArray<E, R>(this, data): any;
|
|
2386
2516
|
```
|
|
2387
2517
|
|
|
2388
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
2518
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:226](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L226)
|
|
2389
2519
|
|
|
2390
2520
|
Create a new list from an array of elements.
|
|
2391
2521
|
|
|
@@ -2464,7 +2594,7 @@ Time O(1), Space O(1).
|
|
|
2464
2594
|
protected _createInstance(options?): this;
|
|
2465
2595
|
```
|
|
2466
2596
|
|
|
2467
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
2597
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:907](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L907)
|
|
2468
2598
|
|
|
2469
2599
|
(Protected) Create an empty instance of the same concrete class.
|
|
2470
2600
|
|
|
@@ -2498,7 +2628,7 @@ Time O(1), Space O(1)
|
|
|
2498
2628
|
protected _createLike<EM, RM>(elements?, options?): DoublyLinkedList<EM, RM>;
|
|
2499
2629
|
```
|
|
2500
2630
|
|
|
2501
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
2631
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:924](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L924)
|
|
2502
2632
|
|
|
2503
2633
|
(Protected) Create a like-kind instance and seed it from an iterable.
|
|
2504
2634
|
|
|
@@ -2546,7 +2676,7 @@ Time O(N), Space O(N)
|
|
|
2546
2676
|
protected _ensureNode(elementOrNode): DoublyLinkedListNode<E>;
|
|
2547
2677
|
```
|
|
2548
2678
|
|
|
2549
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
2679
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:866](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L866)
|
|
2550
2680
|
|
|
2551
2681
|
(Protected) Create or return a node for the given input (node or raw element).
|
|
2552
2682
|
|
|
@@ -2576,7 +2706,7 @@ Time O(1), Space O(1)
|
|
|
2576
2706
|
protected _ensurePredicate(elementNodeOrPredicate): (node) => boolean;
|
|
2577
2707
|
```
|
|
2578
2708
|
|
|
2579
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
2709
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:877](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L877)
|
|
2580
2710
|
|
|
2581
2711
|
(Protected) Normalize input into a predicate over nodes.
|
|
2582
2712
|
|
|
@@ -2608,7 +2738,7 @@ Time O(1), Space O(1)
|
|
|
2608
2738
|
protected _getIterator(): IterableIterator<E>;
|
|
2609
2739
|
```
|
|
2610
2740
|
|
|
2611
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
2741
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:935](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L935)
|
|
2612
2742
|
|
|
2613
2743
|
Internal iterator factory used by the default iterator.
|
|
2614
2744
|
|
|
@@ -2634,7 +2764,7 @@ Implementations should yield in O(1) per element with O(1) extra space when poss
|
|
|
2634
2764
|
protected _getNodeIterator(): IterableIterator<DoublyLinkedListNode<E>>;
|
|
2635
2765
|
```
|
|
2636
2766
|
|
|
2637
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
2767
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:951](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L951)
|
|
2638
2768
|
|
|
2639
2769
|
Iterate linked nodes from head to tail.
|
|
2640
2770
|
|
|
@@ -2660,7 +2790,7 @@ Time O(n), Space O(1)
|
|
|
2660
2790
|
protected _getPrevNode(node): DoublyLinkedListNode<E> | undefined;
|
|
2661
2791
|
```
|
|
2662
2792
|
|
|
2663
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
2793
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:897](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L897)
|
|
2664
2794
|
|
|
2665
2795
|
(Protected) Get the previous node of a given node.
|
|
2666
2796
|
|
|
@@ -2694,7 +2824,7 @@ Time O(1), Space O(1)
|
|
|
2694
2824
|
protected _getReverseIterator(): IterableIterator<E>;
|
|
2695
2825
|
```
|
|
2696
2826
|
|
|
2697
|
-
Defined in: [data-structures/linked-list/doubly-linked-list.ts:
|
|
2827
|
+
Defined in: [data-structures/linked-list/doubly-linked-list.ts:943](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/doubly-linked-list.ts#L943)
|
|
2698
2828
|
|
|
2699
2829
|
Reverse-direction iterator over elements.
|
|
2700
2830
|
|