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: SinglyLinkedList\<E, R\>
|
|
8
8
|
|
|
9
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
9
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:190](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L190)
|
|
10
10
|
|
|
11
11
|
Singly linked list with O(1) push/pop-like ends operations and linear scans.
|
|
12
12
|
|
|
@@ -184,7 +184,7 @@ Caution: Although our linked list classes provide methods such as at, setAt, add
|
|
|
184
184
|
new SinglyLinkedList<E, R>(elements?, options?): SinglyLinkedList<E, R>;
|
|
185
185
|
```
|
|
186
186
|
|
|
187
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
187
|
+
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)
|
|
188
188
|
|
|
189
189
|
Create a SinglyLinkedList and optionally bulk-insert elements.
|
|
190
190
|
|
|
@@ -230,7 +230,7 @@ LinearLinkedBase<E, R, SinglyLinkedListNode<E>>.constructor
|
|
|
230
230
|
get first(): E | undefined;
|
|
231
231
|
```
|
|
232
232
|
|
|
233
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
233
|
+
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)
|
|
234
234
|
|
|
235
235
|
Get the first element value.
|
|
236
236
|
|
|
@@ -254,7 +254,7 @@ First element or undefined.
|
|
|
254
254
|
get head(): SinglyLinkedListNode<E> | undefined;
|
|
255
255
|
```
|
|
256
256
|
|
|
257
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
257
|
+
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)
|
|
258
258
|
|
|
259
259
|
Get the head node.
|
|
260
260
|
|
|
@@ -278,7 +278,7 @@ Head node or undefined.
|
|
|
278
278
|
get last(): E | undefined;
|
|
279
279
|
```
|
|
280
280
|
|
|
281
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
281
|
+
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)
|
|
282
282
|
|
|
283
283
|
Get the last element value.
|
|
284
284
|
|
|
@@ -302,7 +302,7 @@ Last element or undefined.
|
|
|
302
302
|
get length(): number;
|
|
303
303
|
```
|
|
304
304
|
|
|
305
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
305
|
+
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)
|
|
306
306
|
|
|
307
307
|
Get the number of elements.
|
|
308
308
|
|
|
@@ -358,7 +358,7 @@ Maximum allowed length.
|
|
|
358
358
|
get tail(): SinglyLinkedListNode<E> | undefined;
|
|
359
359
|
```
|
|
360
360
|
|
|
361
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
361
|
+
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)
|
|
362
362
|
|
|
363
363
|
Get the tail node.
|
|
364
364
|
|
|
@@ -442,7 +442,7 @@ Producing the iterator is O(1); consuming the entire iterator is Time O(n) with
|
|
|
442
442
|
addAfter(existingElementOrNode, newElementOrNode): boolean;
|
|
443
443
|
```
|
|
444
444
|
|
|
445
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
445
|
+
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)
|
|
446
446
|
|
|
447
447
|
Insert a new element/node after an existing one.
|
|
448
448
|
|
|
@@ -482,7 +482,7 @@ Time O(N), Space O(1)
|
|
|
482
482
|
addAt(index, newElementOrNode): boolean;
|
|
483
483
|
```
|
|
484
484
|
|
|
485
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
485
|
+
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)
|
|
486
486
|
|
|
487
487
|
Insert a new element/node at an index, shifting following nodes.
|
|
488
488
|
|
|
@@ -506,8 +506,6 @@ Element or node to insert.
|
|
|
506
506
|
|
|
507
507
|
True if inserted.
|
|
508
508
|
|
|
509
|
-
*
|
|
510
|
-
|
|
511
509
|
#### Remarks
|
|
512
510
|
|
|
513
511
|
Time O(N), Space O(1)
|
|
@@ -533,7 +531,7 @@ Time O(N), Space O(1)
|
|
|
533
531
|
addBefore(existingElementOrNode, newElementOrNode): boolean;
|
|
534
532
|
```
|
|
535
533
|
|
|
536
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
534
|
+
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)
|
|
537
535
|
|
|
538
536
|
Insert a new element/node before an existing one.
|
|
539
537
|
|
|
@@ -573,7 +571,7 @@ Time O(N), Space O(1)
|
|
|
573
571
|
at(index): E | undefined;
|
|
574
572
|
```
|
|
575
573
|
|
|
576
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
574
|
+
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)
|
|
577
575
|
|
|
578
576
|
Get the element at a given index.
|
|
579
577
|
|
|
@@ -591,8 +589,6 @@ Zero-based index.
|
|
|
591
589
|
|
|
592
590
|
Element or undefined.
|
|
593
591
|
|
|
594
|
-
*
|
|
595
|
-
|
|
596
592
|
#### Remarks
|
|
597
593
|
|
|
598
594
|
Time O(N), Space O(1)
|
|
@@ -619,7 +615,7 @@ Time O(N), Space O(1)
|
|
|
619
615
|
clear(): void;
|
|
620
616
|
```
|
|
621
617
|
|
|
622
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
618
|
+
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)
|
|
623
619
|
|
|
624
620
|
Remove all nodes and reset length.
|
|
625
621
|
|
|
@@ -629,8 +625,6 @@ Remove all nodes and reset length.
|
|
|
629
625
|
|
|
630
626
|
void
|
|
631
627
|
|
|
632
|
-
*
|
|
633
|
-
|
|
634
628
|
#### Remarks
|
|
635
629
|
|
|
636
630
|
Time O(N), Space O(1)
|
|
@@ -656,7 +650,7 @@ Time O(N), Space O(1)
|
|
|
656
650
|
clone(): this;
|
|
657
651
|
```
|
|
658
652
|
|
|
659
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
653
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:830](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/singly-linked-list.ts#L830)
|
|
660
654
|
|
|
661
655
|
Deep clone this list (values are copied by reference).
|
|
662
656
|
|
|
@@ -666,8 +660,6 @@ Deep clone this list (values are copied by reference).
|
|
|
666
660
|
|
|
667
661
|
A new list with the same element sequence.
|
|
668
662
|
|
|
669
|
-
*
|
|
670
|
-
|
|
671
663
|
#### Remarks
|
|
672
664
|
|
|
673
665
|
Time O(N), Space O(N)
|
|
@@ -695,7 +687,7 @@ Time O(N), Space O(N)
|
|
|
695
687
|
concat(...items): this;
|
|
696
688
|
```
|
|
697
689
|
|
|
698
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
690
|
+
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)
|
|
699
691
|
|
|
700
692
|
Concatenate lists/elements preserving order.
|
|
701
693
|
|
|
@@ -731,7 +723,7 @@ Time O(sum(length)), Space O(sum(length))
|
|
|
731
723
|
countOccurrences(elementOrNode): number;
|
|
732
724
|
```
|
|
733
725
|
|
|
734
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
726
|
+
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)
|
|
735
727
|
|
|
736
728
|
Count how many nodes match a value/node/predicate.
|
|
737
729
|
|
|
@@ -763,7 +755,7 @@ Time O(N), Space O(1)
|
|
|
763
755
|
delete(elementOrNode?): boolean;
|
|
764
756
|
```
|
|
765
757
|
|
|
766
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
758
|
+
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)
|
|
767
759
|
|
|
768
760
|
Delete the first match by value/node.
|
|
769
761
|
|
|
@@ -781,8 +773,6 @@ Element or node to remove; if omitted/undefined, nothing happens.
|
|
|
781
773
|
|
|
782
774
|
True if removed.
|
|
783
775
|
|
|
784
|
-
*
|
|
785
|
-
|
|
786
776
|
#### Remarks
|
|
787
777
|
|
|
788
778
|
Time O(N), Space O(1)
|
|
@@ -808,7 +798,7 @@ Time O(N), Space O(1)
|
|
|
808
798
|
deleteAt(index): E | undefined;
|
|
809
799
|
```
|
|
810
800
|
|
|
811
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
801
|
+
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)
|
|
812
802
|
|
|
813
803
|
Delete the element at an index.
|
|
814
804
|
|
|
@@ -826,8 +816,6 @@ Zero-based index.
|
|
|
826
816
|
|
|
827
817
|
Removed element or undefined.
|
|
828
818
|
|
|
829
|
-
*
|
|
830
|
-
|
|
831
819
|
#### Remarks
|
|
832
820
|
|
|
833
821
|
Time O(N), Space O(1)
|
|
@@ -853,7 +841,7 @@ Time O(N), Space O(1)
|
|
|
853
841
|
deleteWhere(predicate): boolean;
|
|
854
842
|
```
|
|
855
843
|
|
|
856
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
844
|
+
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)
|
|
857
845
|
|
|
858
846
|
Delete the first node whose value matches a predicate.
|
|
859
847
|
|
|
@@ -877,6 +865,30 @@ Time O(N), Space O(1)
|
|
|
877
865
|
|
|
878
866
|
***
|
|
879
867
|
|
|
868
|
+
### entries()
|
|
869
|
+
|
|
870
|
+
```ts
|
|
871
|
+
entries(): IterableIterator<[number, E]>;
|
|
872
|
+
```
|
|
873
|
+
|
|
874
|
+
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)
|
|
875
|
+
|
|
876
|
+
Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
877
|
+
|
|
878
|
+
#### Returns
|
|
879
|
+
|
|
880
|
+
`IterableIterator`\<\[`number`, `E`\]\>
|
|
881
|
+
|
|
882
|
+
#### Remarks
|
|
883
|
+
|
|
884
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
885
|
+
|
|
886
|
+
#### Inherited from
|
|
887
|
+
|
|
888
|
+
[`LinearLinkedBase`](LinearLinkedBase.md).[`entries`](LinearLinkedBase.md#entries)
|
|
889
|
+
|
|
890
|
+
***
|
|
891
|
+
|
|
880
892
|
### every()
|
|
881
893
|
|
|
882
894
|
```ts
|
|
@@ -926,7 +938,7 @@ fill(
|
|
|
926
938
|
end?): this;
|
|
927
939
|
```
|
|
928
940
|
|
|
929
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
941
|
+
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)
|
|
930
942
|
|
|
931
943
|
Fill a range with a value.
|
|
932
944
|
|
|
@@ -972,7 +984,7 @@ Time O(n), Space O(1)
|
|
|
972
984
|
filter(callback, thisArg?): this;
|
|
973
985
|
```
|
|
974
986
|
|
|
975
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
987
|
+
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)
|
|
976
988
|
|
|
977
989
|
Filter values into a new list of the same class.
|
|
978
990
|
|
|
@@ -996,8 +1008,6 @@ Value for `this` inside the callback.
|
|
|
996
1008
|
|
|
997
1009
|
A new list with kept values.
|
|
998
1010
|
|
|
999
|
-
*
|
|
1000
|
-
|
|
1001
1011
|
#### Remarks
|
|
1002
1012
|
|
|
1003
1013
|
Time O(N), Space O(N)
|
|
@@ -1123,7 +1133,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
|
1123
1133
|
findIndex(predicate, thisArg?): number;
|
|
1124
1134
|
```
|
|
1125
1135
|
|
|
1126
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1136
|
+
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)
|
|
1127
1137
|
|
|
1128
1138
|
Find the first index matching a predicate.
|
|
1129
1139
|
|
|
@@ -1203,7 +1213,7 @@ Time O(n), Space O(1).
|
|
|
1203
1213
|
getNode(elementNodeOrPredicate?): SinglyLinkedListNode<E> | undefined;
|
|
1204
1214
|
```
|
|
1205
1215
|
|
|
1206
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
1216
|
+
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)
|
|
1207
1217
|
|
|
1208
1218
|
Find a node by value, reference, or predicate.
|
|
1209
1219
|
|
|
@@ -1235,7 +1245,7 @@ Time O(N), Space O(1)
|
|
|
1235
1245
|
getNodeAt(index): SinglyLinkedListNode<E> | undefined;
|
|
1236
1246
|
```
|
|
1237
1247
|
|
|
1238
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
1248
|
+
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)
|
|
1239
1249
|
|
|
1240
1250
|
Get the node reference at a given index.
|
|
1241
1251
|
|
|
@@ -1253,8 +1263,6 @@ Zero-based index.
|
|
|
1253
1263
|
|
|
1254
1264
|
Node or undefined.
|
|
1255
1265
|
|
|
1256
|
-
*
|
|
1257
|
-
|
|
1258
1266
|
#### Remarks
|
|
1259
1267
|
|
|
1260
1268
|
Time O(N), Space O(1)
|
|
@@ -1279,7 +1287,7 @@ Time O(N), Space O(1)
|
|
|
1279
1287
|
has(element): boolean;
|
|
1280
1288
|
```
|
|
1281
1289
|
|
|
1282
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1290
|
+
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)
|
|
1283
1291
|
|
|
1284
1292
|
Checks whether a strictly-equal element exists in the structure.
|
|
1285
1293
|
|
|
@@ -1307,13 +1315,47 @@ Time O(n) in the worst case. Space O(1).
|
|
|
1307
1315
|
|
|
1308
1316
|
***
|
|
1309
1317
|
|
|
1318
|
+
### includes()
|
|
1319
|
+
|
|
1320
|
+
```ts
|
|
1321
|
+
includes(element): boolean;
|
|
1322
|
+
```
|
|
1323
|
+
|
|
1324
|
+
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)
|
|
1325
|
+
|
|
1326
|
+
Check whether a value exists (Array-compatible alias for `has`).
|
|
1327
|
+
|
|
1328
|
+
#### Parameters
|
|
1329
|
+
|
|
1330
|
+
##### element
|
|
1331
|
+
|
|
1332
|
+
`E`
|
|
1333
|
+
|
|
1334
|
+
Element to search for (uses `===`).
|
|
1335
|
+
|
|
1336
|
+
#### Returns
|
|
1337
|
+
|
|
1338
|
+
`boolean`
|
|
1339
|
+
|
|
1340
|
+
`true` if found.
|
|
1341
|
+
|
|
1342
|
+
#### Remarks
|
|
1343
|
+
|
|
1344
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
1345
|
+
|
|
1346
|
+
#### Inherited from
|
|
1347
|
+
|
|
1348
|
+
[`LinearLinkedBase`](LinearLinkedBase.md).[`includes`](LinearLinkedBase.md#includes)
|
|
1349
|
+
|
|
1350
|
+
***
|
|
1351
|
+
|
|
1310
1352
|
### indexOf()
|
|
1311
1353
|
|
|
1312
1354
|
```ts
|
|
1313
1355
|
indexOf(searchElement, fromIndex?): number;
|
|
1314
1356
|
```
|
|
1315
1357
|
|
|
1316
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1358
|
+
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)
|
|
1317
1359
|
|
|
1318
1360
|
Linked-list optimized `indexOf` (forwards scan).
|
|
1319
1361
|
|
|
@@ -1353,7 +1395,7 @@ Time O(n), Space O(1)
|
|
|
1353
1395
|
isEmpty(): boolean;
|
|
1354
1396
|
```
|
|
1355
1397
|
|
|
1356
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
1398
|
+
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)
|
|
1357
1399
|
|
|
1358
1400
|
Check whether the list is empty.
|
|
1359
1401
|
|
|
@@ -1363,8 +1405,6 @@ Check whether the list is empty.
|
|
|
1363
1405
|
|
|
1364
1406
|
True if length is 0.
|
|
1365
1407
|
|
|
1366
|
-
*
|
|
1367
|
-
|
|
1368
1408
|
#### Remarks
|
|
1369
1409
|
|
|
1370
1410
|
Time O(1), Space O(1)
|
|
@@ -1388,7 +1428,7 @@ Time O(1), Space O(1)
|
|
|
1388
1428
|
isNode(elementNodeOrPredicate): elementNodeOrPredicate is SinglyLinkedListNode<E>;
|
|
1389
1429
|
```
|
|
1390
1430
|
|
|
1391
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
1431
|
+
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)
|
|
1392
1432
|
|
|
1393
1433
|
Type guard: check whether the input is a SinglyLinkedListNode.
|
|
1394
1434
|
|
|
@@ -1420,7 +1460,7 @@ Time O(1), Space O(1)
|
|
|
1420
1460
|
join(separator?): string;
|
|
1421
1461
|
```
|
|
1422
1462
|
|
|
1423
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1463
|
+
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)
|
|
1424
1464
|
|
|
1425
1465
|
Join all elements into a string.
|
|
1426
1466
|
|
|
@@ -1448,13 +1488,37 @@ Time O(n), Space O(n)
|
|
|
1448
1488
|
|
|
1449
1489
|
***
|
|
1450
1490
|
|
|
1491
|
+
### keys()
|
|
1492
|
+
|
|
1493
|
+
```ts
|
|
1494
|
+
keys(): IterableIterator<number>;
|
|
1495
|
+
```
|
|
1496
|
+
|
|
1497
|
+
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)
|
|
1498
|
+
|
|
1499
|
+
Return an iterator of numeric indices (Array-compatible).
|
|
1500
|
+
|
|
1501
|
+
#### Returns
|
|
1502
|
+
|
|
1503
|
+
`IterableIterator`\<`number`\>
|
|
1504
|
+
|
|
1505
|
+
#### Remarks
|
|
1506
|
+
|
|
1507
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
1508
|
+
|
|
1509
|
+
#### Inherited from
|
|
1510
|
+
|
|
1511
|
+
[`LinearLinkedBase`](LinearLinkedBase.md).[`keys`](LinearLinkedBase.md#keys)
|
|
1512
|
+
|
|
1513
|
+
***
|
|
1514
|
+
|
|
1451
1515
|
### lastIndexOf()
|
|
1452
1516
|
|
|
1453
1517
|
```ts
|
|
1454
1518
|
lastIndexOf(searchElement, fromIndex?): number;
|
|
1455
1519
|
```
|
|
1456
1520
|
|
|
1457
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1521
|
+
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)
|
|
1458
1522
|
|
|
1459
1523
|
Linked-list optimized `lastIndexOf` (reverse scan).
|
|
1460
1524
|
|
|
@@ -1497,7 +1561,7 @@ map<EM, RM>(
|
|
|
1497
1561
|
thisArg?): SinglyLinkedList<EM, RM>;
|
|
1498
1562
|
```
|
|
1499
1563
|
|
|
1500
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
1564
|
+
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)
|
|
1501
1565
|
|
|
1502
1566
|
Map values into a new list (possibly different element type).
|
|
1503
1567
|
|
|
@@ -1537,8 +1601,6 @@ Value for `this` inside the callback.
|
|
|
1537
1601
|
|
|
1538
1602
|
A new SinglyLinkedList with mapped values.
|
|
1539
1603
|
|
|
1540
|
-
*
|
|
1541
|
-
|
|
1542
1604
|
#### Remarks
|
|
1543
1605
|
|
|
1544
1606
|
Time O(N), Space O(N)
|
|
@@ -1564,7 +1626,7 @@ Time O(N), Space O(N)
|
|
|
1564
1626
|
mapSame(callback, thisArg?): this;
|
|
1565
1627
|
```
|
|
1566
1628
|
|
|
1567
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
1629
|
+
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)
|
|
1568
1630
|
|
|
1569
1631
|
Map values into a new list of the same class.
|
|
1570
1632
|
|
|
@@ -1604,7 +1666,7 @@ Time O(N), Space O(N)
|
|
|
1604
1666
|
pop(): E | undefined;
|
|
1605
1667
|
```
|
|
1606
1668
|
|
|
1607
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
1669
|
+
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)
|
|
1608
1670
|
|
|
1609
1671
|
Remove and return the tail element.
|
|
1610
1672
|
|
|
@@ -1614,8 +1676,6 @@ Remove and return the tail element.
|
|
|
1614
1676
|
|
|
1615
1677
|
Removed element or undefined.
|
|
1616
1678
|
|
|
1617
|
-
*
|
|
1618
|
-
|
|
1619
1679
|
#### Remarks
|
|
1620
1680
|
|
|
1621
1681
|
Time O(N), Space O(1)
|
|
@@ -1647,7 +1707,7 @@ Time O(N), Space O(1)
|
|
|
1647
1707
|
print(): void;
|
|
1648
1708
|
```
|
|
1649
1709
|
|
|
1650
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1710
|
+
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)
|
|
1651
1711
|
|
|
1652
1712
|
Prints `toVisual()` to the console. Intended for quick debugging.
|
|
1653
1713
|
|
|
@@ -1673,7 +1733,7 @@ Time O(n) due to materialization, Space O(n) for the intermediate representation
|
|
|
1673
1733
|
push(elementOrNode): boolean;
|
|
1674
1734
|
```
|
|
1675
1735
|
|
|
1676
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
1736
|
+
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)
|
|
1677
1737
|
|
|
1678
1738
|
Append an element/node to the tail.
|
|
1679
1739
|
|
|
@@ -1691,8 +1751,6 @@ Element or node to append.
|
|
|
1691
1751
|
|
|
1692
1752
|
True when appended.
|
|
1693
1753
|
|
|
1694
|
-
*
|
|
1695
|
-
|
|
1696
1754
|
#### Remarks
|
|
1697
1755
|
|
|
1698
1756
|
Time O(1), Space O(1)
|
|
@@ -1728,7 +1786,7 @@ Time O(1), Space O(1)
|
|
|
1728
1786
|
pushMany(elements): boolean[];
|
|
1729
1787
|
```
|
|
1730
1788
|
|
|
1731
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
1789
|
+
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)
|
|
1732
1790
|
|
|
1733
1791
|
Append a sequence of elements/nodes.
|
|
1734
1792
|
|
|
@@ -1796,7 +1854,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
|
|
|
1796
1854
|
reduce(callbackfn): E;
|
|
1797
1855
|
```
|
|
1798
1856
|
|
|
1799
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1857
|
+
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)
|
|
1800
1858
|
|
|
1801
1859
|
##### Parameters
|
|
1802
1860
|
|
|
@@ -1818,7 +1876,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
|
|
|
1818
1876
|
reduce(callbackfn, initialValue): E;
|
|
1819
1877
|
```
|
|
1820
1878
|
|
|
1821
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1879
|
+
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)
|
|
1822
1880
|
|
|
1823
1881
|
##### Parameters
|
|
1824
1882
|
|
|
@@ -1844,7 +1902,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
|
|
|
1844
1902
|
reduce<U>(callbackfn, initialValue): U;
|
|
1845
1903
|
```
|
|
1846
1904
|
|
|
1847
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1905
|
+
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)
|
|
1848
1906
|
|
|
1849
1907
|
##### Type Parameters
|
|
1850
1908
|
|
|
@@ -1878,7 +1936,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.c
|
|
|
1878
1936
|
reduceRight<U>(callbackfn, initialValue): U;
|
|
1879
1937
|
```
|
|
1880
1938
|
|
|
1881
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1939
|
+
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)
|
|
1882
1940
|
|
|
1883
1941
|
Right-to-left reduction using reverse iterator.
|
|
1884
1942
|
|
|
@@ -1924,7 +1982,7 @@ Time O(n), Space O(1)
|
|
|
1924
1982
|
reverse(): this;
|
|
1925
1983
|
```
|
|
1926
1984
|
|
|
1927
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
1985
|
+
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)
|
|
1928
1986
|
|
|
1929
1987
|
Reverse the list in place.
|
|
1930
1988
|
|
|
@@ -1934,8 +1992,6 @@ Reverse the list in place.
|
|
|
1934
1992
|
|
|
1935
1993
|
This list.
|
|
1936
1994
|
|
|
1937
|
-
*
|
|
1938
|
-
|
|
1939
1995
|
#### Remarks
|
|
1940
1996
|
|
|
1941
1997
|
Time O(N), Space O(1)
|
|
@@ -1961,7 +2017,7 @@ Time O(N), Space O(1)
|
|
|
1961
2017
|
search(elementNodeOrPredicate): E | undefined;
|
|
1962
2018
|
```
|
|
1963
2019
|
|
|
1964
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2020
|
+
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)
|
|
1965
2021
|
|
|
1966
2022
|
Find the first value matching a predicate (by node).
|
|
1967
2023
|
|
|
@@ -1993,7 +2049,7 @@ Time O(N), Space O(1)
|
|
|
1993
2049
|
setAt(index, value): boolean;
|
|
1994
2050
|
```
|
|
1995
2051
|
|
|
1996
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2052
|
+
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)
|
|
1997
2053
|
|
|
1998
2054
|
Set the element value at an index.
|
|
1999
2055
|
|
|
@@ -2033,7 +2089,7 @@ Time O(N), Space O(1)
|
|
|
2033
2089
|
setEquality(equals): this;
|
|
2034
2090
|
```
|
|
2035
2091
|
|
|
2036
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2092
|
+
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)
|
|
2037
2093
|
|
|
2038
2094
|
Set the equality comparator used to compare values.
|
|
2039
2095
|
|
|
@@ -2063,7 +2119,7 @@ Time O(1), Space O(1)
|
|
|
2063
2119
|
shift(): E | undefined;
|
|
2064
2120
|
```
|
|
2065
2121
|
|
|
2066
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2122
|
+
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)
|
|
2067
2123
|
|
|
2068
2124
|
Remove and return the head element.
|
|
2069
2125
|
|
|
@@ -2073,8 +2129,6 @@ Remove and return the head element.
|
|
|
2073
2129
|
|
|
2074
2130
|
Removed element or undefined.
|
|
2075
2131
|
|
|
2076
|
-
*
|
|
2077
|
-
|
|
2078
2132
|
#### Remarks
|
|
2079
2133
|
|
|
2080
2134
|
Time O(1), Space O(1)
|
|
@@ -2096,7 +2150,7 @@ Time O(1), Space O(1)
|
|
|
2096
2150
|
slice(start?, end?): this;
|
|
2097
2151
|
```
|
|
2098
2152
|
|
|
2099
|
-
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)
|
|
2100
2154
|
|
|
2101
2155
|
Slice via forward iteration (no random access required).
|
|
2102
2156
|
|
|
@@ -2176,7 +2230,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
|
|
|
2176
2230
|
sort(compareFn?): this;
|
|
2177
2231
|
```
|
|
2178
2232
|
|
|
2179
|
-
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)
|
|
2180
2234
|
|
|
2181
2235
|
In-place stable order via array sort semantics.
|
|
2182
2236
|
|
|
@@ -2213,7 +2267,7 @@ splice(
|
|
|
2213
2267
|
items?): this;
|
|
2214
2268
|
```
|
|
2215
2269
|
|
|
2216
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2270
|
+
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)
|
|
2217
2271
|
|
|
2218
2272
|
Remove and/or insert elements at a position (array-like behavior).
|
|
2219
2273
|
|
|
@@ -2259,7 +2313,7 @@ Time O(N + M), Space O(M)
|
|
|
2259
2313
|
toArray(): E[];
|
|
2260
2314
|
```
|
|
2261
2315
|
|
|
2262
|
-
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)
|
|
2263
2317
|
|
|
2264
2318
|
Materializes the elements into a new array.
|
|
2265
2319
|
|
|
@@ -2279,13 +2333,39 @@ Time O(n), Space O(n).
|
|
|
2279
2333
|
|
|
2280
2334
|
***
|
|
2281
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
|
+
|
|
2282
2362
|
### toReversedArray()
|
|
2283
2363
|
|
|
2284
2364
|
```ts
|
|
2285
2365
|
toReversedArray(): E[];
|
|
2286
2366
|
```
|
|
2287
2367
|
|
|
2288
|
-
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)
|
|
2289
2369
|
|
|
2290
2370
|
Snapshot elements into a reversed array.
|
|
2291
2371
|
|
|
@@ -2311,7 +2391,7 @@ Time O(n), Space O(n)
|
|
|
2311
2391
|
toVisual(): E[];
|
|
2312
2392
|
```
|
|
2313
2393
|
|
|
2314
|
-
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)
|
|
2315
2395
|
|
|
2316
2396
|
Returns a representation of the structure suitable for quick visualization.
|
|
2317
2397
|
Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
@@ -2338,7 +2418,7 @@ Time O(n), Space O(n).
|
|
|
2338
2418
|
unshift(elementOrNode): boolean;
|
|
2339
2419
|
```
|
|
2340
2420
|
|
|
2341
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2421
|
+
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)
|
|
2342
2422
|
|
|
2343
2423
|
Prepend an element/node to the head.
|
|
2344
2424
|
|
|
@@ -2356,8 +2436,6 @@ Element or node to prepend.
|
|
|
2356
2436
|
|
|
2357
2437
|
True when prepended.
|
|
2358
2438
|
|
|
2359
|
-
*
|
|
2360
|
-
|
|
2361
2439
|
#### Remarks
|
|
2362
2440
|
|
|
2363
2441
|
Time O(1), Space O(1)
|
|
@@ -2394,7 +2472,7 @@ Time O(1), Space O(1)
|
|
|
2394
2472
|
unshiftMany(elements): boolean[];
|
|
2395
2473
|
```
|
|
2396
2474
|
|
|
2397
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2475
|
+
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)
|
|
2398
2476
|
|
|
2399
2477
|
Prepend a sequence of elements/nodes.
|
|
2400
2478
|
|
|
@@ -2455,7 +2533,7 @@ static from<E, R, S>(
|
|
|
2455
2533
|
options?): S;
|
|
2456
2534
|
```
|
|
2457
2535
|
|
|
2458
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2536
|
+
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)
|
|
2459
2537
|
|
|
2460
2538
|
Create a new list from an iterable of elements.
|
|
2461
2539
|
|
|
@@ -2544,7 +2622,7 @@ Time O(1), Space O(1).
|
|
|
2544
2622
|
protected _createInstance(options?): this;
|
|
2545
2623
|
```
|
|
2546
2624
|
|
|
2547
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2625
|
+
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)
|
|
2548
2626
|
|
|
2549
2627
|
(Protected) Create an empty instance of the same concrete class.
|
|
2550
2628
|
|
|
@@ -2578,7 +2656,7 @@ Time O(1), Space O(1)
|
|
|
2578
2656
|
protected _createLike<EM, RM>(elements?, options?): SinglyLinkedList<EM, RM>;
|
|
2579
2657
|
```
|
|
2580
2658
|
|
|
2581
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2659
|
+
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)
|
|
2582
2660
|
|
|
2583
2661
|
(Protected) Create a like-kind instance and seed it from an iterable.
|
|
2584
2662
|
|
|
@@ -2626,7 +2704,7 @@ Time O(N), Space O(N)
|
|
|
2626
2704
|
protected _ensureNode(elementOrNode): SinglyLinkedListNode<E>;
|
|
2627
2705
|
```
|
|
2628
2706
|
|
|
2629
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2707
|
+
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)
|
|
2630
2708
|
|
|
2631
2709
|
(Protected) Normalize input into a node instance.
|
|
2632
2710
|
|
|
@@ -2656,7 +2734,7 @@ Time O(1), Space O(1)
|
|
|
2656
2734
|
protected _ensurePredicate(elementNodeOrPredicate): (node) => boolean;
|
|
2657
2735
|
```
|
|
2658
2736
|
|
|
2659
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2737
|
+
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)
|
|
2660
2738
|
|
|
2661
2739
|
(Protected) Normalize input into a node predicate.
|
|
2662
2740
|
|
|
@@ -2688,7 +2766,7 @@ Time O(1), Space O(1)
|
|
|
2688
2766
|
protected _getIterator(): IterableIterator<E>;
|
|
2689
2767
|
```
|
|
2690
2768
|
|
|
2691
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2769
|
+
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)
|
|
2692
2770
|
|
|
2693
2771
|
(Protected) Iterate values from head to tail.
|
|
2694
2772
|
|
|
@@ -2714,7 +2792,7 @@ Time O(N), Space O(1)
|
|
|
2714
2792
|
protected _getNodeIterator(): IterableIterator<SinglyLinkedListNode<E>>;
|
|
2715
2793
|
```
|
|
2716
2794
|
|
|
2717
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2795
|
+
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)
|
|
2718
2796
|
|
|
2719
2797
|
(Protected) Iterate nodes from head to tail.
|
|
2720
2798
|
|
|
@@ -2740,7 +2818,7 @@ Time O(N), Space O(1)
|
|
|
2740
2818
|
protected _getPrevNode(node): SinglyLinkedListNode<E> | undefined;
|
|
2741
2819
|
```
|
|
2742
2820
|
|
|
2743
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2821
|
+
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)
|
|
2744
2822
|
|
|
2745
2823
|
(Protected) Get the previous node of a given node.
|
|
2746
2824
|
|
|
@@ -2774,7 +2852,7 @@ Time O(N), Space O(1)
|
|
|
2774
2852
|
protected _getReverseIterator(): IterableIterator<E>;
|
|
2775
2853
|
```
|
|
2776
2854
|
|
|
2777
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2855
|
+
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)
|
|
2778
2856
|
|
|
2779
2857
|
(Protected) Iterate values from tail to head.
|
|
2780
2858
|
|
|
@@ -2800,7 +2878,7 @@ Time O(N), Space O(N)
|
|
|
2800
2878
|
protected _isPredicate(elementNodeOrPredicate): elementNodeOrPredicate is (node: SinglyLinkedListNode<E>) => boolean;
|
|
2801
2879
|
```
|
|
2802
2880
|
|
|
2803
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2881
|
+
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)
|
|
2804
2882
|
|
|
2805
2883
|
(Protected) Check if input is a node predicate function.
|
|
2806
2884
|
|
|
@@ -2832,7 +2910,7 @@ Time O(1), Space O(1)
|
|
|
2832
2910
|
protected _spawnLike<EM, RM>(options?): SinglyLinkedList<EM, RM>;
|
|
2833
2911
|
```
|
|
2834
2912
|
|
|
2835
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2913
|
+
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)
|
|
2836
2914
|
|
|
2837
2915
|
(Protected) Spawn an empty like-kind list instance.
|
|
2838
2916
|
|
|
@@ -2872,7 +2950,7 @@ Time O(1), Space O(1)
|
|
|
2872
2950
|
protected createNode(value): SinglyLinkedListNode<E>;
|
|
2873
2951
|
```
|
|
2874
2952
|
|
|
2875
|
-
Defined in: [data-structures/linked-list/singly-linked-list.ts:
|
|
2953
|
+
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)
|
|
2876
2954
|
|
|
2877
2955
|
(Protected) Create a node from a value.
|
|
2878
2956
|
|