data-structure-typed 2.5.0 → 2.5.1
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/.vitepress/cache/deps_temp_51f5f1b0/chunk-7OIKW5WK.js +12984 -0
- package/.vitepress/cache/deps_temp_51f5f1b0/package.json +3 -0
- package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vue_devtools-api.js +4505 -0
- package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vueuse_core.js +9731 -0
- package/.vitepress/cache/deps_temp_51f5f1b0/vue.js +347 -0
- package/CHANGELOG.md +3 -1
- package/README.md +63 -26
- package/dist/cjs/binary-tree.cjs +23698 -0
- package/dist/cjs/graph.cjs +5236 -0
- package/dist/cjs/hash.cjs +1262 -0
- package/dist/cjs/heap.cjs +1540 -0
- package/dist/cjs/index.cjs +28244 -14795
- package/dist/cjs/linked-list.cjs +4370 -0
- package/dist/cjs/matrix.cjs +1042 -0
- package/dist/cjs/priority-queue.cjs +1314 -0
- package/dist/cjs/queue.cjs +4090 -0
- package/dist/cjs/stack.cjs +861 -0
- package/dist/cjs/trie.cjs +1173 -0
- package/dist/cjs-legacy/binary-tree.cjs +23730 -0
- package/dist/cjs-legacy/graph.cjs +5234 -0
- package/dist/cjs-legacy/hash.cjs +1262 -0
- package/dist/cjs-legacy/heap.cjs +1537 -0
- package/dist/cjs-legacy/index.cjs +28239 -14790
- package/dist/cjs-legacy/linked-list.cjs +4376 -0
- package/dist/cjs-legacy/matrix.cjs +1045 -0
- package/dist/cjs-legacy/priority-queue.cjs +1312 -0
- package/dist/cjs-legacy/queue.cjs +4088 -0
- package/dist/cjs-legacy/stack.cjs +861 -0
- package/dist/cjs-legacy/trie.cjs +1172 -0
- package/dist/esm/binary-tree.mjs +23683 -0
- package/dist/esm/graph.mjs +5223 -0
- package/dist/esm/hash.mjs +1259 -0
- package/dist/esm/heap.mjs +1534 -0
- package/dist/esm/index.mjs +28242 -14796
- package/dist/esm/linked-list.mjs +4363 -0
- package/dist/esm/matrix.mjs +1038 -0
- package/dist/esm/priority-queue.mjs +1310 -0
- package/dist/esm/queue.mjs +4086 -0
- package/dist/esm/stack.mjs +859 -0
- package/dist/esm/trie.mjs +1170 -0
- package/dist/esm-legacy/binary-tree.mjs +23715 -0
- package/dist/esm-legacy/graph.mjs +5221 -0
- package/dist/esm-legacy/hash.mjs +1259 -0
- package/dist/esm-legacy/heap.mjs +1531 -0
- package/dist/esm-legacy/index.mjs +28237 -14791
- package/dist/esm-legacy/linked-list.mjs +4369 -0
- package/dist/esm-legacy/matrix.mjs +1041 -0
- package/dist/esm-legacy/priority-queue.mjs +1308 -0
- package/dist/esm-legacy/queue.mjs +4084 -0
- package/dist/esm-legacy/stack.mjs +859 -0
- package/dist/esm-legacy/trie.mjs +1169 -0
- package/dist/types/data-structures/base/index.d.ts +1 -0
- package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
- package/dist/types/data-structures/base/linear-base.d.ts +3 -3
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +240 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +280 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +502 -2
- package/dist/types/data-structures/binary-tree/bst.d.ts +481 -1
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +380 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +120 -1
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +2764 -384
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +2753 -353
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2241 -321
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +2554 -274
- package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
- package/dist/types/data-structures/graph/directed-graph.d.ts +200 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +180 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +230 -10
- package/dist/types/data-structures/heap/heap.d.ts +280 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +343 -3
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +303 -3
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +362 -2
- package/dist/types/data-structures/matrix/matrix.d.ts +160 -0
- package/dist/types/data-structures/queue/deque.d.ts +304 -4
- package/dist/types/data-structures/queue/queue.d.ts +240 -0
- package/dist/types/data-structures/stack/stack.d.ts +200 -0
- package/dist/types/data-structures/trie/trie.d.ts +244 -4
- package/dist/types/interfaces/graph.d.ts +1 -1
- package/dist/types/types/common.d.ts +2 -2
- package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
- package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
- package/dist/types/types/utils/validate-type.d.ts +4 -4
- package/dist/umd/data-structure-typed.js +28022 -14573
- package/dist/umd/data-structure-typed.min.js +9 -3
- package/docs-site-docusaurus/README.md +41 -0
- package/docs-site-docusaurus/docs/api/README.md +52 -0
- package/docs-site-docusaurus/docs/api/classes/AVLTree.md +6130 -0
- package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +282 -0
- package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +2266 -0
- package/docs-site-docusaurus/docs/api/classes/BST.md +5831 -0
- package/docs-site-docusaurus/docs/api/classes/BSTNode.md +333 -0
- package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +455 -0
- package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +4647 -0
- package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +331 -0
- package/docs-site-docusaurus/docs/api/classes/Deque.md +2767 -0
- package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +2999 -0
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +2685 -0
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +221 -0
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +253 -0
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +21 -0
- package/docs-site-docusaurus/docs/api/classes/HashMap.md +1333 -0
- package/docs-site-docusaurus/docs/api/classes/Heap.md +1881 -0
- package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +800 -0
- package/docs-site-docusaurus/docs/api/classes/IterableEntryBase.md +644 -0
- package/docs-site-docusaurus/docs/api/classes/LinearBase.md +1632 -0
- package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +1853 -0
- package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +1108 -0
- package/docs-site-docusaurus/docs/api/classes/LinkedListNode.md +156 -0
- package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +2824 -0
- package/docs-site-docusaurus/docs/api/classes/MapGraph.md +2929 -0
- package/docs-site-docusaurus/docs/api/classes/Matrix.md +1026 -0
- package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +1866 -0
- package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +1883 -0
- package/docs-site-docusaurus/docs/api/classes/MinHeap.md +1879 -0
- package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +1882 -0
- package/docs-site-docusaurus/docs/api/classes/Navigator.md +109 -0
- package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +1839 -0
- package/docs-site-docusaurus/docs/api/classes/Queue.md +2244 -0
- package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +6374 -0
- package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +372 -0
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +2897 -0
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +169 -0
- package/docs-site-docusaurus/docs/api/classes/SkipList.md +1229 -0
- package/docs-site-docusaurus/docs/api/classes/Stack.md +1573 -0
- package/docs-site-docusaurus/docs/api/classes/TreeMap.md +1257 -0
- package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +1475 -0
- package/docs-site-docusaurus/docs/api/classes/TreeSet.md +1117 -0
- package/docs-site-docusaurus/docs/api/classes/Trie.md +1708 -0
- package/docs-site-docusaurus/docs/api/classes/TrieNode.md +199 -0
- package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +2979 -0
- package/docs-site-docusaurus/docs/guide/_category_.json +6 -0
- package/docs-site-docusaurus/docs/guide/architecture.md +613 -0
- package/docs-site-docusaurus/docs/guide/concepts.md +420 -0
- package/docs-site-docusaurus/docs/guide/guides.md +611 -0
- package/docs-site-docusaurus/docs/guide/installation.md +60 -0
- package/docs-site-docusaurus/docs/guide/integrations.md +823 -0
- package/docs-site-docusaurus/docs/guide/overview.md +638 -0
- package/docs-site-docusaurus/docs/guide/performance.md +833 -0
- package/docs-site-docusaurus/docs/guide/quick-start.md +73 -0
- package/docs-site-docusaurus/docusaurus.config.ts +159 -0
- package/docs-site-docusaurus/fix-mdx-generics.mjs +75 -0
- package/docs-site-docusaurus/package-lock.json +18667 -0
- package/docs-site-docusaurus/package.json +50 -0
- package/docs-site-docusaurus/prefix-class-to-methods.mjs +48 -0
- package/docs-site-docusaurus/sidebars.ts +23 -0
- package/docs-site-docusaurus/sort-protected.mjs +87 -0
- package/docs-site-docusaurus/src/css/custom.css +96 -0
- package/docs-site-docusaurus/src/pages/index.module.css +13 -0
- package/docs-site-docusaurus/src/pages/index.tsx +71 -0
- package/docs-site-docusaurus/src/pages/markdown-page.md +7 -0
- package/docs-site-docusaurus/src/theme/TOCItems/index.tsx +34 -0
- package/docs-site-docusaurus/static/.nojekyll +0 -0
- package/docs-site-docusaurus/static/img/docusaurus-social-card.jpg +0 -0
- package/docs-site-docusaurus/static/img/docusaurus.png +0 -0
- package/docs-site-docusaurus/static/img/favicon.ico +0 -0
- package/docs-site-docusaurus/static/img/favicon.png +0 -0
- package/docs-site-docusaurus/static/img/logo-180.png +0 -0
- package/docs-site-docusaurus/static/img/logo.jpg +0 -0
- package/docs-site-docusaurus/static/img/logo.png +0 -0
- package/docs-site-docusaurus/static/img/logo.svg +1 -0
- package/docs-site-docusaurus/static/img/og-image.png +0 -0
- package/docs-site-docusaurus/static/img/undraw_docusaurus_mountain.svg +171 -0
- package/docs-site-docusaurus/static/img/undraw_docusaurus_react.svg +170 -0
- package/docs-site-docusaurus/static/img/undraw_docusaurus_tree.svg +40 -0
- package/docs-site-docusaurus/static/robots.txt +4 -0
- package/docs-site-docusaurus/typedoc.json +23 -0
- package/package.json +106 -10
- package/src/data-structures/base/index.ts +1 -0
- package/src/data-structures/base/iterable-entry-base.ts +8 -8
- package/src/data-structures/base/linear-base.ts +3 -3
- package/src/data-structures/binary-tree/avl-tree.ts +240 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +281 -1
- package/src/data-structures/binary-tree/binary-tree.ts +502 -2
- package/src/data-structures/binary-tree/bst.ts +481 -1
- package/src/data-structures/binary-tree/red-black-tree.ts +380 -0
- package/src/data-structures/binary-tree/segment-tree.ts +121 -2
- package/src/data-structures/binary-tree/tree-map.ts +2862 -482
- package/src/data-structures/binary-tree/tree-multi-map.ts +2963 -563
- package/src/data-structures/binary-tree/tree-multi-set.ts +2399 -479
- package/src/data-structures/binary-tree/tree-set.ts +2685 -405
- package/src/data-structures/graph/abstract-graph.ts +4 -4
- package/src/data-structures/graph/directed-graph.ts +200 -0
- package/src/data-structures/graph/undirected-graph.ts +180 -0
- package/src/data-structures/hash/hash-map.ts +235 -15
- package/src/data-structures/heap/heap.ts +280 -0
- package/src/data-structures/linked-list/doubly-linked-list.ts +343 -3
- package/src/data-structures/linked-list/singly-linked-list.ts +303 -3
- package/src/data-structures/linked-list/skip-linked-list.ts +362 -2
- package/src/data-structures/matrix/matrix.ts +161 -1
- package/src/data-structures/queue/deque.ts +305 -5
- package/src/data-structures/queue/queue.ts +240 -0
- package/src/data-structures/stack/stack.ts +200 -0
- package/src/data-structures/trie/trie.ts +245 -5
- package/src/interfaces/graph.ts +1 -1
- package/src/types/common.ts +2 -2
- package/src/types/data-structures/heap/heap.ts +1 -0
- package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
- package/src/types/utils/validate-type.ts +4 -4
- package/vercel.json +6 -0
- package/dist/leetcode/avl-tree-counter.mjs +0 -2957
- package/dist/leetcode/avl-tree-multi-map.mjs +0 -2889
- package/dist/leetcode/avl-tree.mjs +0 -2720
- package/dist/leetcode/binary-tree.mjs +0 -1594
- package/dist/leetcode/bst.mjs +0 -2398
- package/dist/leetcode/deque.mjs +0 -683
- package/dist/leetcode/directed-graph.mjs +0 -1733
- package/dist/leetcode/doubly-linked-list.mjs +0 -709
- package/dist/leetcode/hash-map.mjs +0 -493
- package/dist/leetcode/heap.mjs +0 -542
- package/dist/leetcode/max-heap.mjs +0 -375
- package/dist/leetcode/max-priority-queue.mjs +0 -383
- package/dist/leetcode/min-heap.mjs +0 -363
- package/dist/leetcode/min-priority-queue.mjs +0 -371
- package/dist/leetcode/priority-queue.mjs +0 -363
- package/dist/leetcode/queue.mjs +0 -943
- package/dist/leetcode/red-black-tree.mjs +0 -2765
- package/dist/leetcode/singly-linked-list.mjs +0 -754
- package/dist/leetcode/stack.mjs +0 -217
- package/dist/leetcode/tree-counter.mjs +0 -3039
- package/dist/leetcode/tree-multi-map.mjs +0 -2913
- package/dist/leetcode/trie.mjs +0 -413
- package/dist/leetcode/undirected-graph.mjs +0 -1650
|
@@ -0,0 +1,2824 @@
|
|
|
1
|
+
[**data-structure-typed**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[data-structure-typed](../README.md) / LinkedListQueue
|
|
6
|
+
|
|
7
|
+
# Class: LinkedListQueue\<E, R\>
|
|
8
|
+
|
|
9
|
+
Defined in: [data-structures/queue/queue.ts:953](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/queue/queue.ts#L953)
|
|
10
|
+
|
|
11
|
+
Queue implemented over a singly linked list; preserves head/tail operations with linear scans for queries.
|
|
12
|
+
|
|
13
|
+
## Remarks
|
|
14
|
+
|
|
15
|
+
Time O(1), Space O(1)
|
|
16
|
+
|
|
17
|
+
## Example
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
examples will be generated by unit test
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Extends
|
|
24
|
+
|
|
25
|
+
- [`SinglyLinkedList`](SinglyLinkedList.md)\<`E`, `R`\>
|
|
26
|
+
|
|
27
|
+
## Type Parameters
|
|
28
|
+
|
|
29
|
+
### E
|
|
30
|
+
|
|
31
|
+
`E` = `any`
|
|
32
|
+
|
|
33
|
+
### R
|
|
34
|
+
|
|
35
|
+
`R` = `any`
|
|
36
|
+
|
|
37
|
+
## Constructors
|
|
38
|
+
|
|
39
|
+
### Constructor
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
new LinkedListQueue<E, R>(elements?, options?): LinkedListQueue<E, R>;
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:205](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L205)
|
|
46
|
+
|
|
47
|
+
Create a SinglyLinkedList and optionally bulk-insert elements.
|
|
48
|
+
|
|
49
|
+
#### Parameters
|
|
50
|
+
|
|
51
|
+
##### elements?
|
|
52
|
+
|
|
53
|
+
\| `Iterable`\<`E`, `any`, `any`\>
|
|
54
|
+
\| `Iterable`\<`R`, `any`, `any`\>
|
|
55
|
+
\| `Iterable`\<[`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\>, `any`, `any`\>
|
|
56
|
+
|
|
57
|
+
Iterable of elements or nodes (or raw records if toElementFn is provided).
|
|
58
|
+
|
|
59
|
+
##### options?
|
|
60
|
+
|
|
61
|
+
`SinglyLinkedListOptions`\<`E`, `R`\>
|
|
62
|
+
|
|
63
|
+
Options such as maxLen and toElementFn.
|
|
64
|
+
|
|
65
|
+
#### Returns
|
|
66
|
+
|
|
67
|
+
`LinkedListQueue`\<`E`, `R`\>
|
|
68
|
+
|
|
69
|
+
New SinglyLinkedList instance.
|
|
70
|
+
|
|
71
|
+
#### Remarks
|
|
72
|
+
|
|
73
|
+
Time O(N), Space O(N)
|
|
74
|
+
|
|
75
|
+
#### Inherited from
|
|
76
|
+
|
|
77
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`constructor`](SinglyLinkedList.md#constructor)
|
|
78
|
+
|
|
79
|
+
## Properties
|
|
80
|
+
|
|
81
|
+
### first
|
|
82
|
+
|
|
83
|
+
#### Get Signature
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
get first(): E | undefined;
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:255](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L255)
|
|
90
|
+
|
|
91
|
+
Get the first element value.
|
|
92
|
+
|
|
93
|
+
##### Remarks
|
|
94
|
+
|
|
95
|
+
Time O(1), Space O(1)
|
|
96
|
+
|
|
97
|
+
##### Returns
|
|
98
|
+
|
|
99
|
+
`E` \| `undefined`
|
|
100
|
+
|
|
101
|
+
First element or undefined.
|
|
102
|
+
|
|
103
|
+
#### Inherited from
|
|
104
|
+
|
|
105
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`first`](SinglyLinkedList.md#first)
|
|
106
|
+
|
|
107
|
+
***
|
|
108
|
+
|
|
109
|
+
### head
|
|
110
|
+
|
|
111
|
+
#### Get Signature
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
get head(): SinglyLinkedListNode<E> | undefined;
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:221](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L221)
|
|
118
|
+
|
|
119
|
+
Get the head node.
|
|
120
|
+
|
|
121
|
+
##### Remarks
|
|
122
|
+
|
|
123
|
+
Time O(1), Space O(1)
|
|
124
|
+
|
|
125
|
+
##### Returns
|
|
126
|
+
|
|
127
|
+
[`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\> \| `undefined`
|
|
128
|
+
|
|
129
|
+
Head node or undefined.
|
|
130
|
+
|
|
131
|
+
#### Inherited from
|
|
132
|
+
|
|
133
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`head`](SinglyLinkedList.md#head)
|
|
134
|
+
|
|
135
|
+
***
|
|
136
|
+
|
|
137
|
+
### last
|
|
138
|
+
|
|
139
|
+
#### Get Signature
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
get last(): E | undefined;
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:265](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L265)
|
|
146
|
+
|
|
147
|
+
Get the last element value.
|
|
148
|
+
|
|
149
|
+
##### Remarks
|
|
150
|
+
|
|
151
|
+
Time O(1), Space O(1)
|
|
152
|
+
|
|
153
|
+
##### Returns
|
|
154
|
+
|
|
155
|
+
`E` \| `undefined`
|
|
156
|
+
|
|
157
|
+
Last element or undefined.
|
|
158
|
+
|
|
159
|
+
#### Inherited from
|
|
160
|
+
|
|
161
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`last`](SinglyLinkedList.md#last)
|
|
162
|
+
|
|
163
|
+
***
|
|
164
|
+
|
|
165
|
+
### length
|
|
166
|
+
|
|
167
|
+
#### Get Signature
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
get length(): number;
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:245](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L245)
|
|
174
|
+
|
|
175
|
+
Get the number of elements.
|
|
176
|
+
|
|
177
|
+
##### Remarks
|
|
178
|
+
|
|
179
|
+
Time O(1), Space O(1)
|
|
180
|
+
|
|
181
|
+
##### Returns
|
|
182
|
+
|
|
183
|
+
`number`
|
|
184
|
+
|
|
185
|
+
Current length.
|
|
186
|
+
|
|
187
|
+
#### Inherited from
|
|
188
|
+
|
|
189
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`length`](SinglyLinkedList.md#length)
|
|
190
|
+
|
|
191
|
+
***
|
|
192
|
+
|
|
193
|
+
### maxLen
|
|
194
|
+
|
|
195
|
+
#### Get Signature
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
get maxLen(): number;
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Defined in: [data-structures/base/linear-base.ts:100](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L100)
|
|
202
|
+
|
|
203
|
+
Upper bound for length (if positive), or `-1` when unbounded.
|
|
204
|
+
|
|
205
|
+
##### Remarks
|
|
206
|
+
|
|
207
|
+
Time O(1), Space O(1)
|
|
208
|
+
|
|
209
|
+
##### Returns
|
|
210
|
+
|
|
211
|
+
`number`
|
|
212
|
+
|
|
213
|
+
Maximum allowed length.
|
|
214
|
+
|
|
215
|
+
#### Inherited from
|
|
216
|
+
|
|
217
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`maxLen`](SinglyLinkedList.md#maxlen)
|
|
218
|
+
|
|
219
|
+
***
|
|
220
|
+
|
|
221
|
+
### tail
|
|
222
|
+
|
|
223
|
+
#### Get Signature
|
|
224
|
+
|
|
225
|
+
```ts
|
|
226
|
+
get tail(): SinglyLinkedListNode<E> | undefined;
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:233](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L233)
|
|
230
|
+
|
|
231
|
+
Get the tail node.
|
|
232
|
+
|
|
233
|
+
##### Remarks
|
|
234
|
+
|
|
235
|
+
Time O(1), Space O(1)
|
|
236
|
+
|
|
237
|
+
##### Returns
|
|
238
|
+
|
|
239
|
+
[`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\> \| `undefined`
|
|
240
|
+
|
|
241
|
+
Tail node or undefined.
|
|
242
|
+
|
|
243
|
+
#### Inherited from
|
|
244
|
+
|
|
245
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`tail`](SinglyLinkedList.md#tail)
|
|
246
|
+
|
|
247
|
+
***
|
|
248
|
+
|
|
249
|
+
### toElementFn
|
|
250
|
+
|
|
251
|
+
#### Get Signature
|
|
252
|
+
|
|
253
|
+
```ts
|
|
254
|
+
get toElementFn(): ((rawElement) => E) | undefined;
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
Defined in: [data-structures/base/iterable-element-base.ts:47](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-element-base.ts#L47)
|
|
258
|
+
|
|
259
|
+
Exposes the current `toElementFn`, if configured.
|
|
260
|
+
|
|
261
|
+
##### Remarks
|
|
262
|
+
|
|
263
|
+
Time O(1), Space O(1).
|
|
264
|
+
|
|
265
|
+
##### Returns
|
|
266
|
+
|
|
267
|
+
((`rawElement`) => `E`) \| `undefined`
|
|
268
|
+
|
|
269
|
+
The converter function or `undefined` when not set.
|
|
270
|
+
|
|
271
|
+
#### Inherited from
|
|
272
|
+
|
|
273
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`toElementFn`](SinglyLinkedList.md#toelementfn)
|
|
274
|
+
|
|
275
|
+
## Methods
|
|
276
|
+
|
|
277
|
+
### \[iterator\]()
|
|
278
|
+
|
|
279
|
+
```ts
|
|
280
|
+
iterator: IterableIterator<E>;
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Defined in: [data-structures/base/iterable-element-base.ts:60](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-element-base.ts#L60)
|
|
284
|
+
|
|
285
|
+
Returns an iterator over the structure's elements.
|
|
286
|
+
|
|
287
|
+
#### Parameters
|
|
288
|
+
|
|
289
|
+
##### args
|
|
290
|
+
|
|
291
|
+
...`unknown`[]
|
|
292
|
+
|
|
293
|
+
Optional iterator arguments forwarded to the internal iterator.
|
|
294
|
+
|
|
295
|
+
#### Returns
|
|
296
|
+
|
|
297
|
+
`IterableIterator`\<`E`\>
|
|
298
|
+
|
|
299
|
+
An `IterableIterator<E>` that yields the elements in traversal order.
|
|
300
|
+
|
|
301
|
+
#### Remarks
|
|
302
|
+
|
|
303
|
+
Producing the iterator is O(1); consuming the entire iterator is Time O(n) with O(1) extra space.
|
|
304
|
+
|
|
305
|
+
#### Inherited from
|
|
306
|
+
|
|
307
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`[iterator]`](SinglyLinkedList.md#iterator)
|
|
308
|
+
|
|
309
|
+
***
|
|
310
|
+
|
|
311
|
+
### addAfter()
|
|
312
|
+
|
|
313
|
+
```ts
|
|
314
|
+
addAfter(existingElementOrNode, newElementOrNode): boolean;
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:1057](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L1057)
|
|
318
|
+
|
|
319
|
+
Insert a new element/node after an existing one.
|
|
320
|
+
|
|
321
|
+
#### Parameters
|
|
322
|
+
|
|
323
|
+
##### existingElementOrNode
|
|
324
|
+
|
|
325
|
+
`E` \| [`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\>
|
|
326
|
+
|
|
327
|
+
Existing element or node.
|
|
328
|
+
|
|
329
|
+
##### newElementOrNode
|
|
330
|
+
|
|
331
|
+
`E` \| [`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\>
|
|
332
|
+
|
|
333
|
+
Element or node to insert.
|
|
334
|
+
|
|
335
|
+
#### Returns
|
|
336
|
+
|
|
337
|
+
`boolean`
|
|
338
|
+
|
|
339
|
+
True if inserted.
|
|
340
|
+
|
|
341
|
+
#### Remarks
|
|
342
|
+
|
|
343
|
+
Time O(N), Space O(1)
|
|
344
|
+
|
|
345
|
+
#### Inherited from
|
|
346
|
+
|
|
347
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`addAfter`](SinglyLinkedList.md#addafter)
|
|
348
|
+
|
|
349
|
+
***
|
|
350
|
+
|
|
351
|
+
### addAt()
|
|
352
|
+
|
|
353
|
+
```ts
|
|
354
|
+
addAt(index, newElementOrNode): boolean;
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:835](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L835)
|
|
358
|
+
|
|
359
|
+
Insert a new element/node at an index, shifting following nodes.
|
|
360
|
+
|
|
361
|
+
#### Parameters
|
|
362
|
+
|
|
363
|
+
##### index
|
|
364
|
+
|
|
365
|
+
`number`
|
|
366
|
+
|
|
367
|
+
Zero-based index.
|
|
368
|
+
|
|
369
|
+
##### newElementOrNode
|
|
370
|
+
|
|
371
|
+
`E` \| [`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\>
|
|
372
|
+
|
|
373
|
+
Element or node to insert.
|
|
374
|
+
|
|
375
|
+
#### Returns
|
|
376
|
+
|
|
377
|
+
`boolean`
|
|
378
|
+
|
|
379
|
+
True if inserted.
|
|
380
|
+
|
|
381
|
+
*
|
|
382
|
+
|
|
383
|
+
#### Remarks
|
|
384
|
+
|
|
385
|
+
Time O(N), Space O(1)
|
|
386
|
+
|
|
387
|
+
#### Example
|
|
388
|
+
|
|
389
|
+
```ts
|
|
390
|
+
// Insert at index
|
|
391
|
+
const list = new SinglyLinkedList<number>([1, 3]);
|
|
392
|
+
list.addAt(1, 2);
|
|
393
|
+
console.log(list.toArray()); // [1, 2, 3];
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
#### Inherited from
|
|
397
|
+
|
|
398
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`addAt`](SinglyLinkedList.md#addat)
|
|
399
|
+
|
|
400
|
+
***
|
|
401
|
+
|
|
402
|
+
### addBefore()
|
|
403
|
+
|
|
404
|
+
```ts
|
|
405
|
+
addBefore(existingElementOrNode, newElementOrNode): boolean;
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:1027](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L1027)
|
|
409
|
+
|
|
410
|
+
Insert a new element/node before an existing one.
|
|
411
|
+
|
|
412
|
+
#### Parameters
|
|
413
|
+
|
|
414
|
+
##### existingElementOrNode
|
|
415
|
+
|
|
416
|
+
`E` \| [`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\>
|
|
417
|
+
|
|
418
|
+
Existing element or node.
|
|
419
|
+
|
|
420
|
+
##### newElementOrNode
|
|
421
|
+
|
|
422
|
+
`E` \| [`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\>
|
|
423
|
+
|
|
424
|
+
Element or node to insert.
|
|
425
|
+
|
|
426
|
+
#### Returns
|
|
427
|
+
|
|
428
|
+
`boolean`
|
|
429
|
+
|
|
430
|
+
True if inserted.
|
|
431
|
+
|
|
432
|
+
#### Remarks
|
|
433
|
+
|
|
434
|
+
Time O(N), Space O(1)
|
|
435
|
+
|
|
436
|
+
#### Inherited from
|
|
437
|
+
|
|
438
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`addBefore`](SinglyLinkedList.md#addbefore)
|
|
439
|
+
|
|
440
|
+
***
|
|
441
|
+
|
|
442
|
+
### at()
|
|
443
|
+
|
|
444
|
+
```ts
|
|
445
|
+
at(index): E | undefined;
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:631](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L631)
|
|
449
|
+
|
|
450
|
+
Get the element at a given index.
|
|
451
|
+
|
|
452
|
+
#### Parameters
|
|
453
|
+
|
|
454
|
+
##### index
|
|
455
|
+
|
|
456
|
+
`number`
|
|
457
|
+
|
|
458
|
+
Zero-based index.
|
|
459
|
+
|
|
460
|
+
#### Returns
|
|
461
|
+
|
|
462
|
+
`E` \| `undefined`
|
|
463
|
+
|
|
464
|
+
Element or undefined.
|
|
465
|
+
|
|
466
|
+
*
|
|
467
|
+
|
|
468
|
+
#### Remarks
|
|
469
|
+
|
|
470
|
+
Time O(N), Space O(1)
|
|
471
|
+
|
|
472
|
+
#### Example
|
|
473
|
+
|
|
474
|
+
```ts
|
|
475
|
+
// Access element by index
|
|
476
|
+
const list = new SinglyLinkedList<string>(['a', 'b', 'c', 'd']);
|
|
477
|
+
console.log(list.at(0)); // 'a';
|
|
478
|
+
console.log(list.at(2)); // 'c';
|
|
479
|
+
console.log(list.at(3)); // 'd';
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
#### Inherited from
|
|
483
|
+
|
|
484
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`at`](SinglyLinkedList.md#at)
|
|
485
|
+
|
|
486
|
+
***
|
|
487
|
+
|
|
488
|
+
### clear()
|
|
489
|
+
|
|
490
|
+
```ts
|
|
491
|
+
clear(): void;
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:938](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L938)
|
|
495
|
+
|
|
496
|
+
Remove all nodes and reset length.
|
|
497
|
+
|
|
498
|
+
#### Returns
|
|
499
|
+
|
|
500
|
+
`void`
|
|
501
|
+
|
|
502
|
+
void
|
|
503
|
+
|
|
504
|
+
*
|
|
505
|
+
|
|
506
|
+
#### Remarks
|
|
507
|
+
|
|
508
|
+
Time O(N), Space O(1)
|
|
509
|
+
|
|
510
|
+
#### Example
|
|
511
|
+
|
|
512
|
+
```ts
|
|
513
|
+
// Remove all
|
|
514
|
+
const list = new SinglyLinkedList<number>([1, 2, 3]);
|
|
515
|
+
list.clear();
|
|
516
|
+
console.log(list.isEmpty()); // true;
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
#### Inherited from
|
|
520
|
+
|
|
521
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`clear`](SinglyLinkedList.md#clear)
|
|
522
|
+
|
|
523
|
+
***
|
|
524
|
+
|
|
525
|
+
### clone()
|
|
526
|
+
|
|
527
|
+
```ts
|
|
528
|
+
clone(): this;
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
Defined in: [data-structures/queue/queue.ts:960](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/queue/queue.ts#L960)
|
|
532
|
+
|
|
533
|
+
Deep clone this linked-list-based queue.
|
|
534
|
+
|
|
535
|
+
#### Returns
|
|
536
|
+
|
|
537
|
+
`this`
|
|
538
|
+
|
|
539
|
+
A new queue with the same sequence of elements.
|
|
540
|
+
|
|
541
|
+
#### Remarks
|
|
542
|
+
|
|
543
|
+
Time O(N), Space O(N)
|
|
544
|
+
|
|
545
|
+
#### Overrides
|
|
546
|
+
|
|
547
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`clone`](SinglyLinkedList.md#clone)
|
|
548
|
+
|
|
549
|
+
***
|
|
550
|
+
|
|
551
|
+
### concat()
|
|
552
|
+
|
|
553
|
+
```ts
|
|
554
|
+
concat(...items): this;
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
Defined in: [data-structures/base/linear-base.ts:473](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L473)
|
|
558
|
+
|
|
559
|
+
Concatenate lists/elements preserving order.
|
|
560
|
+
|
|
561
|
+
#### Parameters
|
|
562
|
+
|
|
563
|
+
##### items
|
|
564
|
+
|
|
565
|
+
...(
|
|
566
|
+
\| `E`
|
|
567
|
+
\| [`LinearBase`](LinearBase.md)\<`E`, `R`, [`LinkedListNode`](LinkedListNode.md)\<`E`\>\>)[]
|
|
568
|
+
|
|
569
|
+
Elements or `LinearBase` instances.
|
|
570
|
+
|
|
571
|
+
#### Returns
|
|
572
|
+
|
|
573
|
+
`this`
|
|
574
|
+
|
|
575
|
+
New list with combined elements (`this` type).
|
|
576
|
+
|
|
577
|
+
#### Remarks
|
|
578
|
+
|
|
579
|
+
Time O(sum(length)), Space O(sum(length))
|
|
580
|
+
|
|
581
|
+
#### Inherited from
|
|
582
|
+
|
|
583
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`concat`](SinglyLinkedList.md#concat)
|
|
584
|
+
|
|
585
|
+
***
|
|
586
|
+
|
|
587
|
+
### countOccurrences()
|
|
588
|
+
|
|
589
|
+
```ts
|
|
590
|
+
countOccurrences(elementOrNode): number;
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:1133](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L1133)
|
|
594
|
+
|
|
595
|
+
Count how many nodes match a value/node/predicate.
|
|
596
|
+
|
|
597
|
+
#### Parameters
|
|
598
|
+
|
|
599
|
+
##### elementOrNode
|
|
600
|
+
|
|
601
|
+
\| `E`
|
|
602
|
+
\| [`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\>
|
|
603
|
+
\| ((`node`) => `boolean`)
|
|
604
|
+
|
|
605
|
+
Element, node, or node predicate to match.
|
|
606
|
+
|
|
607
|
+
#### Returns
|
|
608
|
+
|
|
609
|
+
`number`
|
|
610
|
+
|
|
611
|
+
Number of matches in the list.
|
|
612
|
+
|
|
613
|
+
#### Remarks
|
|
614
|
+
|
|
615
|
+
Time O(N), Space O(1)
|
|
616
|
+
|
|
617
|
+
#### Inherited from
|
|
618
|
+
|
|
619
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`countOccurrences`](SinglyLinkedList.md#countoccurrences)
|
|
620
|
+
|
|
621
|
+
***
|
|
622
|
+
|
|
623
|
+
### delete()
|
|
624
|
+
|
|
625
|
+
```ts
|
|
626
|
+
delete(elementOrNode?): boolean;
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:780](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L780)
|
|
630
|
+
|
|
631
|
+
Delete the first match by value/node.
|
|
632
|
+
|
|
633
|
+
#### Parameters
|
|
634
|
+
|
|
635
|
+
##### elementOrNode?
|
|
636
|
+
|
|
637
|
+
`E` \| [`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\>
|
|
638
|
+
|
|
639
|
+
Element or node to remove; if omitted/undefined, nothing happens.
|
|
640
|
+
|
|
641
|
+
#### Returns
|
|
642
|
+
|
|
643
|
+
`boolean`
|
|
644
|
+
|
|
645
|
+
True if removed.
|
|
646
|
+
|
|
647
|
+
*
|
|
648
|
+
|
|
649
|
+
#### Remarks
|
|
650
|
+
|
|
651
|
+
Time O(N), Space O(1)
|
|
652
|
+
|
|
653
|
+
#### Example
|
|
654
|
+
|
|
655
|
+
```ts
|
|
656
|
+
// Remove first occurrence
|
|
657
|
+
const list = new SinglyLinkedList<number>([1, 2, 3, 2]);
|
|
658
|
+
list.delete(2);
|
|
659
|
+
console.log(list.toArray()); // [1, 3, 2];
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
#### Inherited from
|
|
663
|
+
|
|
664
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`delete`](SinglyLinkedList.md#delete)
|
|
665
|
+
|
|
666
|
+
***
|
|
667
|
+
|
|
668
|
+
### deleteAt()
|
|
669
|
+
|
|
670
|
+
```ts
|
|
671
|
+
deleteAt(index): E | undefined;
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:731](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L731)
|
|
675
|
+
|
|
676
|
+
Delete the element at an index.
|
|
677
|
+
|
|
678
|
+
#### Parameters
|
|
679
|
+
|
|
680
|
+
##### index
|
|
681
|
+
|
|
682
|
+
`number`
|
|
683
|
+
|
|
684
|
+
Zero-based index.
|
|
685
|
+
|
|
686
|
+
#### Returns
|
|
687
|
+
|
|
688
|
+
`E` \| `undefined`
|
|
689
|
+
|
|
690
|
+
Removed element or undefined.
|
|
691
|
+
|
|
692
|
+
*
|
|
693
|
+
|
|
694
|
+
#### Remarks
|
|
695
|
+
|
|
696
|
+
Time O(N), Space O(1)
|
|
697
|
+
|
|
698
|
+
#### Example
|
|
699
|
+
|
|
700
|
+
```ts
|
|
701
|
+
// Remove by index
|
|
702
|
+
const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
|
|
703
|
+
list.deleteAt(1);
|
|
704
|
+
console.log(list.toArray()); // ['a', 'c'];
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
#### Inherited from
|
|
708
|
+
|
|
709
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`deleteAt`](SinglyLinkedList.md#deleteat)
|
|
710
|
+
|
|
711
|
+
***
|
|
712
|
+
|
|
713
|
+
### deleteWhere()
|
|
714
|
+
|
|
715
|
+
```ts
|
|
716
|
+
deleteWhere(predicate): boolean;
|
|
717
|
+
```
|
|
718
|
+
|
|
719
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:1163](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L1163)
|
|
720
|
+
|
|
721
|
+
Delete the first node whose value matches a predicate.
|
|
722
|
+
|
|
723
|
+
#### Parameters
|
|
724
|
+
|
|
725
|
+
##### predicate
|
|
726
|
+
|
|
727
|
+
(`value`, `index`, `list`) => `boolean`
|
|
728
|
+
|
|
729
|
+
Predicate (value, index, list) → boolean to decide deletion.
|
|
730
|
+
|
|
731
|
+
#### Returns
|
|
732
|
+
|
|
733
|
+
`boolean`
|
|
734
|
+
|
|
735
|
+
True if a node was removed.
|
|
736
|
+
|
|
737
|
+
#### Remarks
|
|
738
|
+
|
|
739
|
+
Time O(N), Space O(1)
|
|
740
|
+
|
|
741
|
+
#### Inherited from
|
|
742
|
+
|
|
743
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`deleteWhere`](SinglyLinkedList.md#deletewhere)
|
|
744
|
+
|
|
745
|
+
***
|
|
746
|
+
|
|
747
|
+
### every()
|
|
748
|
+
|
|
749
|
+
```ts
|
|
750
|
+
every(predicate, thisArg?): boolean;
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
Defined in: [data-structures/base/iterable-element-base.ts:86](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-element-base.ts#L86)
|
|
754
|
+
|
|
755
|
+
Tests whether all elements satisfy the predicate.
|
|
756
|
+
|
|
757
|
+
#### Parameters
|
|
758
|
+
|
|
759
|
+
##### predicate
|
|
760
|
+
|
|
761
|
+
`ElementCallback`\<`E`, `R`, `boolean`\>
|
|
762
|
+
|
|
763
|
+
Function invoked for each element with signature `(value, index, self)`.
|
|
764
|
+
|
|
765
|
+
##### thisArg?
|
|
766
|
+
|
|
767
|
+
`unknown`
|
|
768
|
+
|
|
769
|
+
Optional `this` binding for the predicate.
|
|
770
|
+
|
|
771
|
+
#### Returns
|
|
772
|
+
|
|
773
|
+
`boolean`
|
|
774
|
+
|
|
775
|
+
`true` if every element passes; otherwise `false`.
|
|
776
|
+
|
|
777
|
+
#### Remarks
|
|
778
|
+
|
|
779
|
+
Time O(n) in the worst case; may exit early when the first failure is found. Space O(1).
|
|
780
|
+
|
|
781
|
+
#### Inherited from
|
|
782
|
+
|
|
783
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`every`](SinglyLinkedList.md#every)
|
|
784
|
+
|
|
785
|
+
***
|
|
786
|
+
|
|
787
|
+
### fill()
|
|
788
|
+
|
|
789
|
+
```ts
|
|
790
|
+
fill(
|
|
791
|
+
value,
|
|
792
|
+
start?,
|
|
793
|
+
end?): this;
|
|
794
|
+
```
|
|
795
|
+
|
|
796
|
+
Defined in: [data-structures/base/linear-base.ts:292](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L292)
|
|
797
|
+
|
|
798
|
+
Fill a range with a value.
|
|
799
|
+
|
|
800
|
+
#### Parameters
|
|
801
|
+
|
|
802
|
+
##### value
|
|
803
|
+
|
|
804
|
+
`E`
|
|
805
|
+
|
|
806
|
+
Value to set.
|
|
807
|
+
|
|
808
|
+
##### start?
|
|
809
|
+
|
|
810
|
+
`number` = `0`
|
|
811
|
+
|
|
812
|
+
Inclusive start.
|
|
813
|
+
|
|
814
|
+
##### end?
|
|
815
|
+
|
|
816
|
+
`number` = `...`
|
|
817
|
+
|
|
818
|
+
Exclusive end.
|
|
819
|
+
|
|
820
|
+
#### Returns
|
|
821
|
+
|
|
822
|
+
`this`
|
|
823
|
+
|
|
824
|
+
This list.
|
|
825
|
+
|
|
826
|
+
#### Remarks
|
|
827
|
+
|
|
828
|
+
Time O(n), Space O(1)
|
|
829
|
+
|
|
830
|
+
#### Inherited from
|
|
831
|
+
|
|
832
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`fill`](SinglyLinkedList.md#fill)
|
|
833
|
+
|
|
834
|
+
***
|
|
835
|
+
|
|
836
|
+
### filter()
|
|
837
|
+
|
|
838
|
+
```ts
|
|
839
|
+
filter(callback, thisArg?): this;
|
|
840
|
+
```
|
|
841
|
+
|
|
842
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:1281](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L1281)
|
|
843
|
+
|
|
844
|
+
Filter values into a new list of the same class.
|
|
845
|
+
|
|
846
|
+
#### Parameters
|
|
847
|
+
|
|
848
|
+
##### callback
|
|
849
|
+
|
|
850
|
+
`ElementCallback`\<`E`, `R`, `boolean`\>
|
|
851
|
+
|
|
852
|
+
Predicate (value, index, list) → boolean to keep value.
|
|
853
|
+
|
|
854
|
+
##### thisArg?
|
|
855
|
+
|
|
856
|
+
`any`
|
|
857
|
+
|
|
858
|
+
Value for `this` inside the callback.
|
|
859
|
+
|
|
860
|
+
#### Returns
|
|
861
|
+
|
|
862
|
+
`this`
|
|
863
|
+
|
|
864
|
+
A new list with kept values.
|
|
865
|
+
|
|
866
|
+
*
|
|
867
|
+
|
|
868
|
+
#### Remarks
|
|
869
|
+
|
|
870
|
+
Time O(N), Space O(N)
|
|
871
|
+
|
|
872
|
+
#### Example
|
|
873
|
+
|
|
874
|
+
```ts
|
|
875
|
+
// SinglyLinkedList filter and map operations
|
|
876
|
+
const list = new SinglyLinkedList<number>([1, 2, 3, 4, 5]);
|
|
877
|
+
|
|
878
|
+
// Filter even numbers
|
|
879
|
+
const filtered = list.filter(value => value % 2 === 0);
|
|
880
|
+
console.log(filtered.length); // 2;
|
|
881
|
+
|
|
882
|
+
// Map to double values
|
|
883
|
+
const doubled = list.map(value => value * 2);
|
|
884
|
+
console.log(doubled.length); // 5;
|
|
885
|
+
|
|
886
|
+
// Use reduce to sum
|
|
887
|
+
const sum = list.reduce((acc, value) => acc + value, 0);
|
|
888
|
+
console.log(sum); // 15;
|
|
889
|
+
```
|
|
890
|
+
|
|
891
|
+
#### Inherited from
|
|
892
|
+
|
|
893
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`filter`](SinglyLinkedList.md#filter)
|
|
894
|
+
|
|
895
|
+
***
|
|
896
|
+
|
|
897
|
+
### find()
|
|
898
|
+
|
|
899
|
+
#### Call Signature
|
|
900
|
+
|
|
901
|
+
```ts
|
|
902
|
+
find<S>(predicate, thisArg?): S | undefined;
|
|
903
|
+
```
|
|
904
|
+
|
|
905
|
+
Defined in: [data-structures/base/iterable-element-base.ts:162](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-element-base.ts#L162)
|
|
906
|
+
|
|
907
|
+
Finds the first element that satisfies the predicate and returns it.
|
|
908
|
+
|
|
909
|
+
Finds the first element of type `S` (a subtype of `E`) that satisfies the predicate and returns it.
|
|
910
|
+
|
|
911
|
+
##### Type Parameters
|
|
912
|
+
|
|
913
|
+
###### S
|
|
914
|
+
|
|
915
|
+
`S`
|
|
916
|
+
|
|
917
|
+
##### Parameters
|
|
918
|
+
|
|
919
|
+
###### predicate
|
|
920
|
+
|
|
921
|
+
`ElementCallback`\<`E`, `R`, `S`\>
|
|
922
|
+
|
|
923
|
+
Type-guard predicate: `(value, index, self) => value is S`.
|
|
924
|
+
|
|
925
|
+
###### thisArg?
|
|
926
|
+
|
|
927
|
+
`unknown`
|
|
928
|
+
|
|
929
|
+
Optional `this` binding for the predicate.
|
|
930
|
+
|
|
931
|
+
##### Returns
|
|
932
|
+
|
|
933
|
+
`S` \| `undefined`
|
|
934
|
+
|
|
935
|
+
The matched element typed as `S`, or `undefined` if not found.
|
|
936
|
+
|
|
937
|
+
##### Remarks
|
|
938
|
+
|
|
939
|
+
Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
940
|
+
|
|
941
|
+
##### Inherited from
|
|
942
|
+
|
|
943
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`find`](SinglyLinkedList.md#find)
|
|
944
|
+
|
|
945
|
+
#### Call Signature
|
|
946
|
+
|
|
947
|
+
```ts
|
|
948
|
+
find(predicate, thisArg?): E | undefined;
|
|
949
|
+
```
|
|
950
|
+
|
|
951
|
+
Defined in: [data-structures/base/iterable-element-base.ts:163](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-element-base.ts#L163)
|
|
952
|
+
|
|
953
|
+
Finds the first element that satisfies the predicate and returns it.
|
|
954
|
+
|
|
955
|
+
Finds the first element of type `S` (a subtype of `E`) that satisfies the predicate and returns it.
|
|
956
|
+
|
|
957
|
+
##### Parameters
|
|
958
|
+
|
|
959
|
+
###### predicate
|
|
960
|
+
|
|
961
|
+
`ElementCallback`\<`E`, `R`, `unknown`\>
|
|
962
|
+
|
|
963
|
+
Type-guard predicate: `(value, index, self) => value is S`.
|
|
964
|
+
|
|
965
|
+
###### thisArg?
|
|
966
|
+
|
|
967
|
+
`unknown`
|
|
968
|
+
|
|
969
|
+
Optional `this` binding for the predicate.
|
|
970
|
+
|
|
971
|
+
##### Returns
|
|
972
|
+
|
|
973
|
+
`E` \| `undefined`
|
|
974
|
+
|
|
975
|
+
The matched element typed as `S`, or `undefined` if not found.
|
|
976
|
+
|
|
977
|
+
##### Remarks
|
|
978
|
+
|
|
979
|
+
Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
980
|
+
|
|
981
|
+
##### Inherited from
|
|
982
|
+
|
|
983
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`find`](SinglyLinkedList.md#find)
|
|
984
|
+
|
|
985
|
+
***
|
|
986
|
+
|
|
987
|
+
### findIndex()
|
|
988
|
+
|
|
989
|
+
```ts
|
|
990
|
+
findIndex(predicate, thisArg?): number;
|
|
991
|
+
```
|
|
992
|
+
|
|
993
|
+
Defined in: [data-structures/base/linear-base.ts:151](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L151)
|
|
994
|
+
|
|
995
|
+
Find the first index matching a predicate.
|
|
996
|
+
|
|
997
|
+
#### Parameters
|
|
998
|
+
|
|
999
|
+
##### predicate
|
|
1000
|
+
|
|
1001
|
+
`ElementCallback`\<`E`, `R`, `boolean`\>
|
|
1002
|
+
|
|
1003
|
+
`(element, index, self) => boolean`.
|
|
1004
|
+
|
|
1005
|
+
##### thisArg?
|
|
1006
|
+
|
|
1007
|
+
`any`
|
|
1008
|
+
|
|
1009
|
+
Optional `this` for callback.
|
|
1010
|
+
|
|
1011
|
+
#### Returns
|
|
1012
|
+
|
|
1013
|
+
`number`
|
|
1014
|
+
|
|
1015
|
+
Index or `-1`.
|
|
1016
|
+
|
|
1017
|
+
#### Remarks
|
|
1018
|
+
|
|
1019
|
+
Time O(n), Space O(1)
|
|
1020
|
+
|
|
1021
|
+
#### Inherited from
|
|
1022
|
+
|
|
1023
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`findIndex`](SinglyLinkedList.md#findindex)
|
|
1024
|
+
|
|
1025
|
+
***
|
|
1026
|
+
|
|
1027
|
+
### forEach()
|
|
1028
|
+
|
|
1029
|
+
```ts
|
|
1030
|
+
forEach(callbackfn, thisArg?): void;
|
|
1031
|
+
```
|
|
1032
|
+
|
|
1033
|
+
Defined in: [data-structures/base/iterable-element-base.ts:132](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-element-base.ts#L132)
|
|
1034
|
+
|
|
1035
|
+
Invokes a callback for each element in iteration order.
|
|
1036
|
+
|
|
1037
|
+
#### Parameters
|
|
1038
|
+
|
|
1039
|
+
##### callbackfn
|
|
1040
|
+
|
|
1041
|
+
`ElementCallback`\<`E`, `R`, `void`\>
|
|
1042
|
+
|
|
1043
|
+
Function invoked per element with signature `(value, index, self)`.
|
|
1044
|
+
|
|
1045
|
+
##### thisArg?
|
|
1046
|
+
|
|
1047
|
+
`unknown`
|
|
1048
|
+
|
|
1049
|
+
Optional `this` binding for the callback.
|
|
1050
|
+
|
|
1051
|
+
#### Returns
|
|
1052
|
+
|
|
1053
|
+
`void`
|
|
1054
|
+
|
|
1055
|
+
`void`.
|
|
1056
|
+
|
|
1057
|
+
#### Remarks
|
|
1058
|
+
|
|
1059
|
+
Time O(n), Space O(1).
|
|
1060
|
+
|
|
1061
|
+
#### Inherited from
|
|
1062
|
+
|
|
1063
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`forEach`](SinglyLinkedList.md#foreach)
|
|
1064
|
+
|
|
1065
|
+
***
|
|
1066
|
+
|
|
1067
|
+
### getNode()
|
|
1068
|
+
|
|
1069
|
+
```ts
|
|
1070
|
+
getNode(elementNodeOrPredicate?): SinglyLinkedListNode<E> | undefined;
|
|
1071
|
+
```
|
|
1072
|
+
|
|
1073
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:1005](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L1005)
|
|
1074
|
+
|
|
1075
|
+
Find a node by value, reference, or predicate.
|
|
1076
|
+
|
|
1077
|
+
#### Parameters
|
|
1078
|
+
|
|
1079
|
+
##### elementNodeOrPredicate?
|
|
1080
|
+
|
|
1081
|
+
\| `E`
|
|
1082
|
+
\| [`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\>
|
|
1083
|
+
\| ((`node`) => `boolean`)
|
|
1084
|
+
|
|
1085
|
+
Element, node, or node predicate to match.
|
|
1086
|
+
|
|
1087
|
+
#### Returns
|
|
1088
|
+
|
|
1089
|
+
[`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\> \| `undefined`
|
|
1090
|
+
|
|
1091
|
+
Matching node or undefined.
|
|
1092
|
+
|
|
1093
|
+
#### Remarks
|
|
1094
|
+
|
|
1095
|
+
Time O(N), Space O(1)
|
|
1096
|
+
|
|
1097
|
+
#### Inherited from
|
|
1098
|
+
|
|
1099
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`getNode`](SinglyLinkedList.md#getnode)
|
|
1100
|
+
|
|
1101
|
+
***
|
|
1102
|
+
|
|
1103
|
+
### getNodeAt()
|
|
1104
|
+
|
|
1105
|
+
```ts
|
|
1106
|
+
getNodeAt(index): SinglyLinkedListNode<E> | undefined;
|
|
1107
|
+
```
|
|
1108
|
+
|
|
1109
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:687](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L687)
|
|
1110
|
+
|
|
1111
|
+
Get the node reference at a given index.
|
|
1112
|
+
|
|
1113
|
+
#### Parameters
|
|
1114
|
+
|
|
1115
|
+
##### index
|
|
1116
|
+
|
|
1117
|
+
`number`
|
|
1118
|
+
|
|
1119
|
+
Zero-based index.
|
|
1120
|
+
|
|
1121
|
+
#### Returns
|
|
1122
|
+
|
|
1123
|
+
[`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\> \| `undefined`
|
|
1124
|
+
|
|
1125
|
+
Node or undefined.
|
|
1126
|
+
|
|
1127
|
+
*
|
|
1128
|
+
|
|
1129
|
+
#### Remarks
|
|
1130
|
+
|
|
1131
|
+
Time O(N), Space O(1)
|
|
1132
|
+
|
|
1133
|
+
#### Example
|
|
1134
|
+
|
|
1135
|
+
```ts
|
|
1136
|
+
// Get node at index
|
|
1137
|
+
const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
|
|
1138
|
+
console.log(list.getNodeAt(1)?.value); // 'b';
|
|
1139
|
+
```
|
|
1140
|
+
|
|
1141
|
+
#### Inherited from
|
|
1142
|
+
|
|
1143
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`getNodeAt`](SinglyLinkedList.md#getnodeat)
|
|
1144
|
+
|
|
1145
|
+
***
|
|
1146
|
+
|
|
1147
|
+
### has()
|
|
1148
|
+
|
|
1149
|
+
```ts
|
|
1150
|
+
has(element): boolean;
|
|
1151
|
+
```
|
|
1152
|
+
|
|
1153
|
+
Defined in: [data-structures/base/iterable-element-base.ts:188](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-element-base.ts#L188)
|
|
1154
|
+
|
|
1155
|
+
Checks whether a strictly-equal element exists in the structure.
|
|
1156
|
+
|
|
1157
|
+
#### Parameters
|
|
1158
|
+
|
|
1159
|
+
##### element
|
|
1160
|
+
|
|
1161
|
+
`E`
|
|
1162
|
+
|
|
1163
|
+
The element to test with `===` equality.
|
|
1164
|
+
|
|
1165
|
+
#### Returns
|
|
1166
|
+
|
|
1167
|
+
`boolean`
|
|
1168
|
+
|
|
1169
|
+
`true` if an equal element is found; otherwise `false`.
|
|
1170
|
+
|
|
1171
|
+
#### Remarks
|
|
1172
|
+
|
|
1173
|
+
Time O(n) in the worst case. Space O(1).
|
|
1174
|
+
|
|
1175
|
+
#### Inherited from
|
|
1176
|
+
|
|
1177
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`has`](SinglyLinkedList.md#has)
|
|
1178
|
+
|
|
1179
|
+
***
|
|
1180
|
+
|
|
1181
|
+
### indexOf()
|
|
1182
|
+
|
|
1183
|
+
```ts
|
|
1184
|
+
indexOf(searchElement, fromIndex?): number;
|
|
1185
|
+
```
|
|
1186
|
+
|
|
1187
|
+
Defined in: [data-structures/base/linear-base.ts:422](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L422)
|
|
1188
|
+
|
|
1189
|
+
Linked-list optimized `indexOf` (forwards scan).
|
|
1190
|
+
|
|
1191
|
+
#### Parameters
|
|
1192
|
+
|
|
1193
|
+
##### searchElement
|
|
1194
|
+
|
|
1195
|
+
`E`
|
|
1196
|
+
|
|
1197
|
+
Value to match.
|
|
1198
|
+
|
|
1199
|
+
##### fromIndex?
|
|
1200
|
+
|
|
1201
|
+
`number` = `0`
|
|
1202
|
+
|
|
1203
|
+
Start position.
|
|
1204
|
+
|
|
1205
|
+
#### Returns
|
|
1206
|
+
|
|
1207
|
+
`number`
|
|
1208
|
+
|
|
1209
|
+
Index or `-1`.
|
|
1210
|
+
|
|
1211
|
+
#### Remarks
|
|
1212
|
+
|
|
1213
|
+
Time O(n), Space O(1)
|
|
1214
|
+
|
|
1215
|
+
#### Inherited from
|
|
1216
|
+
|
|
1217
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`indexOf`](SinglyLinkedList.md#indexof)
|
|
1218
|
+
|
|
1219
|
+
***
|
|
1220
|
+
|
|
1221
|
+
### isEmpty()
|
|
1222
|
+
|
|
1223
|
+
```ts
|
|
1224
|
+
isEmpty(): boolean;
|
|
1225
|
+
```
|
|
1226
|
+
|
|
1227
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:897](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L897)
|
|
1228
|
+
|
|
1229
|
+
Check whether the list is empty.
|
|
1230
|
+
|
|
1231
|
+
#### Returns
|
|
1232
|
+
|
|
1233
|
+
`boolean`
|
|
1234
|
+
|
|
1235
|
+
True if length is 0.
|
|
1236
|
+
|
|
1237
|
+
*
|
|
1238
|
+
|
|
1239
|
+
#### Remarks
|
|
1240
|
+
|
|
1241
|
+
Time O(1), Space O(1)
|
|
1242
|
+
|
|
1243
|
+
#### Example
|
|
1244
|
+
|
|
1245
|
+
```ts
|
|
1246
|
+
// Check empty
|
|
1247
|
+
console.log(new SinglyLinkedList().isEmpty()); // true;
|
|
1248
|
+
```
|
|
1249
|
+
|
|
1250
|
+
#### Inherited from
|
|
1251
|
+
|
|
1252
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`isEmpty`](SinglyLinkedList.md#isempty)
|
|
1253
|
+
|
|
1254
|
+
***
|
|
1255
|
+
|
|
1256
|
+
### isNode()
|
|
1257
|
+
|
|
1258
|
+
```ts
|
|
1259
|
+
isNode(elementNodeOrPredicate): elementNodeOrPredicate is SinglyLinkedListNode<E>;
|
|
1260
|
+
```
|
|
1261
|
+
|
|
1262
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:645](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L645)
|
|
1263
|
+
|
|
1264
|
+
Type guard: check whether the input is a SinglyLinkedListNode.
|
|
1265
|
+
|
|
1266
|
+
#### Parameters
|
|
1267
|
+
|
|
1268
|
+
##### elementNodeOrPredicate
|
|
1269
|
+
|
|
1270
|
+
\| `E`
|
|
1271
|
+
\| [`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\>
|
|
1272
|
+
\| ((`node`) => `boolean`)
|
|
1273
|
+
|
|
1274
|
+
Element, node, or predicate.
|
|
1275
|
+
|
|
1276
|
+
#### Returns
|
|
1277
|
+
|
|
1278
|
+
`elementNodeOrPredicate is SinglyLinkedListNode<E>`
|
|
1279
|
+
|
|
1280
|
+
True if the value is a SinglyLinkedListNode.
|
|
1281
|
+
|
|
1282
|
+
#### Remarks
|
|
1283
|
+
|
|
1284
|
+
Time O(1), Space O(1)
|
|
1285
|
+
|
|
1286
|
+
#### Inherited from
|
|
1287
|
+
|
|
1288
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`isNode`](SinglyLinkedList.md#isnode)
|
|
1289
|
+
|
|
1290
|
+
***
|
|
1291
|
+
|
|
1292
|
+
### join()
|
|
1293
|
+
|
|
1294
|
+
```ts
|
|
1295
|
+
join(separator?): string;
|
|
1296
|
+
```
|
|
1297
|
+
|
|
1298
|
+
Defined in: [data-structures/base/linear-base.ts:228](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L228)
|
|
1299
|
+
|
|
1300
|
+
Join all elements into a string.
|
|
1301
|
+
|
|
1302
|
+
#### Parameters
|
|
1303
|
+
|
|
1304
|
+
##### separator?
|
|
1305
|
+
|
|
1306
|
+
`string` = `','`
|
|
1307
|
+
|
|
1308
|
+
Separator string.
|
|
1309
|
+
|
|
1310
|
+
#### Returns
|
|
1311
|
+
|
|
1312
|
+
`string`
|
|
1313
|
+
|
|
1314
|
+
Concatenated string.
|
|
1315
|
+
|
|
1316
|
+
#### Remarks
|
|
1317
|
+
|
|
1318
|
+
Time O(n), Space O(n)
|
|
1319
|
+
|
|
1320
|
+
#### Inherited from
|
|
1321
|
+
|
|
1322
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`join`](SinglyLinkedList.md#join)
|
|
1323
|
+
|
|
1324
|
+
***
|
|
1325
|
+
|
|
1326
|
+
### lastIndexOf()
|
|
1327
|
+
|
|
1328
|
+
```ts
|
|
1329
|
+
lastIndexOf(searchElement, fromIndex?): number;
|
|
1330
|
+
```
|
|
1331
|
+
|
|
1332
|
+
Defined in: [data-structures/base/linear-base.ts:448](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L448)
|
|
1333
|
+
|
|
1334
|
+
Linked-list optimized `lastIndexOf` (reverse scan).
|
|
1335
|
+
|
|
1336
|
+
#### Parameters
|
|
1337
|
+
|
|
1338
|
+
##### searchElement
|
|
1339
|
+
|
|
1340
|
+
`E`
|
|
1341
|
+
|
|
1342
|
+
Value to match.
|
|
1343
|
+
|
|
1344
|
+
##### fromIndex?
|
|
1345
|
+
|
|
1346
|
+
`number` = `...`
|
|
1347
|
+
|
|
1348
|
+
Start position.
|
|
1349
|
+
|
|
1350
|
+
#### Returns
|
|
1351
|
+
|
|
1352
|
+
`number`
|
|
1353
|
+
|
|
1354
|
+
Index or `-1`.
|
|
1355
|
+
|
|
1356
|
+
#### Remarks
|
|
1357
|
+
|
|
1358
|
+
Time O(n), Space O(1)
|
|
1359
|
+
|
|
1360
|
+
#### Inherited from
|
|
1361
|
+
|
|
1362
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`lastIndexOf`](SinglyLinkedList.md#lastindexof)
|
|
1363
|
+
|
|
1364
|
+
***
|
|
1365
|
+
|
|
1366
|
+
### map()
|
|
1367
|
+
|
|
1368
|
+
```ts
|
|
1369
|
+
map<EM, RM>(
|
|
1370
|
+
callback,
|
|
1371
|
+
options?,
|
|
1372
|
+
thisArg?): SinglyLinkedList<EM, RM>;
|
|
1373
|
+
```
|
|
1374
|
+
|
|
1375
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:1350](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L1350)
|
|
1376
|
+
|
|
1377
|
+
Map values into a new list (possibly different element type).
|
|
1378
|
+
|
|
1379
|
+
#### Type Parameters
|
|
1380
|
+
|
|
1381
|
+
##### EM
|
|
1382
|
+
|
|
1383
|
+
`EM`
|
|
1384
|
+
|
|
1385
|
+
##### RM
|
|
1386
|
+
|
|
1387
|
+
`RM` = `any`
|
|
1388
|
+
|
|
1389
|
+
#### Parameters
|
|
1390
|
+
|
|
1391
|
+
##### callback
|
|
1392
|
+
|
|
1393
|
+
`ElementCallback`\<`E`, `R`, `EM`\>
|
|
1394
|
+
|
|
1395
|
+
Mapping function (value, index, list) → newElement.
|
|
1396
|
+
|
|
1397
|
+
##### options?
|
|
1398
|
+
|
|
1399
|
+
`SinglyLinkedListOptions`\<`EM`, `RM`\>
|
|
1400
|
+
|
|
1401
|
+
Options for the output list (e.g., maxLen, toElementFn).
|
|
1402
|
+
|
|
1403
|
+
##### thisArg?
|
|
1404
|
+
|
|
1405
|
+
`any`
|
|
1406
|
+
|
|
1407
|
+
Value for `this` inside the callback.
|
|
1408
|
+
|
|
1409
|
+
#### Returns
|
|
1410
|
+
|
|
1411
|
+
[`SinglyLinkedList`](SinglyLinkedList.md)\<`EM`, `RM`\>
|
|
1412
|
+
|
|
1413
|
+
A new SinglyLinkedList with mapped values.
|
|
1414
|
+
|
|
1415
|
+
*
|
|
1416
|
+
|
|
1417
|
+
#### Remarks
|
|
1418
|
+
|
|
1419
|
+
Time O(N), Space O(N)
|
|
1420
|
+
|
|
1421
|
+
#### Example
|
|
1422
|
+
|
|
1423
|
+
```ts
|
|
1424
|
+
// Transform elements
|
|
1425
|
+
const list = new SinglyLinkedList<number>([1, 2, 3]);
|
|
1426
|
+
const doubled = list.map(n => n * 2);
|
|
1427
|
+
console.log([...doubled]); // [2, 4, 6];
|
|
1428
|
+
```
|
|
1429
|
+
|
|
1430
|
+
#### Inherited from
|
|
1431
|
+
|
|
1432
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`map`](SinglyLinkedList.md#map)
|
|
1433
|
+
|
|
1434
|
+
***
|
|
1435
|
+
|
|
1436
|
+
### mapSame()
|
|
1437
|
+
|
|
1438
|
+
```ts
|
|
1439
|
+
mapSame(callback, thisArg?): this;
|
|
1440
|
+
```
|
|
1441
|
+
|
|
1442
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:1296](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L1296)
|
|
1443
|
+
|
|
1444
|
+
Map values into a new list of the same class.
|
|
1445
|
+
|
|
1446
|
+
#### Parameters
|
|
1447
|
+
|
|
1448
|
+
##### callback
|
|
1449
|
+
|
|
1450
|
+
`ElementCallback`\<`E`, `R`, `E`\>
|
|
1451
|
+
|
|
1452
|
+
Mapping function (value, index, list) → newValue.
|
|
1453
|
+
|
|
1454
|
+
##### thisArg?
|
|
1455
|
+
|
|
1456
|
+
`any`
|
|
1457
|
+
|
|
1458
|
+
Value for `this` inside the callback.
|
|
1459
|
+
|
|
1460
|
+
#### Returns
|
|
1461
|
+
|
|
1462
|
+
`this`
|
|
1463
|
+
|
|
1464
|
+
A new list with mapped values.
|
|
1465
|
+
|
|
1466
|
+
#### Remarks
|
|
1467
|
+
|
|
1468
|
+
Time O(N), Space O(N)
|
|
1469
|
+
|
|
1470
|
+
#### Inherited from
|
|
1471
|
+
|
|
1472
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`mapSame`](SinglyLinkedList.md#mapsame)
|
|
1473
|
+
|
|
1474
|
+
***
|
|
1475
|
+
|
|
1476
|
+
### pop()
|
|
1477
|
+
|
|
1478
|
+
```ts
|
|
1479
|
+
pop(): E | undefined;
|
|
1480
|
+
```
|
|
1481
|
+
|
|
1482
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:406](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L406)
|
|
1483
|
+
|
|
1484
|
+
Remove and return the tail element.
|
|
1485
|
+
|
|
1486
|
+
#### Returns
|
|
1487
|
+
|
|
1488
|
+
`E` \| `undefined`
|
|
1489
|
+
|
|
1490
|
+
Removed element or undefined.
|
|
1491
|
+
|
|
1492
|
+
*
|
|
1493
|
+
|
|
1494
|
+
#### Remarks
|
|
1495
|
+
|
|
1496
|
+
Time O(N), Space O(1)
|
|
1497
|
+
|
|
1498
|
+
#### Example
|
|
1499
|
+
|
|
1500
|
+
```ts
|
|
1501
|
+
// SinglyLinkedList pop and shift operations
|
|
1502
|
+
const list = new SinglyLinkedList<number>([10, 20, 30, 40, 50]);
|
|
1503
|
+
|
|
1504
|
+
// Pop removes from the end
|
|
1505
|
+
const last = list.pop();
|
|
1506
|
+
console.log(last); // 50;
|
|
1507
|
+
|
|
1508
|
+
// Shift removes from the beginning
|
|
1509
|
+
const first = list.shift();
|
|
1510
|
+
console.log(first); // 10;
|
|
1511
|
+
|
|
1512
|
+
// Verify remaining elements
|
|
1513
|
+
console.log([...list]); // [20, 30, 40];
|
|
1514
|
+
console.log(list.length); // 3;
|
|
1515
|
+
```
|
|
1516
|
+
|
|
1517
|
+
#### Inherited from
|
|
1518
|
+
|
|
1519
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`pop`](SinglyLinkedList.md#pop)
|
|
1520
|
+
|
|
1521
|
+
***
|
|
1522
|
+
|
|
1523
|
+
### print()
|
|
1524
|
+
|
|
1525
|
+
```ts
|
|
1526
|
+
print(): void;
|
|
1527
|
+
```
|
|
1528
|
+
|
|
1529
|
+
Defined in: [data-structures/base/iterable-element-base.ts:268](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-element-base.ts#L268)
|
|
1530
|
+
|
|
1531
|
+
Prints `toVisual()` to the console. Intended for quick debugging.
|
|
1532
|
+
|
|
1533
|
+
#### Returns
|
|
1534
|
+
|
|
1535
|
+
`void`
|
|
1536
|
+
|
|
1537
|
+
`void`.
|
|
1538
|
+
|
|
1539
|
+
#### Remarks
|
|
1540
|
+
|
|
1541
|
+
Time O(n) due to materialization, Space O(n) for the intermediate representation.
|
|
1542
|
+
|
|
1543
|
+
#### Inherited from
|
|
1544
|
+
|
|
1545
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`print`](SinglyLinkedList.md#print)
|
|
1546
|
+
|
|
1547
|
+
***
|
|
1548
|
+
|
|
1549
|
+
### push()
|
|
1550
|
+
|
|
1551
|
+
```ts
|
|
1552
|
+
push(elementOrNode): boolean;
|
|
1553
|
+
```
|
|
1554
|
+
|
|
1555
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:344](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L344)
|
|
1556
|
+
|
|
1557
|
+
Append an element/node to the tail.
|
|
1558
|
+
|
|
1559
|
+
#### Parameters
|
|
1560
|
+
|
|
1561
|
+
##### elementOrNode
|
|
1562
|
+
|
|
1563
|
+
`E` \| [`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\>
|
|
1564
|
+
|
|
1565
|
+
Element or node to append.
|
|
1566
|
+
|
|
1567
|
+
#### Returns
|
|
1568
|
+
|
|
1569
|
+
`boolean`
|
|
1570
|
+
|
|
1571
|
+
True when appended.
|
|
1572
|
+
|
|
1573
|
+
*
|
|
1574
|
+
|
|
1575
|
+
#### Remarks
|
|
1576
|
+
|
|
1577
|
+
Time O(1), Space O(1)
|
|
1578
|
+
|
|
1579
|
+
#### Example
|
|
1580
|
+
|
|
1581
|
+
```ts
|
|
1582
|
+
// basic SinglyLinkedList creation and push operation
|
|
1583
|
+
// Create a simple SinglyLinkedList with initial values
|
|
1584
|
+
const list = new SinglyLinkedList([1, 2, 3, 4, 5]);
|
|
1585
|
+
|
|
1586
|
+
// Verify the list maintains insertion order
|
|
1587
|
+
console.log([...list]); // [1, 2, 3, 4, 5];
|
|
1588
|
+
|
|
1589
|
+
// Check length
|
|
1590
|
+
console.log(list.length); // 5;
|
|
1591
|
+
|
|
1592
|
+
// Push a new element to the end
|
|
1593
|
+
list.push(6);
|
|
1594
|
+
console.log(list.length); // 6;
|
|
1595
|
+
console.log([...list]); // [1, 2, 3, 4, 5, 6];
|
|
1596
|
+
```
|
|
1597
|
+
|
|
1598
|
+
#### Inherited from
|
|
1599
|
+
|
|
1600
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`push`](SinglyLinkedList.md#push)
|
|
1601
|
+
|
|
1602
|
+
***
|
|
1603
|
+
|
|
1604
|
+
### pushMany()
|
|
1605
|
+
|
|
1606
|
+
```ts
|
|
1607
|
+
pushMany(elements): boolean[];
|
|
1608
|
+
```
|
|
1609
|
+
|
|
1610
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:546](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L546)
|
|
1611
|
+
|
|
1612
|
+
Append a sequence of elements/nodes.
|
|
1613
|
+
|
|
1614
|
+
#### Parameters
|
|
1615
|
+
|
|
1616
|
+
##### elements
|
|
1617
|
+
|
|
1618
|
+
\| `Iterable`\<`E`, `any`, `any`\>
|
|
1619
|
+
\| `Iterable`\<`R`, `any`, `any`\>
|
|
1620
|
+
\| `Iterable`\<[`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\>, `any`, `any`\>
|
|
1621
|
+
|
|
1622
|
+
Iterable of elements or nodes (or raw records if toElementFn is provided).
|
|
1623
|
+
|
|
1624
|
+
#### Returns
|
|
1625
|
+
|
|
1626
|
+
`boolean`[]
|
|
1627
|
+
|
|
1628
|
+
Array of per-element success flags.
|
|
1629
|
+
|
|
1630
|
+
#### Remarks
|
|
1631
|
+
|
|
1632
|
+
Time O(N), Space O(1)
|
|
1633
|
+
|
|
1634
|
+
#### Inherited from
|
|
1635
|
+
|
|
1636
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`pushMany`](SinglyLinkedList.md#pushmany)
|
|
1637
|
+
|
|
1638
|
+
***
|
|
1639
|
+
|
|
1640
|
+
### reduce()
|
|
1641
|
+
|
|
1642
|
+
Reduces all elements to a single accumulated value.
|
|
1643
|
+
|
|
1644
|
+
#### Param
|
|
1645
|
+
|
|
1646
|
+
Reducer of signature `(acc, value, index, self) => nextAcc`. The first element is used as the initial accumulator.
|
|
1647
|
+
|
|
1648
|
+
#### Param
|
|
1649
|
+
|
|
1650
|
+
Reducer of signature `(acc, value, index, self) => nextAcc`.
|
|
1651
|
+
|
|
1652
|
+
#### Param
|
|
1653
|
+
|
|
1654
|
+
The initial accumulator value of type `E`.
|
|
1655
|
+
|
|
1656
|
+
#### Template
|
|
1657
|
+
|
|
1658
|
+
The accumulator type when it differs from `E`.
|
|
1659
|
+
|
|
1660
|
+
#### Param
|
|
1661
|
+
|
|
1662
|
+
Reducer of signature `(acc: U, value, index, self) => U`.
|
|
1663
|
+
|
|
1664
|
+
#### Param
|
|
1665
|
+
|
|
1666
|
+
The initial accumulator value of type `U`.
|
|
1667
|
+
|
|
1668
|
+
#### Remarks
|
|
1669
|
+
|
|
1670
|
+
Time O(n), Space O(1). Throws if called on an empty structure without `initialValue`.
|
|
1671
|
+
|
|
1672
|
+
#### Call Signature
|
|
1673
|
+
|
|
1674
|
+
```ts
|
|
1675
|
+
reduce(callbackfn): E;
|
|
1676
|
+
```
|
|
1677
|
+
|
|
1678
|
+
Defined in: [data-structures/base/iterable-element-base.ts:193](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-element-base.ts#L193)
|
|
1679
|
+
|
|
1680
|
+
##### Parameters
|
|
1681
|
+
|
|
1682
|
+
###### callbackfn
|
|
1683
|
+
|
|
1684
|
+
`ReduceElementCallback`\<`E`, `R`\>
|
|
1685
|
+
|
|
1686
|
+
##### Returns
|
|
1687
|
+
|
|
1688
|
+
`E`
|
|
1689
|
+
|
|
1690
|
+
##### Inherited from
|
|
1691
|
+
|
|
1692
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`reduce`](SinglyLinkedList.md#reduce)
|
|
1693
|
+
|
|
1694
|
+
#### Call Signature
|
|
1695
|
+
|
|
1696
|
+
```ts
|
|
1697
|
+
reduce(callbackfn, initialValue): E;
|
|
1698
|
+
```
|
|
1699
|
+
|
|
1700
|
+
Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-element-base.ts#L194)
|
|
1701
|
+
|
|
1702
|
+
##### Parameters
|
|
1703
|
+
|
|
1704
|
+
###### callbackfn
|
|
1705
|
+
|
|
1706
|
+
`ReduceElementCallback`\<`E`, `R`\>
|
|
1707
|
+
|
|
1708
|
+
###### initialValue
|
|
1709
|
+
|
|
1710
|
+
`E`
|
|
1711
|
+
|
|
1712
|
+
##### Returns
|
|
1713
|
+
|
|
1714
|
+
`E`
|
|
1715
|
+
|
|
1716
|
+
##### Inherited from
|
|
1717
|
+
|
|
1718
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`reduce`](SinglyLinkedList.md#reduce)
|
|
1719
|
+
|
|
1720
|
+
#### Call Signature
|
|
1721
|
+
|
|
1722
|
+
```ts
|
|
1723
|
+
reduce<U>(callbackfn, initialValue): U;
|
|
1724
|
+
```
|
|
1725
|
+
|
|
1726
|
+
Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-element-base.ts#L195)
|
|
1727
|
+
|
|
1728
|
+
##### Type Parameters
|
|
1729
|
+
|
|
1730
|
+
###### U
|
|
1731
|
+
|
|
1732
|
+
`U`
|
|
1733
|
+
|
|
1734
|
+
##### Parameters
|
|
1735
|
+
|
|
1736
|
+
###### callbackfn
|
|
1737
|
+
|
|
1738
|
+
`ReduceElementCallback`\<`E`, `R`, `U`\>
|
|
1739
|
+
|
|
1740
|
+
###### initialValue
|
|
1741
|
+
|
|
1742
|
+
`U`
|
|
1743
|
+
|
|
1744
|
+
##### Returns
|
|
1745
|
+
|
|
1746
|
+
`U`
|
|
1747
|
+
|
|
1748
|
+
##### Inherited from
|
|
1749
|
+
|
|
1750
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`reduce`](SinglyLinkedList.md#reduce)
|
|
1751
|
+
|
|
1752
|
+
***
|
|
1753
|
+
|
|
1754
|
+
### reduceRight()
|
|
1755
|
+
|
|
1756
|
+
```ts
|
|
1757
|
+
reduceRight<U>(callbackfn, initialValue): U;
|
|
1758
|
+
```
|
|
1759
|
+
|
|
1760
|
+
Defined in: [data-structures/base/linear-base.ts:574](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L574)
|
|
1761
|
+
|
|
1762
|
+
Right-to-left reduction using reverse iterator.
|
|
1763
|
+
|
|
1764
|
+
#### Type Parameters
|
|
1765
|
+
|
|
1766
|
+
##### U
|
|
1767
|
+
|
|
1768
|
+
`U`
|
|
1769
|
+
|
|
1770
|
+
#### Parameters
|
|
1771
|
+
|
|
1772
|
+
##### callbackfn
|
|
1773
|
+
|
|
1774
|
+
`ReduceLinearCallback`\<`E`, `U`\>
|
|
1775
|
+
|
|
1776
|
+
`(acc, element, index, self) => acc`.
|
|
1777
|
+
|
|
1778
|
+
##### initialValue
|
|
1779
|
+
|
|
1780
|
+
`U`
|
|
1781
|
+
|
|
1782
|
+
Initial accumulator.
|
|
1783
|
+
|
|
1784
|
+
#### Returns
|
|
1785
|
+
|
|
1786
|
+
`U`
|
|
1787
|
+
|
|
1788
|
+
Final accumulator.
|
|
1789
|
+
|
|
1790
|
+
#### Remarks
|
|
1791
|
+
|
|
1792
|
+
Time O(n), Space O(1)
|
|
1793
|
+
|
|
1794
|
+
#### Inherited from
|
|
1795
|
+
|
|
1796
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`reduceRight`](SinglyLinkedList.md#reduceright)
|
|
1797
|
+
|
|
1798
|
+
***
|
|
1799
|
+
|
|
1800
|
+
### reverse()
|
|
1801
|
+
|
|
1802
|
+
```ts
|
|
1803
|
+
reverse(): this;
|
|
1804
|
+
```
|
|
1805
|
+
|
|
1806
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:983](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L983)
|
|
1807
|
+
|
|
1808
|
+
Reverse the list in place.
|
|
1809
|
+
|
|
1810
|
+
#### Returns
|
|
1811
|
+
|
|
1812
|
+
`this`
|
|
1813
|
+
|
|
1814
|
+
This list.
|
|
1815
|
+
|
|
1816
|
+
*
|
|
1817
|
+
|
|
1818
|
+
#### Remarks
|
|
1819
|
+
|
|
1820
|
+
Time O(N), Space O(1)
|
|
1821
|
+
|
|
1822
|
+
#### Example
|
|
1823
|
+
|
|
1824
|
+
```ts
|
|
1825
|
+
// Reverse the list in-place
|
|
1826
|
+
const list = new SinglyLinkedList<number>([1, 2, 3, 4]);
|
|
1827
|
+
list.reverse();
|
|
1828
|
+
console.log([...list]); // [4, 3, 2, 1];
|
|
1829
|
+
```
|
|
1830
|
+
|
|
1831
|
+
#### Inherited from
|
|
1832
|
+
|
|
1833
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`reverse`](SinglyLinkedList.md#reverse)
|
|
1834
|
+
|
|
1835
|
+
***
|
|
1836
|
+
|
|
1837
|
+
### search()
|
|
1838
|
+
|
|
1839
|
+
```ts
|
|
1840
|
+
search(elementNodeOrPredicate): E | undefined;
|
|
1841
|
+
```
|
|
1842
|
+
|
|
1843
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:578](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L578)
|
|
1844
|
+
|
|
1845
|
+
Find the first value matching a predicate (by node).
|
|
1846
|
+
|
|
1847
|
+
#### Parameters
|
|
1848
|
+
|
|
1849
|
+
##### elementNodeOrPredicate
|
|
1850
|
+
|
|
1851
|
+
\| `E`
|
|
1852
|
+
\| [`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\>
|
|
1853
|
+
\| ((`node`) => `boolean`)
|
|
1854
|
+
|
|
1855
|
+
Element, node, or node predicate to match.
|
|
1856
|
+
|
|
1857
|
+
#### Returns
|
|
1858
|
+
|
|
1859
|
+
`E` \| `undefined`
|
|
1860
|
+
|
|
1861
|
+
Matched value or undefined.
|
|
1862
|
+
|
|
1863
|
+
#### Remarks
|
|
1864
|
+
|
|
1865
|
+
Time O(N), Space O(1)
|
|
1866
|
+
|
|
1867
|
+
#### Inherited from
|
|
1868
|
+
|
|
1869
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`search`](SinglyLinkedList.md#search)
|
|
1870
|
+
|
|
1871
|
+
***
|
|
1872
|
+
|
|
1873
|
+
### setAt()
|
|
1874
|
+
|
|
1875
|
+
```ts
|
|
1876
|
+
setAt(index, value): boolean;
|
|
1877
|
+
```
|
|
1878
|
+
|
|
1879
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:855](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L855)
|
|
1880
|
+
|
|
1881
|
+
Set the element value at an index.
|
|
1882
|
+
|
|
1883
|
+
#### Parameters
|
|
1884
|
+
|
|
1885
|
+
##### index
|
|
1886
|
+
|
|
1887
|
+
`number`
|
|
1888
|
+
|
|
1889
|
+
Zero-based index.
|
|
1890
|
+
|
|
1891
|
+
##### value
|
|
1892
|
+
|
|
1893
|
+
`E`
|
|
1894
|
+
|
|
1895
|
+
New value.
|
|
1896
|
+
|
|
1897
|
+
#### Returns
|
|
1898
|
+
|
|
1899
|
+
`boolean`
|
|
1900
|
+
|
|
1901
|
+
True if updated.
|
|
1902
|
+
|
|
1903
|
+
#### Remarks
|
|
1904
|
+
|
|
1905
|
+
Time O(N), Space O(1)
|
|
1906
|
+
|
|
1907
|
+
#### Inherited from
|
|
1908
|
+
|
|
1909
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`setAt`](SinglyLinkedList.md#setat)
|
|
1910
|
+
|
|
1911
|
+
***
|
|
1912
|
+
|
|
1913
|
+
### setEquality()
|
|
1914
|
+
|
|
1915
|
+
```ts
|
|
1916
|
+
setEquality(equals): this;
|
|
1917
|
+
```
|
|
1918
|
+
|
|
1919
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:1151](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L1151)
|
|
1920
|
+
|
|
1921
|
+
Set the equality comparator used to compare values.
|
|
1922
|
+
|
|
1923
|
+
#### Parameters
|
|
1924
|
+
|
|
1925
|
+
##### equals
|
|
1926
|
+
|
|
1927
|
+
(`a`, `b`) => `boolean`
|
|
1928
|
+
|
|
1929
|
+
Equality predicate (a, b) → boolean.
|
|
1930
|
+
|
|
1931
|
+
#### Returns
|
|
1932
|
+
|
|
1933
|
+
`this`
|
|
1934
|
+
|
|
1935
|
+
This list.
|
|
1936
|
+
|
|
1937
|
+
#### Remarks
|
|
1938
|
+
|
|
1939
|
+
Time O(1), Space O(1)
|
|
1940
|
+
|
|
1941
|
+
#### Inherited from
|
|
1942
|
+
|
|
1943
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`setEquality`](SinglyLinkedList.md#setequality)
|
|
1944
|
+
|
|
1945
|
+
***
|
|
1946
|
+
|
|
1947
|
+
### shift()
|
|
1948
|
+
|
|
1949
|
+
```ts
|
|
1950
|
+
shift(): E | undefined;
|
|
1951
|
+
```
|
|
1952
|
+
|
|
1953
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:463](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L463)
|
|
1954
|
+
|
|
1955
|
+
Remove and return the head element.
|
|
1956
|
+
|
|
1957
|
+
#### Returns
|
|
1958
|
+
|
|
1959
|
+
`E` \| `undefined`
|
|
1960
|
+
|
|
1961
|
+
Removed element or undefined.
|
|
1962
|
+
|
|
1963
|
+
*
|
|
1964
|
+
|
|
1965
|
+
#### Remarks
|
|
1966
|
+
|
|
1967
|
+
Time O(1), Space O(1)
|
|
1968
|
+
|
|
1969
|
+
#### Example
|
|
1970
|
+
|
|
1971
|
+
```ts
|
|
1972
|
+
// Remove from the front
|
|
1973
|
+
const list = new SinglyLinkedList<number>([10, 20, 30]);
|
|
1974
|
+
console.log(list.shift()); // 10;
|
|
1975
|
+
console.log(list.length); // 2;
|
|
1976
|
+
```
|
|
1977
|
+
|
|
1978
|
+
#### Inherited from
|
|
1979
|
+
|
|
1980
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`shift`](SinglyLinkedList.md#shift)
|
|
1981
|
+
|
|
1982
|
+
***
|
|
1983
|
+
|
|
1984
|
+
### slice()
|
|
1985
|
+
|
|
1986
|
+
```ts
|
|
1987
|
+
slice(start?, end?): this;
|
|
1988
|
+
```
|
|
1989
|
+
|
|
1990
|
+
Defined in: [data-structures/base/linear-base.ts:494](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L494)
|
|
1991
|
+
|
|
1992
|
+
Slice via forward iteration (no random access required).
|
|
1993
|
+
|
|
1994
|
+
#### Parameters
|
|
1995
|
+
|
|
1996
|
+
##### start?
|
|
1997
|
+
|
|
1998
|
+
`number` = `0`
|
|
1999
|
+
|
|
2000
|
+
Inclusive start (supports negative index).
|
|
2001
|
+
|
|
2002
|
+
##### end?
|
|
2003
|
+
|
|
2004
|
+
`number` = `...`
|
|
2005
|
+
|
|
2006
|
+
Exclusive end (supports negative index).
|
|
2007
|
+
|
|
2008
|
+
#### Returns
|
|
2009
|
+
|
|
2010
|
+
`this`
|
|
2011
|
+
|
|
2012
|
+
New list (`this` type).
|
|
2013
|
+
|
|
2014
|
+
#### Remarks
|
|
2015
|
+
|
|
2016
|
+
Time O(n), Space O(n)
|
|
2017
|
+
|
|
2018
|
+
#### Inherited from
|
|
2019
|
+
|
|
2020
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`slice`](SinglyLinkedList.md#slice)
|
|
2021
|
+
|
|
2022
|
+
***
|
|
2023
|
+
|
|
2024
|
+
### some()
|
|
2025
|
+
|
|
2026
|
+
```ts
|
|
2027
|
+
some(predicate, thisArg?): boolean;
|
|
2028
|
+
```
|
|
2029
|
+
|
|
2030
|
+
Defined in: [data-structures/base/iterable-element-base.ts:109](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-element-base.ts#L109)
|
|
2031
|
+
|
|
2032
|
+
Tests whether at least one element satisfies the predicate.
|
|
2033
|
+
|
|
2034
|
+
#### Parameters
|
|
2035
|
+
|
|
2036
|
+
##### predicate
|
|
2037
|
+
|
|
2038
|
+
`ElementCallback`\<`E`, `R`, `boolean`\>
|
|
2039
|
+
|
|
2040
|
+
Function invoked for each element with signature `(value, index, self)`.
|
|
2041
|
+
|
|
2042
|
+
##### thisArg?
|
|
2043
|
+
|
|
2044
|
+
`unknown`
|
|
2045
|
+
|
|
2046
|
+
Optional `this` binding for the predicate.
|
|
2047
|
+
|
|
2048
|
+
#### Returns
|
|
2049
|
+
|
|
2050
|
+
`boolean`
|
|
2051
|
+
|
|
2052
|
+
`true` if any element passes; otherwise `false`.
|
|
2053
|
+
|
|
2054
|
+
#### Remarks
|
|
2055
|
+
|
|
2056
|
+
Time O(n) in the worst case; may exit early on first success. Space O(1).
|
|
2057
|
+
|
|
2058
|
+
#### Inherited from
|
|
2059
|
+
|
|
2060
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`some`](SinglyLinkedList.md#some)
|
|
2061
|
+
|
|
2062
|
+
***
|
|
2063
|
+
|
|
2064
|
+
### sort()
|
|
2065
|
+
|
|
2066
|
+
```ts
|
|
2067
|
+
sort(compareFn?): this;
|
|
2068
|
+
```
|
|
2069
|
+
|
|
2070
|
+
Defined in: [data-structures/base/linear-base.ts:185](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L185)
|
|
2071
|
+
|
|
2072
|
+
In-place stable order via array sort semantics.
|
|
2073
|
+
|
|
2074
|
+
#### Parameters
|
|
2075
|
+
|
|
2076
|
+
##### compareFn?
|
|
2077
|
+
|
|
2078
|
+
(`a`, `b`) => `number`
|
|
2079
|
+
|
|
2080
|
+
Comparator `(a, b) => number`.
|
|
2081
|
+
|
|
2082
|
+
#### Returns
|
|
2083
|
+
|
|
2084
|
+
`this`
|
|
2085
|
+
|
|
2086
|
+
This container.
|
|
2087
|
+
|
|
2088
|
+
#### Remarks
|
|
2089
|
+
|
|
2090
|
+
Time O(n log n), Space O(n) (materializes to array temporarily)
|
|
2091
|
+
|
|
2092
|
+
#### Inherited from
|
|
2093
|
+
|
|
2094
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`sort`](SinglyLinkedList.md#sort)
|
|
2095
|
+
|
|
2096
|
+
***
|
|
2097
|
+
|
|
2098
|
+
### splice()
|
|
2099
|
+
|
|
2100
|
+
```ts
|
|
2101
|
+
splice(
|
|
2102
|
+
start,
|
|
2103
|
+
deleteCount?, ...
|
|
2104
|
+
items?): this;
|
|
2105
|
+
```
|
|
2106
|
+
|
|
2107
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:1077](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L1077)
|
|
2108
|
+
|
|
2109
|
+
Remove and/or insert elements at a position (array-like behavior).
|
|
2110
|
+
|
|
2111
|
+
#### Parameters
|
|
2112
|
+
|
|
2113
|
+
##### start
|
|
2114
|
+
|
|
2115
|
+
`number`
|
|
2116
|
+
|
|
2117
|
+
Start index (clamped to [0, length]).
|
|
2118
|
+
|
|
2119
|
+
##### deleteCount?
|
|
2120
|
+
|
|
2121
|
+
`number` = `0`
|
|
2122
|
+
|
|
2123
|
+
Number of elements to remove (default 0).
|
|
2124
|
+
|
|
2125
|
+
##### items?
|
|
2126
|
+
|
|
2127
|
+
...`E`[]
|
|
2128
|
+
|
|
2129
|
+
Elements to insert after `start`.
|
|
2130
|
+
|
|
2131
|
+
#### Returns
|
|
2132
|
+
|
|
2133
|
+
`this`
|
|
2134
|
+
|
|
2135
|
+
A new list containing the removed elements (typed as `this`).
|
|
2136
|
+
|
|
2137
|
+
#### Remarks
|
|
2138
|
+
|
|
2139
|
+
Time O(N + M), Space O(M)
|
|
2140
|
+
|
|
2141
|
+
#### Inherited from
|
|
2142
|
+
|
|
2143
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`splice`](SinglyLinkedList.md#splice)
|
|
2144
|
+
|
|
2145
|
+
***
|
|
2146
|
+
|
|
2147
|
+
### toArray()
|
|
2148
|
+
|
|
2149
|
+
```ts
|
|
2150
|
+
toArray(): E[];
|
|
2151
|
+
```
|
|
2152
|
+
|
|
2153
|
+
Defined in: [data-structures/base/iterable-element-base.ts:245](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-element-base.ts#L245)
|
|
2154
|
+
|
|
2155
|
+
Materializes the elements into a new array.
|
|
2156
|
+
|
|
2157
|
+
#### Returns
|
|
2158
|
+
|
|
2159
|
+
`E`[]
|
|
2160
|
+
|
|
2161
|
+
A shallow array copy of the iteration order.
|
|
2162
|
+
|
|
2163
|
+
#### Remarks
|
|
2164
|
+
|
|
2165
|
+
Time O(n), Space O(n).
|
|
2166
|
+
|
|
2167
|
+
#### Inherited from
|
|
2168
|
+
|
|
2169
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`toArray`](SinglyLinkedList.md#toarray)
|
|
2170
|
+
|
|
2171
|
+
***
|
|
2172
|
+
|
|
2173
|
+
### toReversedArray()
|
|
2174
|
+
|
|
2175
|
+
```ts
|
|
2176
|
+
toReversedArray(): E[];
|
|
2177
|
+
```
|
|
2178
|
+
|
|
2179
|
+
Defined in: [data-structures/base/linear-base.ts:237](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L237)
|
|
2180
|
+
|
|
2181
|
+
Snapshot elements into a reversed array.
|
|
2182
|
+
|
|
2183
|
+
#### Returns
|
|
2184
|
+
|
|
2185
|
+
`E`[]
|
|
2186
|
+
|
|
2187
|
+
New reversed array.
|
|
2188
|
+
|
|
2189
|
+
#### Remarks
|
|
2190
|
+
|
|
2191
|
+
Time O(n), Space O(n)
|
|
2192
|
+
|
|
2193
|
+
#### Inherited from
|
|
2194
|
+
|
|
2195
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`toReversedArray`](SinglyLinkedList.md#toreversedarray)
|
|
2196
|
+
|
|
2197
|
+
***
|
|
2198
|
+
|
|
2199
|
+
### toVisual()
|
|
2200
|
+
|
|
2201
|
+
```ts
|
|
2202
|
+
toVisual(): E[];
|
|
2203
|
+
```
|
|
2204
|
+
|
|
2205
|
+
Defined in: [data-structures/base/iterable-element-base.ts:257](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-element-base.ts#L257)
|
|
2206
|
+
|
|
2207
|
+
Returns a representation of the structure suitable for quick visualization.
|
|
2208
|
+
Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
2209
|
+
|
|
2210
|
+
#### Returns
|
|
2211
|
+
|
|
2212
|
+
`E`[]
|
|
2213
|
+
|
|
2214
|
+
A visual representation (array by default).
|
|
2215
|
+
|
|
2216
|
+
#### Remarks
|
|
2217
|
+
|
|
2218
|
+
Time O(n), Space O(n).
|
|
2219
|
+
|
|
2220
|
+
#### Inherited from
|
|
2221
|
+
|
|
2222
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`toVisual`](SinglyLinkedList.md#tovisual)
|
|
2223
|
+
|
|
2224
|
+
***
|
|
2225
|
+
|
|
2226
|
+
### unshift()
|
|
2227
|
+
|
|
2228
|
+
```ts
|
|
2229
|
+
unshift(elementOrNode): boolean;
|
|
2230
|
+
```
|
|
2231
|
+
|
|
2232
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:527](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L527)
|
|
2233
|
+
|
|
2234
|
+
Prepend an element/node to the head.
|
|
2235
|
+
|
|
2236
|
+
#### Parameters
|
|
2237
|
+
|
|
2238
|
+
##### elementOrNode
|
|
2239
|
+
|
|
2240
|
+
`E` \| [`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\>
|
|
2241
|
+
|
|
2242
|
+
Element or node to prepend.
|
|
2243
|
+
|
|
2244
|
+
#### Returns
|
|
2245
|
+
|
|
2246
|
+
`boolean`
|
|
2247
|
+
|
|
2248
|
+
True when prepended.
|
|
2249
|
+
|
|
2250
|
+
*
|
|
2251
|
+
|
|
2252
|
+
#### Remarks
|
|
2253
|
+
|
|
2254
|
+
Time O(1), Space O(1)
|
|
2255
|
+
|
|
2256
|
+
#### Example
|
|
2257
|
+
|
|
2258
|
+
```ts
|
|
2259
|
+
// SinglyLinkedList unshift and forward traversal
|
|
2260
|
+
const list = new SinglyLinkedList<number>([20, 30, 40]);
|
|
2261
|
+
|
|
2262
|
+
// Unshift adds to the beginning
|
|
2263
|
+
list.unshift(10);
|
|
2264
|
+
console.log([...list]); // [10, 20, 30, 40];
|
|
2265
|
+
|
|
2266
|
+
// Access elements (forward traversal only for singly linked)
|
|
2267
|
+
const second = list.at(1);
|
|
2268
|
+
console.log(second); // 20;
|
|
2269
|
+
|
|
2270
|
+
// SinglyLinkedList allows forward iteration only
|
|
2271
|
+
const elements: number[] = [];
|
|
2272
|
+
for (const item of list) {
|
|
2273
|
+
elements.push(item);
|
|
2274
|
+
}
|
|
2275
|
+
console.log(elements); // [10, 20, 30, 40];
|
|
2276
|
+
|
|
2277
|
+
console.log(list.length); // 4;
|
|
2278
|
+
```
|
|
2279
|
+
|
|
2280
|
+
#### Inherited from
|
|
2281
|
+
|
|
2282
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`unshift`](SinglyLinkedList.md#unshift)
|
|
2283
|
+
|
|
2284
|
+
***
|
|
2285
|
+
|
|
2286
|
+
### unshiftMany()
|
|
2287
|
+
|
|
2288
|
+
```ts
|
|
2289
|
+
unshiftMany(elements): boolean[];
|
|
2290
|
+
```
|
|
2291
|
+
|
|
2292
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:562](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L562)
|
|
2293
|
+
|
|
2294
|
+
Prepend a sequence of elements/nodes.
|
|
2295
|
+
|
|
2296
|
+
#### Parameters
|
|
2297
|
+
|
|
2298
|
+
##### elements
|
|
2299
|
+
|
|
2300
|
+
\| `Iterable`\<`E`, `any`, `any`\>
|
|
2301
|
+
\| `Iterable`\<`R`, `any`, `any`\>
|
|
2302
|
+
\| `Iterable`\<[`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\>, `any`, `any`\>
|
|
2303
|
+
|
|
2304
|
+
Iterable of elements or nodes (or raw records if toElementFn is provided).
|
|
2305
|
+
|
|
2306
|
+
#### Returns
|
|
2307
|
+
|
|
2308
|
+
`boolean`[]
|
|
2309
|
+
|
|
2310
|
+
Array of per-element success flags.
|
|
2311
|
+
|
|
2312
|
+
#### Remarks
|
|
2313
|
+
|
|
2314
|
+
Time O(N), Space O(1)
|
|
2315
|
+
|
|
2316
|
+
#### Inherited from
|
|
2317
|
+
|
|
2318
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`unshiftMany`](SinglyLinkedList.md#unshiftmany)
|
|
2319
|
+
|
|
2320
|
+
***
|
|
2321
|
+
|
|
2322
|
+
### values()
|
|
2323
|
+
|
|
2324
|
+
```ts
|
|
2325
|
+
values(): IterableIterator<E>;
|
|
2326
|
+
```
|
|
2327
|
+
|
|
2328
|
+
Defined in: [data-structures/base/iterable-element-base.ts:71](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-element-base.ts#L71)
|
|
2329
|
+
|
|
2330
|
+
Returns an iterator over the values (alias of the default iterator).
|
|
2331
|
+
|
|
2332
|
+
#### Returns
|
|
2333
|
+
|
|
2334
|
+
`IterableIterator`\<`E`\>
|
|
2335
|
+
|
|
2336
|
+
An `IterableIterator<E>` over all elements.
|
|
2337
|
+
|
|
2338
|
+
#### Remarks
|
|
2339
|
+
|
|
2340
|
+
Creating the iterator is O(1); full iteration is Time O(n), Space O(1).
|
|
2341
|
+
|
|
2342
|
+
#### Inherited from
|
|
2343
|
+
|
|
2344
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`values`](SinglyLinkedList.md#values)
|
|
2345
|
+
|
|
2346
|
+
***
|
|
2347
|
+
|
|
2348
|
+
### from()
|
|
2349
|
+
|
|
2350
|
+
```ts
|
|
2351
|
+
static from<E, R, S>(
|
|
2352
|
+
this,
|
|
2353
|
+
data,
|
|
2354
|
+
options?): S;
|
|
2355
|
+
```
|
|
2356
|
+
|
|
2357
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:281](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L281)
|
|
2358
|
+
|
|
2359
|
+
Create a new list from an iterable of elements.
|
|
2360
|
+
|
|
2361
|
+
#### Type Parameters
|
|
2362
|
+
|
|
2363
|
+
##### E
|
|
2364
|
+
|
|
2365
|
+
`E`
|
|
2366
|
+
|
|
2367
|
+
##### R
|
|
2368
|
+
|
|
2369
|
+
`R` = `any`
|
|
2370
|
+
|
|
2371
|
+
##### S
|
|
2372
|
+
|
|
2373
|
+
`S` *extends* [`SinglyLinkedList`](SinglyLinkedList.md)\<`E`, `R`\> = [`SinglyLinkedList`](SinglyLinkedList.md)\<`E`, `R`\>
|
|
2374
|
+
|
|
2375
|
+
#### Parameters
|
|
2376
|
+
|
|
2377
|
+
##### this
|
|
2378
|
+
|
|
2379
|
+
`Object`
|
|
2380
|
+
|
|
2381
|
+
The constructor (subclass) to instantiate.
|
|
2382
|
+
|
|
2383
|
+
##### data
|
|
2384
|
+
|
|
2385
|
+
`Iterable`\<`E`\>
|
|
2386
|
+
|
|
2387
|
+
Iterable of elements to insert.
|
|
2388
|
+
|
|
2389
|
+
##### options?
|
|
2390
|
+
|
|
2391
|
+
`SinglyLinkedListOptions`\<`E`, `R`\>
|
|
2392
|
+
|
|
2393
|
+
Options forwarded to the constructor.
|
|
2394
|
+
|
|
2395
|
+
#### Returns
|
|
2396
|
+
|
|
2397
|
+
`S`
|
|
2398
|
+
|
|
2399
|
+
A new list populated with the iterable's elements.
|
|
2400
|
+
|
|
2401
|
+
#### Remarks
|
|
2402
|
+
|
|
2403
|
+
Time O(N), Space O(N)
|
|
2404
|
+
|
|
2405
|
+
#### Inherited from
|
|
2406
|
+
|
|
2407
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`from`](SinglyLinkedList.md#from)
|
|
2408
|
+
|
|
2409
|
+
|
|
2410
|
+
---
|
|
2411
|
+
|
|
2412
|
+
## Protected Members
|
|
2413
|
+
|
|
2414
|
+
### \_toElementFn?
|
|
2415
|
+
|
|
2416
|
+
```ts
|
|
2417
|
+
protected optional _toElementFn?: (rawElement) => E;
|
|
2418
|
+
```
|
|
2419
|
+
|
|
2420
|
+
Defined in: [data-structures/base/iterable-element-base.ts:38](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-element-base.ts#L38)
|
|
2421
|
+
|
|
2422
|
+
The converter used to transform a raw element (`R`) into a public element (`E`).
|
|
2423
|
+
|
|
2424
|
+
#### Parameters
|
|
2425
|
+
|
|
2426
|
+
##### rawElement
|
|
2427
|
+
|
|
2428
|
+
`R`
|
|
2429
|
+
|
|
2430
|
+
#### Returns
|
|
2431
|
+
|
|
2432
|
+
`E`
|
|
2433
|
+
|
|
2434
|
+
#### Remarks
|
|
2435
|
+
|
|
2436
|
+
Time O(1), Space O(1).
|
|
2437
|
+
|
|
2438
|
+
#### Inherited from
|
|
2439
|
+
|
|
2440
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`_toElementFn`](SinglyLinkedList.md#_toelementfn)
|
|
2441
|
+
|
|
2442
|
+
## Accessors
|
|
2443
|
+
|
|
2444
|
+
### \_createInstance()
|
|
2445
|
+
|
|
2446
|
+
```ts
|
|
2447
|
+
protected _createInstance(options?): this;
|
|
2448
|
+
```
|
|
2449
|
+
|
|
2450
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:1473](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L1473)
|
|
2451
|
+
|
|
2452
|
+
(Protected) Create an empty instance of the same concrete class.
|
|
2453
|
+
|
|
2454
|
+
#### Parameters
|
|
2455
|
+
|
|
2456
|
+
##### options?
|
|
2457
|
+
|
|
2458
|
+
`SinglyLinkedListOptions`\<`E`, `R`\>
|
|
2459
|
+
|
|
2460
|
+
Options forwarded to the constructor.
|
|
2461
|
+
|
|
2462
|
+
#### Returns
|
|
2463
|
+
|
|
2464
|
+
`this`
|
|
2465
|
+
|
|
2466
|
+
An empty like-kind list instance.
|
|
2467
|
+
|
|
2468
|
+
#### Remarks
|
|
2469
|
+
|
|
2470
|
+
Time O(1), Space O(1)
|
|
2471
|
+
|
|
2472
|
+
#### Inherited from
|
|
2473
|
+
|
|
2474
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`_createInstance`](SinglyLinkedList.md#_createinstance)
|
|
2475
|
+
|
|
2476
|
+
***
|
|
2477
|
+
|
|
2478
|
+
### \_createLike()
|
|
2479
|
+
|
|
2480
|
+
```ts
|
|
2481
|
+
protected _createLike<EM, RM>(elements?, options?): SinglyLinkedList<EM, RM>;
|
|
2482
|
+
```
|
|
2483
|
+
|
|
2484
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:1491](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L1491)
|
|
2485
|
+
|
|
2486
|
+
(Protected) Create a like-kind instance and seed it from an iterable.
|
|
2487
|
+
|
|
2488
|
+
#### Type Parameters
|
|
2489
|
+
|
|
2490
|
+
##### EM
|
|
2491
|
+
|
|
2492
|
+
`EM`
|
|
2493
|
+
|
|
2494
|
+
##### RM
|
|
2495
|
+
|
|
2496
|
+
`RM`
|
|
2497
|
+
|
|
2498
|
+
#### Parameters
|
|
2499
|
+
|
|
2500
|
+
##### elements?
|
|
2501
|
+
|
|
2502
|
+
\| `Iterable`\<`EM`, `any`, `any`\>
|
|
2503
|
+
\| `Iterable`\<`RM`, `any`, `any`\>
|
|
2504
|
+
\| `Iterable`\<[`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`EM`\>, `any`, `any`\>
|
|
2505
|
+
|
|
2506
|
+
Iterable used to seed the new list.
|
|
2507
|
+
|
|
2508
|
+
##### options?
|
|
2509
|
+
|
|
2510
|
+
`SinglyLinkedListOptions`\<`EM`, `RM`\>
|
|
2511
|
+
|
|
2512
|
+
Options forwarded to the constructor.
|
|
2513
|
+
|
|
2514
|
+
#### Returns
|
|
2515
|
+
|
|
2516
|
+
[`SinglyLinkedList`](SinglyLinkedList.md)\<`EM`, `RM`\>
|
|
2517
|
+
|
|
2518
|
+
A like-kind SinglyLinkedList instance.
|
|
2519
|
+
|
|
2520
|
+
#### Remarks
|
|
2521
|
+
|
|
2522
|
+
Time O(N), Space O(N)
|
|
2523
|
+
|
|
2524
|
+
#### Inherited from
|
|
2525
|
+
|
|
2526
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`_createLike`](SinglyLinkedList.md#_createlike)
|
|
2527
|
+
|
|
2528
|
+
***
|
|
2529
|
+
|
|
2530
|
+
### \_ensureNode()
|
|
2531
|
+
|
|
2532
|
+
```ts
|
|
2533
|
+
protected _ensureNode(elementOrNode): SinglyLinkedListNode<E>;
|
|
2534
|
+
```
|
|
2535
|
+
|
|
2536
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:1392](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L1392)
|
|
2537
|
+
|
|
2538
|
+
(Protected) Normalize input into a node instance.
|
|
2539
|
+
|
|
2540
|
+
#### Parameters
|
|
2541
|
+
|
|
2542
|
+
##### elementOrNode
|
|
2543
|
+
|
|
2544
|
+
`E` \| [`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\>
|
|
2545
|
+
|
|
2546
|
+
Element or node.
|
|
2547
|
+
|
|
2548
|
+
#### Returns
|
|
2549
|
+
|
|
2550
|
+
[`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\>
|
|
2551
|
+
|
|
2552
|
+
A SinglyLinkedListNode for the provided input.
|
|
2553
|
+
|
|
2554
|
+
#### Remarks
|
|
2555
|
+
|
|
2556
|
+
Time O(1), Space O(1)
|
|
2557
|
+
|
|
2558
|
+
#### Inherited from
|
|
2559
|
+
|
|
2560
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`_ensureNode`](SinglyLinkedList.md#_ensurenode)
|
|
2561
|
+
|
|
2562
|
+
***
|
|
2563
|
+
|
|
2564
|
+
### \_ensurePredicate()
|
|
2565
|
+
|
|
2566
|
+
```ts
|
|
2567
|
+
protected _ensurePredicate(elementNodeOrPredicate): (node) => boolean;
|
|
2568
|
+
```
|
|
2569
|
+
|
|
2570
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:1404](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L1404)
|
|
2571
|
+
|
|
2572
|
+
(Protected) Normalize input into a node predicate.
|
|
2573
|
+
|
|
2574
|
+
#### Parameters
|
|
2575
|
+
|
|
2576
|
+
##### elementNodeOrPredicate
|
|
2577
|
+
|
|
2578
|
+
\| `E`
|
|
2579
|
+
\| [`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\>
|
|
2580
|
+
\| ((`node`) => `boolean`)
|
|
2581
|
+
|
|
2582
|
+
Element, node, or predicate.
|
|
2583
|
+
|
|
2584
|
+
#### Returns
|
|
2585
|
+
|
|
2586
|
+
A predicate taking a node and returning true/false.
|
|
2587
|
+
|
|
2588
|
+
(`node`) => `boolean`
|
|
2589
|
+
|
|
2590
|
+
#### Remarks
|
|
2591
|
+
|
|
2592
|
+
Time O(1), Space O(1)
|
|
2593
|
+
|
|
2594
|
+
#### Inherited from
|
|
2595
|
+
|
|
2596
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`_ensurePredicate`](SinglyLinkedList.md#_ensurepredicate)
|
|
2597
|
+
|
|
2598
|
+
***
|
|
2599
|
+
|
|
2600
|
+
### \_getIterator()
|
|
2601
|
+
|
|
2602
|
+
```ts
|
|
2603
|
+
protected _getIterator(): IterableIterator<E>;
|
|
2604
|
+
```
|
|
2605
|
+
|
|
2606
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:1433](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L1433)
|
|
2607
|
+
|
|
2608
|
+
(Protected) Iterate values from head to tail.
|
|
2609
|
+
|
|
2610
|
+
#### Returns
|
|
2611
|
+
|
|
2612
|
+
`IterableIterator`\<`E`\>
|
|
2613
|
+
|
|
2614
|
+
Iterator of values (E).
|
|
2615
|
+
|
|
2616
|
+
#### Remarks
|
|
2617
|
+
|
|
2618
|
+
Time O(N), Space O(1)
|
|
2619
|
+
|
|
2620
|
+
#### Inherited from
|
|
2621
|
+
|
|
2622
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`_getIterator`](SinglyLinkedList.md#_getiterator)
|
|
2623
|
+
|
|
2624
|
+
***
|
|
2625
|
+
|
|
2626
|
+
### \_getNodeIterator()
|
|
2627
|
+
|
|
2628
|
+
```ts
|
|
2629
|
+
protected _getNodeIterator(): IterableIterator<SinglyLinkedListNode<E>>;
|
|
2630
|
+
```
|
|
2631
|
+
|
|
2632
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:1458](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L1458)
|
|
2633
|
+
|
|
2634
|
+
(Protected) Iterate nodes from head to tail.
|
|
2635
|
+
|
|
2636
|
+
#### Returns
|
|
2637
|
+
|
|
2638
|
+
`IterableIterator`\<[`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\>\>
|
|
2639
|
+
|
|
2640
|
+
Iterator of nodes.
|
|
2641
|
+
|
|
2642
|
+
#### Remarks
|
|
2643
|
+
|
|
2644
|
+
Time O(N), Space O(1)
|
|
2645
|
+
|
|
2646
|
+
#### Inherited from
|
|
2647
|
+
|
|
2648
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`_getNodeIterator`](SinglyLinkedList.md#_getnodeiterator)
|
|
2649
|
+
|
|
2650
|
+
***
|
|
2651
|
+
|
|
2652
|
+
### \_getPrevNode()
|
|
2653
|
+
|
|
2654
|
+
```ts
|
|
2655
|
+
protected _getPrevNode(node): SinglyLinkedListNode<E> | undefined;
|
|
2656
|
+
```
|
|
2657
|
+
|
|
2658
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:1420](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L1420)
|
|
2659
|
+
|
|
2660
|
+
(Protected) Get the previous node of a given node.
|
|
2661
|
+
|
|
2662
|
+
#### Parameters
|
|
2663
|
+
|
|
2664
|
+
##### node
|
|
2665
|
+
|
|
2666
|
+
[`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\>
|
|
2667
|
+
|
|
2668
|
+
A node in the list.
|
|
2669
|
+
|
|
2670
|
+
#### Returns
|
|
2671
|
+
|
|
2672
|
+
[`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\> \| `undefined`
|
|
2673
|
+
|
|
2674
|
+
Previous node or undefined.
|
|
2675
|
+
|
|
2676
|
+
#### Remarks
|
|
2677
|
+
|
|
2678
|
+
Time O(N), Space O(1)
|
|
2679
|
+
|
|
2680
|
+
#### Inherited from
|
|
2681
|
+
|
|
2682
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`_getPrevNode`](SinglyLinkedList.md#_getprevnode)
|
|
2683
|
+
|
|
2684
|
+
***
|
|
2685
|
+
|
|
2686
|
+
### \_getReverseIterator()
|
|
2687
|
+
|
|
2688
|
+
```ts
|
|
2689
|
+
protected _getReverseIterator(): IterableIterator<E>;
|
|
2690
|
+
```
|
|
2691
|
+
|
|
2692
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:1447](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L1447)
|
|
2693
|
+
|
|
2694
|
+
(Protected) Iterate values from tail to head.
|
|
2695
|
+
|
|
2696
|
+
#### Returns
|
|
2697
|
+
|
|
2698
|
+
`IterableIterator`\<`E`\>
|
|
2699
|
+
|
|
2700
|
+
Iterator of values (E).
|
|
2701
|
+
|
|
2702
|
+
#### Remarks
|
|
2703
|
+
|
|
2704
|
+
Time O(N), Space O(N)
|
|
2705
|
+
|
|
2706
|
+
#### Inherited from
|
|
2707
|
+
|
|
2708
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`_getReverseIterator`](SinglyLinkedList.md#_getreverseiterator)
|
|
2709
|
+
|
|
2710
|
+
***
|
|
2711
|
+
|
|
2712
|
+
### \_isPredicate()
|
|
2713
|
+
|
|
2714
|
+
```ts
|
|
2715
|
+
protected _isPredicate(elementNodeOrPredicate): elementNodeOrPredicate is (node: SinglyLinkedListNode<E>) => boolean;
|
|
2716
|
+
```
|
|
2717
|
+
|
|
2718
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:1379](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L1379)
|
|
2719
|
+
|
|
2720
|
+
(Protected) Check if input is a node predicate function.
|
|
2721
|
+
|
|
2722
|
+
#### Parameters
|
|
2723
|
+
|
|
2724
|
+
##### elementNodeOrPredicate
|
|
2725
|
+
|
|
2726
|
+
\| `E`
|
|
2727
|
+
\| [`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\>
|
|
2728
|
+
\| ((`node`) => `boolean`)
|
|
2729
|
+
|
|
2730
|
+
Element, node, or node predicate.
|
|
2731
|
+
|
|
2732
|
+
#### Returns
|
|
2733
|
+
|
|
2734
|
+
`elementNodeOrPredicate is (node: SinglyLinkedListNode<E>) => boolean`
|
|
2735
|
+
|
|
2736
|
+
True if input is a predicate function.
|
|
2737
|
+
|
|
2738
|
+
#### Remarks
|
|
2739
|
+
|
|
2740
|
+
Time O(1), Space O(1)
|
|
2741
|
+
|
|
2742
|
+
#### Inherited from
|
|
2743
|
+
|
|
2744
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`_isPredicate`](SinglyLinkedList.md#_ispredicate)
|
|
2745
|
+
|
|
2746
|
+
***
|
|
2747
|
+
|
|
2748
|
+
### \_spawnLike()
|
|
2749
|
+
|
|
2750
|
+
```ts
|
|
2751
|
+
protected _spawnLike<EM, RM>(options?): SinglyLinkedList<EM, RM>;
|
|
2752
|
+
```
|
|
2753
|
+
|
|
2754
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:1511](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L1511)
|
|
2755
|
+
|
|
2756
|
+
(Protected) Spawn an empty like-kind list instance.
|
|
2757
|
+
|
|
2758
|
+
#### Type Parameters
|
|
2759
|
+
|
|
2760
|
+
##### EM
|
|
2761
|
+
|
|
2762
|
+
`EM`
|
|
2763
|
+
|
|
2764
|
+
##### RM
|
|
2765
|
+
|
|
2766
|
+
`RM`
|
|
2767
|
+
|
|
2768
|
+
#### Parameters
|
|
2769
|
+
|
|
2770
|
+
##### options?
|
|
2771
|
+
|
|
2772
|
+
`SinglyLinkedListOptions`\<`EM`, `RM`\>
|
|
2773
|
+
|
|
2774
|
+
Options forwarded to the constructor.
|
|
2775
|
+
|
|
2776
|
+
#### Returns
|
|
2777
|
+
|
|
2778
|
+
[`SinglyLinkedList`](SinglyLinkedList.md)\<`EM`, `RM`\>
|
|
2779
|
+
|
|
2780
|
+
An empty like-kind SinglyLinkedList instance.
|
|
2781
|
+
|
|
2782
|
+
#### Remarks
|
|
2783
|
+
|
|
2784
|
+
Time O(1), Space O(1)
|
|
2785
|
+
|
|
2786
|
+
#### Inherited from
|
|
2787
|
+
|
|
2788
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`_spawnLike`](SinglyLinkedList.md#_spawnlike)
|
|
2789
|
+
|
|
2790
|
+
***
|
|
2791
|
+
|
|
2792
|
+
### createNode()
|
|
2793
|
+
|
|
2794
|
+
```ts
|
|
2795
|
+
protected createNode(value): SinglyLinkedListNode<E>;
|
|
2796
|
+
```
|
|
2797
|
+
|
|
2798
|
+
Defined in: [data-structures/linked-list/singly-linked-list.ts:1368](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/linked-list/singly-linked-list.ts#L1368)
|
|
2799
|
+
|
|
2800
|
+
(Protected) Create a node from a value.
|
|
2801
|
+
|
|
2802
|
+
#### Parameters
|
|
2803
|
+
|
|
2804
|
+
##### value
|
|
2805
|
+
|
|
2806
|
+
`E`
|
|
2807
|
+
|
|
2808
|
+
Value to wrap in a node.
|
|
2809
|
+
|
|
2810
|
+
#### Returns
|
|
2811
|
+
|
|
2812
|
+
[`SinglyLinkedListNode`](SinglyLinkedListNode.md)\<`E`\>
|
|
2813
|
+
|
|
2814
|
+
A new SinglyLinkedListNode instance.
|
|
2815
|
+
|
|
2816
|
+
#### Remarks
|
|
2817
|
+
|
|
2818
|
+
Time O(1), Space O(1)
|
|
2819
|
+
|
|
2820
|
+
#### Inherited from
|
|
2821
|
+
|
|
2822
|
+
[`SinglyLinkedList`](SinglyLinkedList.md).[`createNode`](SinglyLinkedList.md#createnode)
|
|
2823
|
+
|
|
2824
|
+
***
|