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: LinkedListQueue\<E, R\>
|
|
8
8
|
|
|
9
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
9
|
+
Defined in: [data-structures/queue/queue.ts:624](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L624)
|
|
10
10
|
|
|
11
11
|
Queue implemented over a singly linked list; preserves head/tail operations with linear scans for queries.
|
|
12
12
|
|
|
@@ -42,7 +42,7 @@ examples will be generated by unit test
|
|
|
42
42
|
new LinkedListQueue<E, R>(elements?, options?): LinkedListQueue<E, R>;
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
45
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:198](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L198)
|
|
46
46
|
|
|
47
47
|
Create a SinglyLinkedList and optionally bulk-insert elements.
|
|
48
48
|
|
|
@@ -86,7 +86,7 @@ Time O(N), Space O(N)
|
|
|
86
86
|
get first(): E | undefined;
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
89
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:244](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L244)
|
|
90
90
|
|
|
91
91
|
Get the first element value.
|
|
92
92
|
|
|
@@ -114,7 +114,7 @@ First element or undefined.
|
|
|
114
114
|
get head(): SinglyLinkedListNode<E> | undefined;
|
|
115
115
|
```
|
|
116
116
|
|
|
117
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
117
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:213](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L213)
|
|
118
118
|
|
|
119
119
|
Get the head node.
|
|
120
120
|
|
|
@@ -142,7 +142,7 @@ Head node or undefined.
|
|
|
142
142
|
get last(): E | undefined;
|
|
143
143
|
```
|
|
144
144
|
|
|
145
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
145
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:253](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L253)
|
|
146
146
|
|
|
147
147
|
Get the last element value.
|
|
148
148
|
|
|
@@ -170,7 +170,7 @@ Last element or undefined.
|
|
|
170
170
|
get length(): number;
|
|
171
171
|
```
|
|
172
172
|
|
|
173
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
173
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:235](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L235)
|
|
174
174
|
|
|
175
175
|
Get the number of elements.
|
|
176
176
|
|
|
@@ -226,7 +226,7 @@ Maximum allowed length.
|
|
|
226
226
|
get tail(): SinglyLinkedListNode<E> | undefined;
|
|
227
227
|
```
|
|
228
228
|
|
|
229
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
229
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:224](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L224)
|
|
230
230
|
|
|
231
231
|
Get the tail node.
|
|
232
232
|
|
|
@@ -314,7 +314,7 @@ Producing the iterator is O(1); consuming the entire iterator is Time O(n) with
|
|
|
314
314
|
addAfter(existingElementOrNode, newElementOrNode): boolean;
|
|
315
315
|
```
|
|
316
316
|
|
|
317
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
317
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:702](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L702)
|
|
318
318
|
|
|
319
319
|
Insert a new element/node after an existing one.
|
|
320
320
|
|
|
@@ -354,7 +354,7 @@ Time O(N), Space O(1)
|
|
|
354
354
|
addAt(index, newElementOrNode): boolean;
|
|
355
355
|
```
|
|
356
356
|
|
|
357
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
357
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:568](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L568)
|
|
358
358
|
|
|
359
359
|
Insert a new element/node at an index, shifting following nodes.
|
|
360
360
|
|
|
@@ -378,8 +378,6 @@ Element or node to insert.
|
|
|
378
378
|
|
|
379
379
|
True if inserted.
|
|
380
380
|
|
|
381
|
-
*
|
|
382
|
-
|
|
383
381
|
#### Remarks
|
|
384
382
|
|
|
385
383
|
Time O(N), Space O(1)
|
|
@@ -405,7 +403,7 @@ Time O(N), Space O(1)
|
|
|
405
403
|
addBefore(existingElementOrNode, newElementOrNode): boolean;
|
|
406
404
|
```
|
|
407
405
|
|
|
408
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
406
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:674](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L674)
|
|
409
407
|
|
|
410
408
|
Insert a new element/node before an existing one.
|
|
411
409
|
|
|
@@ -445,7 +443,7 @@ Time O(N), Space O(1)
|
|
|
445
443
|
at(index): E | undefined;
|
|
446
444
|
```
|
|
447
445
|
|
|
448
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
446
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:470](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L470)
|
|
449
447
|
|
|
450
448
|
Get the element at a given index.
|
|
451
449
|
|
|
@@ -463,8 +461,6 @@ Zero-based index.
|
|
|
463
461
|
|
|
464
462
|
Element or undefined.
|
|
465
463
|
|
|
466
|
-
*
|
|
467
|
-
|
|
468
464
|
#### Remarks
|
|
469
465
|
|
|
470
466
|
Time O(N), Space O(1)
|
|
@@ -491,7 +487,7 @@ Time O(N), Space O(1)
|
|
|
491
487
|
clear(): void;
|
|
492
488
|
```
|
|
493
489
|
|
|
494
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
490
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:616](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L616)
|
|
495
491
|
|
|
496
492
|
Remove all nodes and reset length.
|
|
497
493
|
|
|
@@ -501,8 +497,6 @@ Remove all nodes and reset length.
|
|
|
501
497
|
|
|
502
498
|
void
|
|
503
499
|
|
|
504
|
-
*
|
|
505
|
-
|
|
506
500
|
#### Remarks
|
|
507
501
|
|
|
508
502
|
Time O(N), Space O(1)
|
|
@@ -528,7 +522,7 @@ Time O(N), Space O(1)
|
|
|
528
522
|
clone(): this;
|
|
529
523
|
```
|
|
530
524
|
|
|
531
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
525
|
+
Defined in: [data-structures/queue/queue.ts:630](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L630)
|
|
532
526
|
|
|
533
527
|
Deep clone this linked-list-based queue.
|
|
534
528
|
|
|
@@ -554,7 +548,7 @@ Time O(N), Space O(N)
|
|
|
554
548
|
concat(...items): this;
|
|
555
549
|
```
|
|
556
550
|
|
|
557
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
551
|
+
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)
|
|
558
552
|
|
|
559
553
|
Concatenate lists/elements preserving order.
|
|
560
554
|
|
|
@@ -590,7 +584,7 @@ Time O(sum(length)), Space O(sum(length))
|
|
|
590
584
|
countOccurrences(elementOrNode): number;
|
|
591
585
|
```
|
|
592
586
|
|
|
593
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
587
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:768](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L768)
|
|
594
588
|
|
|
595
589
|
Count how many nodes match a value/node/predicate.
|
|
596
590
|
|
|
@@ -626,7 +620,7 @@ Time O(N), Space O(1)
|
|
|
626
620
|
delete(elementOrNode?): boolean;
|
|
627
621
|
```
|
|
628
622
|
|
|
629
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
623
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:540](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L540)
|
|
630
624
|
|
|
631
625
|
Delete the first match by value/node.
|
|
632
626
|
|
|
@@ -644,8 +638,6 @@ Element or node to remove; if omitted/undefined, nothing happens.
|
|
|
644
638
|
|
|
645
639
|
True if removed.
|
|
646
640
|
|
|
647
|
-
*
|
|
648
|
-
|
|
649
641
|
#### Remarks
|
|
650
642
|
|
|
651
643
|
Time O(N), Space O(1)
|
|
@@ -671,7 +663,7 @@ Time O(N), Space O(1)
|
|
|
671
663
|
deleteAt(index): E | undefined;
|
|
672
664
|
```
|
|
673
665
|
|
|
674
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
666
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:517](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L517)
|
|
675
667
|
|
|
676
668
|
Delete the element at an index.
|
|
677
669
|
|
|
@@ -689,8 +681,6 @@ Zero-based index.
|
|
|
689
681
|
|
|
690
682
|
Removed element or undefined.
|
|
691
683
|
|
|
692
|
-
*
|
|
693
|
-
|
|
694
684
|
#### Remarks
|
|
695
685
|
|
|
696
686
|
Time O(N), Space O(1)
|
|
@@ -716,7 +706,7 @@ Time O(N), Space O(1)
|
|
|
716
706
|
deleteWhere(predicate): boolean;
|
|
717
707
|
```
|
|
718
708
|
|
|
719
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
709
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:796](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L796)
|
|
720
710
|
|
|
721
711
|
Delete the first node whose value matches a predicate.
|
|
722
712
|
|
|
@@ -744,6 +734,30 @@ Time O(N), Space O(1)
|
|
|
744
734
|
|
|
745
735
|
***
|
|
746
736
|
|
|
737
|
+
### entries()
|
|
738
|
+
|
|
739
|
+
```ts
|
|
740
|
+
entries(): IterableIterator<[number, E]>;
|
|
741
|
+
```
|
|
742
|
+
|
|
743
|
+
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)
|
|
744
|
+
|
|
745
|
+
Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
746
|
+
|
|
747
|
+
#### Returns
|
|
748
|
+
|
|
749
|
+
`IterableIterator`\<\[`number`, `E`\]\>
|
|
750
|
+
|
|
751
|
+
#### Remarks
|
|
752
|
+
|
|
753
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
754
|
+
|
|
755
|
+
#### Inherited from
|
|
756
|
+
|
|
757
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`entries`](SinglyLinkedList.md#entries)
|
|
758
|
+
|
|
759
|
+
***
|
|
760
|
+
|
|
747
761
|
### every()
|
|
748
762
|
|
|
749
763
|
```ts
|
|
@@ -793,7 +807,7 @@ fill(
|
|
|
793
807
|
end?): this;
|
|
794
808
|
```
|
|
795
809
|
|
|
796
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
810
|
+
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)
|
|
797
811
|
|
|
798
812
|
Fill a range with a value.
|
|
799
813
|
|
|
@@ -839,7 +853,7 @@ Time O(n), Space O(1)
|
|
|
839
853
|
filter(callback, thisArg?): this;
|
|
840
854
|
```
|
|
841
855
|
|
|
842
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
856
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:858](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L858)
|
|
843
857
|
|
|
844
858
|
Filter values into a new list of the same class.
|
|
845
859
|
|
|
@@ -863,8 +877,6 @@ Value for `this` inside the callback.
|
|
|
863
877
|
|
|
864
878
|
A new list with kept values.
|
|
865
879
|
|
|
866
|
-
*
|
|
867
|
-
|
|
868
880
|
#### Remarks
|
|
869
881
|
|
|
870
882
|
Time O(N), Space O(N)
|
|
@@ -990,7 +1002,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
|
990
1002
|
findIndex(predicate, thisArg?): number;
|
|
991
1003
|
```
|
|
992
1004
|
|
|
993
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1005
|
+
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)
|
|
994
1006
|
|
|
995
1007
|
Find the first index matching a predicate.
|
|
996
1008
|
|
|
@@ -1070,7 +1082,7 @@ Time O(n), Space O(1).
|
|
|
1070
1082
|
getNode(elementNodeOrPredicate?): SinglyLinkedListNode<E> | undefined;
|
|
1071
1083
|
```
|
|
1072
1084
|
|
|
1073
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
1085
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:653](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L653)
|
|
1074
1086
|
|
|
1075
1087
|
Find a node by value, reference, or predicate.
|
|
1076
1088
|
|
|
@@ -1106,7 +1118,7 @@ Time O(N), Space O(1)
|
|
|
1106
1118
|
getNodeAt(index): SinglyLinkedListNode<E> | undefined;
|
|
1107
1119
|
```
|
|
1108
1120
|
|
|
1109
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
1121
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:499](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L499)
|
|
1110
1122
|
|
|
1111
1123
|
Get the node reference at a given index.
|
|
1112
1124
|
|
|
@@ -1124,8 +1136,6 @@ Zero-based index.
|
|
|
1124
1136
|
|
|
1125
1137
|
Node or undefined.
|
|
1126
1138
|
|
|
1127
|
-
*
|
|
1128
|
-
|
|
1129
1139
|
#### Remarks
|
|
1130
1140
|
|
|
1131
1141
|
Time O(N), Space O(1)
|
|
@@ -1150,7 +1160,7 @@ Time O(N), Space O(1)
|
|
|
1150
1160
|
has(element): boolean;
|
|
1151
1161
|
```
|
|
1152
1162
|
|
|
1153
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1163
|
+
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)
|
|
1154
1164
|
|
|
1155
1165
|
Checks whether a strictly-equal element exists in the structure.
|
|
1156
1166
|
|
|
@@ -1178,13 +1188,47 @@ Time O(n) in the worst case. Space O(1).
|
|
|
1178
1188
|
|
|
1179
1189
|
***
|
|
1180
1190
|
|
|
1191
|
+
### includes()
|
|
1192
|
+
|
|
1193
|
+
```ts
|
|
1194
|
+
includes(element): boolean;
|
|
1195
|
+
```
|
|
1196
|
+
|
|
1197
|
+
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)
|
|
1198
|
+
|
|
1199
|
+
Check whether a value exists (Array-compatible alias for `has`).
|
|
1200
|
+
|
|
1201
|
+
#### Parameters
|
|
1202
|
+
|
|
1203
|
+
##### element
|
|
1204
|
+
|
|
1205
|
+
`E`
|
|
1206
|
+
|
|
1207
|
+
Element to search for (uses `===`).
|
|
1208
|
+
|
|
1209
|
+
#### Returns
|
|
1210
|
+
|
|
1211
|
+
`boolean`
|
|
1212
|
+
|
|
1213
|
+
`true` if found.
|
|
1214
|
+
|
|
1215
|
+
#### Remarks
|
|
1216
|
+
|
|
1217
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
1218
|
+
|
|
1219
|
+
#### Inherited from
|
|
1220
|
+
|
|
1221
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`includes`](SinglyLinkedList.md#includes)
|
|
1222
|
+
|
|
1223
|
+
***
|
|
1224
|
+
|
|
1181
1225
|
### indexOf()
|
|
1182
1226
|
|
|
1183
1227
|
```ts
|
|
1184
1228
|
indexOf(searchElement, fromIndex?): number;
|
|
1185
1229
|
```
|
|
1186
1230
|
|
|
1187
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1231
|
+
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)
|
|
1188
1232
|
|
|
1189
1233
|
Linked-list optimized `indexOf` (forwards scan).
|
|
1190
1234
|
|
|
@@ -1224,7 +1268,7 @@ Time O(n), Space O(1)
|
|
|
1224
1268
|
isEmpty(): boolean;
|
|
1225
1269
|
```
|
|
1226
1270
|
|
|
1227
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
1271
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:602](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L602)
|
|
1228
1272
|
|
|
1229
1273
|
Check whether the list is empty.
|
|
1230
1274
|
|
|
@@ -1234,8 +1278,6 @@ Check whether the list is empty.
|
|
|
1234
1278
|
|
|
1235
1279
|
True if length is 0.
|
|
1236
1280
|
|
|
1237
|
-
*
|
|
1238
|
-
|
|
1239
1281
|
#### Remarks
|
|
1240
1282
|
|
|
1241
1283
|
Time O(1), Space O(1)
|
|
@@ -1259,7 +1301,7 @@ Time O(1), Space O(1)
|
|
|
1259
1301
|
isNode(elementNodeOrPredicate): elementNodeOrPredicate is SinglyLinkedListNode<E>;
|
|
1260
1302
|
```
|
|
1261
1303
|
|
|
1262
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
1304
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:483](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L483)
|
|
1263
1305
|
|
|
1264
1306
|
Type guard: check whether the input is a SinglyLinkedListNode.
|
|
1265
1307
|
|
|
@@ -1295,7 +1337,7 @@ Time O(1), Space O(1)
|
|
|
1295
1337
|
join(separator?): string;
|
|
1296
1338
|
```
|
|
1297
1339
|
|
|
1298
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1340
|
+
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)
|
|
1299
1341
|
|
|
1300
1342
|
Join all elements into a string.
|
|
1301
1343
|
|
|
@@ -1323,13 +1365,37 @@ Time O(n), Space O(n)
|
|
|
1323
1365
|
|
|
1324
1366
|
***
|
|
1325
1367
|
|
|
1368
|
+
### keys()
|
|
1369
|
+
|
|
1370
|
+
```ts
|
|
1371
|
+
keys(): IterableIterator<number>;
|
|
1372
|
+
```
|
|
1373
|
+
|
|
1374
|
+
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)
|
|
1375
|
+
|
|
1376
|
+
Return an iterator of numeric indices (Array-compatible).
|
|
1377
|
+
|
|
1378
|
+
#### Returns
|
|
1379
|
+
|
|
1380
|
+
`IterableIterator`\<`number`\>
|
|
1381
|
+
|
|
1382
|
+
#### Remarks
|
|
1383
|
+
|
|
1384
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
1385
|
+
|
|
1386
|
+
#### Inherited from
|
|
1387
|
+
|
|
1388
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`keys`](SinglyLinkedList.md#keys)
|
|
1389
|
+
|
|
1390
|
+
***
|
|
1391
|
+
|
|
1326
1392
|
### lastIndexOf()
|
|
1327
1393
|
|
|
1328
1394
|
```ts
|
|
1329
1395
|
lastIndexOf(searchElement, fromIndex?): number;
|
|
1330
1396
|
```
|
|
1331
1397
|
|
|
1332
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1398
|
+
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)
|
|
1333
1399
|
|
|
1334
1400
|
Linked-list optimized `lastIndexOf` (reverse scan).
|
|
1335
1401
|
|
|
@@ -1372,7 +1438,7 @@ map<EM, RM>(
|
|
|
1372
1438
|
thisArg?): SinglyLinkedList<EM, RM>;
|
|
1373
1439
|
```
|
|
1374
1440
|
|
|
1375
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
1441
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:897](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L897)
|
|
1376
1442
|
|
|
1377
1443
|
Map values into a new list (possibly different element type).
|
|
1378
1444
|
|
|
@@ -1412,8 +1478,6 @@ Value for `this` inside the callback.
|
|
|
1412
1478
|
|
|
1413
1479
|
A new SinglyLinkedList with mapped values.
|
|
1414
1480
|
|
|
1415
|
-
*
|
|
1416
|
-
|
|
1417
1481
|
#### Remarks
|
|
1418
1482
|
|
|
1419
1483
|
Time O(N), Space O(N)
|
|
@@ -1439,7 +1503,7 @@ Time O(N), Space O(N)
|
|
|
1439
1503
|
mapSame(callback, thisArg?): this;
|
|
1440
1504
|
```
|
|
1441
1505
|
|
|
1442
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
1506
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:872](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L872)
|
|
1443
1507
|
|
|
1444
1508
|
Map values into a new list of the same class.
|
|
1445
1509
|
|
|
@@ -1479,7 +1543,7 @@ Time O(N), Space O(N)
|
|
|
1479
1543
|
pop(): E | undefined;
|
|
1480
1544
|
```
|
|
1481
1545
|
|
|
1482
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
1546
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:335](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L335)
|
|
1483
1547
|
|
|
1484
1548
|
Remove and return the tail element.
|
|
1485
1549
|
|
|
@@ -1489,8 +1553,6 @@ Remove and return the tail element.
|
|
|
1489
1553
|
|
|
1490
1554
|
Removed element or undefined.
|
|
1491
1555
|
|
|
1492
|
-
*
|
|
1493
|
-
|
|
1494
1556
|
#### Remarks
|
|
1495
1557
|
|
|
1496
1558
|
Time O(N), Space O(1)
|
|
@@ -1526,7 +1588,7 @@ Time O(N), Space O(1)
|
|
|
1526
1588
|
print(): void;
|
|
1527
1589
|
```
|
|
1528
1590
|
|
|
1529
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1591
|
+
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)
|
|
1530
1592
|
|
|
1531
1593
|
Prints `toVisual()` to the console. Intended for quick debugging.
|
|
1532
1594
|
|
|
@@ -1552,7 +1614,7 @@ Time O(n) due to materialization, Space O(n) for the intermediate representation
|
|
|
1552
1614
|
push(elementOrNode): boolean;
|
|
1553
1615
|
```
|
|
1554
1616
|
|
|
1555
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
1617
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:302](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L302)
|
|
1556
1618
|
|
|
1557
1619
|
Append an element/node to the tail.
|
|
1558
1620
|
|
|
@@ -1570,8 +1632,6 @@ Element or node to append.
|
|
|
1570
1632
|
|
|
1571
1633
|
True when appended.
|
|
1572
1634
|
|
|
1573
|
-
*
|
|
1574
|
-
|
|
1575
1635
|
#### Remarks
|
|
1576
1636
|
|
|
1577
1637
|
Time O(1), Space O(1)
|
|
@@ -1607,7 +1667,7 @@ Time O(1), Space O(1)
|
|
|
1607
1667
|
pushMany(elements): boolean[];
|
|
1608
1668
|
```
|
|
1609
1669
|
|
|
1610
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
1670
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:416](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L416)
|
|
1611
1671
|
|
|
1612
1672
|
Append a sequence of elements/nodes.
|
|
1613
1673
|
|
|
@@ -1675,7 +1735,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
|
|
|
1675
1735
|
reduce(callbackfn): E;
|
|
1676
1736
|
```
|
|
1677
1737
|
|
|
1678
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1738
|
+
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)
|
|
1679
1739
|
|
|
1680
1740
|
##### Parameters
|
|
1681
1741
|
|
|
@@ -1697,7 +1757,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
|
|
|
1697
1757
|
reduce(callbackfn, initialValue): E;
|
|
1698
1758
|
```
|
|
1699
1759
|
|
|
1700
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1760
|
+
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)
|
|
1701
1761
|
|
|
1702
1762
|
##### Parameters
|
|
1703
1763
|
|
|
@@ -1723,7 +1783,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
|
|
|
1723
1783
|
reduce<U>(callbackfn, initialValue): U;
|
|
1724
1784
|
```
|
|
1725
1785
|
|
|
1726
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1786
|
+
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)
|
|
1727
1787
|
|
|
1728
1788
|
##### Type Parameters
|
|
1729
1789
|
|
|
@@ -1757,7 +1817,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.c
|
|
|
1757
1817
|
reduceRight<U>(callbackfn, initialValue): U;
|
|
1758
1818
|
```
|
|
1759
1819
|
|
|
1760
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1820
|
+
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)
|
|
1761
1821
|
|
|
1762
1822
|
Right-to-left reduction using reverse iterator.
|
|
1763
1823
|
|
|
@@ -1803,7 +1863,7 @@ Time O(n), Space O(1)
|
|
|
1803
1863
|
reverse(): this;
|
|
1804
1864
|
```
|
|
1805
1865
|
|
|
1806
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
1866
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:632](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L632)
|
|
1807
1867
|
|
|
1808
1868
|
Reverse the list in place.
|
|
1809
1869
|
|
|
@@ -1813,8 +1873,6 @@ Reverse the list in place.
|
|
|
1813
1873
|
|
|
1814
1874
|
This list.
|
|
1815
1875
|
|
|
1816
|
-
*
|
|
1817
|
-
|
|
1818
1876
|
#### Remarks
|
|
1819
1877
|
|
|
1820
1878
|
Time O(N), Space O(1)
|
|
@@ -1840,7 +1898,7 @@ Time O(N), Space O(1)
|
|
|
1840
1898
|
search(elementNodeOrPredicate): E | undefined;
|
|
1841
1899
|
```
|
|
1842
1900
|
|
|
1843
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
1901
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:446](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L446)
|
|
1844
1902
|
|
|
1845
1903
|
Find the first value matching a predicate (by node).
|
|
1846
1904
|
|
|
@@ -1876,7 +1934,7 @@ Time O(N), Space O(1)
|
|
|
1876
1934
|
setAt(index, value): boolean;
|
|
1877
1935
|
```
|
|
1878
1936
|
|
|
1879
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
1937
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:587](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L587)
|
|
1880
1938
|
|
|
1881
1939
|
Set the element value at an index.
|
|
1882
1940
|
|
|
@@ -1916,7 +1974,7 @@ Time O(N), Space O(1)
|
|
|
1916
1974
|
setEquality(equals): this;
|
|
1917
1975
|
```
|
|
1918
1976
|
|
|
1919
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
1977
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:785](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L785)
|
|
1920
1978
|
|
|
1921
1979
|
Set the equality comparator used to compare values.
|
|
1922
1980
|
|
|
@@ -1950,7 +2008,7 @@ Time O(1), Space O(1)
|
|
|
1950
2008
|
shift(): E | undefined;
|
|
1951
2009
|
```
|
|
1952
2010
|
|
|
1953
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2011
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:363](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L363)
|
|
1954
2012
|
|
|
1955
2013
|
Remove and return the head element.
|
|
1956
2014
|
|
|
@@ -1960,8 +2018,6 @@ Remove and return the head element.
|
|
|
1960
2018
|
|
|
1961
2019
|
Removed element or undefined.
|
|
1962
2020
|
|
|
1963
|
-
*
|
|
1964
|
-
|
|
1965
2021
|
#### Remarks
|
|
1966
2022
|
|
|
1967
2023
|
Time O(1), Space O(1)
|
|
@@ -1987,7 +2043,7 @@ Time O(1), Space O(1)
|
|
|
1987
2043
|
slice(start?, end?): this;
|
|
1988
2044
|
```
|
|
1989
2045
|
|
|
1990
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
2046
|
+
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)
|
|
1991
2047
|
|
|
1992
2048
|
Slice via forward iteration (no random access required).
|
|
1993
2049
|
|
|
@@ -2067,7 +2123,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
|
|
|
2067
2123
|
sort(compareFn?): this;
|
|
2068
2124
|
```
|
|
2069
2125
|
|
|
2070
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
2126
|
+
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)
|
|
2071
2127
|
|
|
2072
2128
|
In-place stable order via array sort semantics.
|
|
2073
2129
|
|
|
@@ -2104,7 +2160,7 @@ splice(
|
|
|
2104
2160
|
items?): this;
|
|
2105
2161
|
```
|
|
2106
2162
|
|
|
2107
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2163
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:721](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L721)
|
|
2108
2164
|
|
|
2109
2165
|
Remove and/or insert elements at a position (array-like behavior).
|
|
2110
2166
|
|
|
@@ -2150,7 +2206,7 @@ Time O(N + M), Space O(M)
|
|
|
2150
2206
|
toArray(): E[];
|
|
2151
2207
|
```
|
|
2152
2208
|
|
|
2153
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
2209
|
+
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)
|
|
2154
2210
|
|
|
2155
2211
|
Materializes the elements into a new array.
|
|
2156
2212
|
|
|
@@ -2170,13 +2226,39 @@ Time O(n), Space O(n).
|
|
|
2170
2226
|
|
|
2171
2227
|
***
|
|
2172
2228
|
|
|
2229
|
+
### toReversed()
|
|
2230
|
+
|
|
2231
|
+
```ts
|
|
2232
|
+
toReversed(): this;
|
|
2233
|
+
```
|
|
2234
|
+
|
|
2235
|
+
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)
|
|
2236
|
+
|
|
2237
|
+
Return a new instance of the same type with elements in reverse order (non-mutating).
|
|
2238
|
+
|
|
2239
|
+
#### Returns
|
|
2240
|
+
|
|
2241
|
+
`this`
|
|
2242
|
+
|
|
2243
|
+
A new reversed instance.
|
|
2244
|
+
|
|
2245
|
+
#### Remarks
|
|
2246
|
+
|
|
2247
|
+
Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
|
|
2248
|
+
|
|
2249
|
+
#### Inherited from
|
|
2250
|
+
|
|
2251
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`toReversed`](SinglyLinkedList.md#toreversed)
|
|
2252
|
+
|
|
2253
|
+
***
|
|
2254
|
+
|
|
2173
2255
|
### toReversedArray()
|
|
2174
2256
|
|
|
2175
2257
|
```ts
|
|
2176
2258
|
toReversedArray(): E[];
|
|
2177
2259
|
```
|
|
2178
2260
|
|
|
2179
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
2261
|
+
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)
|
|
2180
2262
|
|
|
2181
2263
|
Snapshot elements into a reversed array.
|
|
2182
2264
|
|
|
@@ -2202,7 +2284,7 @@ Time O(n), Space O(n)
|
|
|
2202
2284
|
toVisual(): E[];
|
|
2203
2285
|
```
|
|
2204
2286
|
|
|
2205
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
2287
|
+
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)
|
|
2206
2288
|
|
|
2207
2289
|
Returns a representation of the structure suitable for quick visualization.
|
|
2208
2290
|
Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
@@ -2229,7 +2311,7 @@ Time O(n), Space O(n).
|
|
|
2229
2311
|
unshift(elementOrNode): boolean;
|
|
2230
2312
|
```
|
|
2231
2313
|
|
|
2232
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2314
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:398](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L398)
|
|
2233
2315
|
|
|
2234
2316
|
Prepend an element/node to the head.
|
|
2235
2317
|
|
|
@@ -2247,8 +2329,6 @@ Element or node to prepend.
|
|
|
2247
2329
|
|
|
2248
2330
|
True when prepended.
|
|
2249
2331
|
|
|
2250
|
-
*
|
|
2251
|
-
|
|
2252
2332
|
#### Remarks
|
|
2253
2333
|
|
|
2254
2334
|
Time O(1), Space O(1)
|
|
@@ -2289,7 +2369,7 @@ Time O(1), Space O(1)
|
|
|
2289
2369
|
unshiftMany(elements): boolean[];
|
|
2290
2370
|
```
|
|
2291
2371
|
|
|
2292
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2372
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:431](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L431)
|
|
2293
2373
|
|
|
2294
2374
|
Prepend a sequence of elements/nodes.
|
|
2295
2375
|
|
|
@@ -2354,7 +2434,7 @@ static from<E, R, S>(
|
|
|
2354
2434
|
options?): S;
|
|
2355
2435
|
```
|
|
2356
2436
|
|
|
2357
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2437
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:268](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L268)
|
|
2358
2438
|
|
|
2359
2439
|
Create a new list from an iterable of elements.
|
|
2360
2440
|
|
|
@@ -2447,7 +2527,7 @@ Time O(1), Space O(1).
|
|
|
2447
2527
|
protected _createInstance(options?): this;
|
|
2448
2528
|
```
|
|
2449
2529
|
|
|
2450
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2530
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:1013](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L1013)
|
|
2451
2531
|
|
|
2452
2532
|
(Protected) Create an empty instance of the same concrete class.
|
|
2453
2533
|
|
|
@@ -2481,7 +2561,7 @@ Time O(1), Space O(1)
|
|
|
2481
2561
|
protected _createLike<EM, RM>(elements?, options?): SinglyLinkedList<EM, RM>;
|
|
2482
2562
|
```
|
|
2483
2563
|
|
|
2484
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2564
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:1030](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L1030)
|
|
2485
2565
|
|
|
2486
2566
|
(Protected) Create a like-kind instance and seed it from an iterable.
|
|
2487
2567
|
|
|
@@ -2533,7 +2613,7 @@ Time O(N), Space O(N)
|
|
|
2533
2613
|
protected _ensureNode(elementOrNode): SinglyLinkedListNode<E>;
|
|
2534
2614
|
```
|
|
2535
2615
|
|
|
2536
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2616
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:938](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L938)
|
|
2537
2617
|
|
|
2538
2618
|
(Protected) Normalize input into a node instance.
|
|
2539
2619
|
|
|
@@ -2567,7 +2647,7 @@ Time O(1), Space O(1)
|
|
|
2567
2647
|
protected _ensurePredicate(elementNodeOrPredicate): (node) => boolean;
|
|
2568
2648
|
```
|
|
2569
2649
|
|
|
2570
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2650
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:949](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L949)
|
|
2571
2651
|
|
|
2572
2652
|
(Protected) Normalize input into a node predicate.
|
|
2573
2653
|
|
|
@@ -2603,7 +2683,7 @@ Time O(1), Space O(1)
|
|
|
2603
2683
|
protected _getIterator(): IterableIterator<E>;
|
|
2604
2684
|
```
|
|
2605
2685
|
|
|
2606
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2686
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:976](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L976)
|
|
2607
2687
|
|
|
2608
2688
|
(Protected) Iterate values from head to tail.
|
|
2609
2689
|
|
|
@@ -2629,7 +2709,7 @@ Time O(N), Space O(1)
|
|
|
2629
2709
|
protected _getNodeIterator(): IterableIterator<SinglyLinkedListNode<E>>;
|
|
2630
2710
|
```
|
|
2631
2711
|
|
|
2632
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2712
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:999](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L999)
|
|
2633
2713
|
|
|
2634
2714
|
(Protected) Iterate nodes from head to tail.
|
|
2635
2715
|
|
|
@@ -2655,7 +2735,7 @@ Time O(N), Space O(1)
|
|
|
2655
2735
|
protected _getPrevNode(node): SinglyLinkedListNode<E> | undefined;
|
|
2656
2736
|
```
|
|
2657
2737
|
|
|
2658
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2738
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:964](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L964)
|
|
2659
2739
|
|
|
2660
2740
|
(Protected) Get the previous node of a given node.
|
|
2661
2741
|
|
|
@@ -2689,7 +2769,7 @@ Time O(N), Space O(1)
|
|
|
2689
2769
|
protected _getReverseIterator(): IterableIterator<E>;
|
|
2690
2770
|
```
|
|
2691
2771
|
|
|
2692
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2772
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:989](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L989)
|
|
2693
2773
|
|
|
2694
2774
|
(Protected) Iterate values from tail to head.
|
|
2695
2775
|
|
|
@@ -2715,7 +2795,7 @@ Time O(N), Space O(N)
|
|
|
2715
2795
|
protected _isPredicate(elementNodeOrPredicate): elementNodeOrPredicate is (node: SinglyLinkedListNode<E>) => boolean;
|
|
2716
2796
|
```
|
|
2717
2797
|
|
|
2718
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2798
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:926](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L926)
|
|
2719
2799
|
|
|
2720
2800
|
(Protected) Check if input is a node predicate function.
|
|
2721
2801
|
|
|
@@ -2751,7 +2831,7 @@ Time O(1), Space O(1)
|
|
|
2751
2831
|
protected _spawnLike<EM, RM>(options?): SinglyLinkedList<EM, RM>;
|
|
2752
2832
|
```
|
|
2753
2833
|
|
|
2754
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2834
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:1049](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L1049)
|
|
2755
2835
|
|
|
2756
2836
|
(Protected) Spawn an empty like-kind list instance.
|
|
2757
2837
|
|
|
@@ -2795,7 +2875,7 @@ Time O(1), Space O(1)
|
|
|
2795
2875
|
protected createNode(value): SinglyLinkedListNode<E>;
|
|
2796
2876
|
```
|
|
2797
2877
|
|
|
2798
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2878
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:916](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L916)
|
|
2799
2879
|
|
|
2800
2880
|
(Protected) Create a node from a value.
|
|
2801
2881
|
|