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,1632 @@
|
|
|
1
|
+
[**data-structure-typed**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[data-structure-typed](../README.md) / LinearBase
|
|
6
|
+
|
|
7
|
+
# Abstract Class: LinearBase\<E, R, NODE\>
|
|
8
|
+
|
|
9
|
+
Defined in: [data-structures/base/linear-base.ts:68](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L68)
|
|
10
|
+
|
|
11
|
+
Abstract linear container with array-like utilities.
|
|
12
|
+
|
|
13
|
+
## Remarks
|
|
14
|
+
|
|
15
|
+
Time O(1), Space O(1)
|
|
16
|
+
|
|
17
|
+
## Extends
|
|
18
|
+
|
|
19
|
+
- [`IterableElementBase`](IterableElementBase.md)\<`E`, `R`\>
|
|
20
|
+
|
|
21
|
+
## Extended by
|
|
22
|
+
|
|
23
|
+
- [`Queue`](Queue.md)
|
|
24
|
+
- [`Deque`](Deque.md)
|
|
25
|
+
- [`LinearLinkedBase`](LinearLinkedBase.md)
|
|
26
|
+
|
|
27
|
+
## Type Parameters
|
|
28
|
+
|
|
29
|
+
### E
|
|
30
|
+
|
|
31
|
+
`E`
|
|
32
|
+
|
|
33
|
+
Element type.
|
|
34
|
+
|
|
35
|
+
### R
|
|
36
|
+
|
|
37
|
+
`R` = `any`
|
|
38
|
+
|
|
39
|
+
Return type for mapped/derived views.
|
|
40
|
+
|
|
41
|
+
### NODE
|
|
42
|
+
|
|
43
|
+
`NODE` *extends* [`LinkedListNode`](LinkedListNode.md)\<`E`\> = [`LinkedListNode`](LinkedListNode.md)\<`E`\>
|
|
44
|
+
|
|
45
|
+
Linked node type used by some implementations.
|
|
46
|
+
|
|
47
|
+
## Constructors
|
|
48
|
+
|
|
49
|
+
### Constructor
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
new LinearBase<E, R, NODE>(options?): LinearBase<E, R, NODE>;
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Defined in: [data-structures/base/linear-base.ts:78](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L78)
|
|
56
|
+
|
|
57
|
+
Construct a linear container with runtime options.
|
|
58
|
+
|
|
59
|
+
#### Parameters
|
|
60
|
+
|
|
61
|
+
##### options?
|
|
62
|
+
|
|
63
|
+
`LinearBaseOptions`\<`E`, `R`\>
|
|
64
|
+
|
|
65
|
+
`{ maxLen?, ... }` bounds/behavior options.
|
|
66
|
+
|
|
67
|
+
#### Returns
|
|
68
|
+
|
|
69
|
+
`LinearBase`\<`E`, `R`, `NODE`\>
|
|
70
|
+
|
|
71
|
+
#### Remarks
|
|
72
|
+
|
|
73
|
+
Time O(1), Space O(1)
|
|
74
|
+
|
|
75
|
+
#### Overrides
|
|
76
|
+
|
|
77
|
+
[`IterableElementBase`](IterableElementBase.md).[`constructor`](IterableElementBase.md#constructor)
|
|
78
|
+
|
|
79
|
+
## Properties
|
|
80
|
+
|
|
81
|
+
### length
|
|
82
|
+
|
|
83
|
+
#### Get Signature
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
get abstract length(): number;
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Defined in: [data-structures/base/linear-base.ts:91](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L91)
|
|
90
|
+
|
|
91
|
+
Element count.
|
|
92
|
+
|
|
93
|
+
##### Remarks
|
|
94
|
+
|
|
95
|
+
Time O(1), Space O(1)
|
|
96
|
+
|
|
97
|
+
##### Returns
|
|
98
|
+
|
|
99
|
+
`number`
|
|
100
|
+
|
|
101
|
+
Number of elements.
|
|
102
|
+
|
|
103
|
+
***
|
|
104
|
+
|
|
105
|
+
### maxLen
|
|
106
|
+
|
|
107
|
+
#### Get Signature
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
get maxLen(): number;
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
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)
|
|
114
|
+
|
|
115
|
+
Upper bound for length (if positive), or `-1` when unbounded.
|
|
116
|
+
|
|
117
|
+
##### Remarks
|
|
118
|
+
|
|
119
|
+
Time O(1), Space O(1)
|
|
120
|
+
|
|
121
|
+
##### Returns
|
|
122
|
+
|
|
123
|
+
`number`
|
|
124
|
+
|
|
125
|
+
Maximum allowed length.
|
|
126
|
+
|
|
127
|
+
***
|
|
128
|
+
|
|
129
|
+
### toElementFn
|
|
130
|
+
|
|
131
|
+
#### Get Signature
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
get toElementFn(): ((rawElement) => E) | undefined;
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
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)
|
|
138
|
+
|
|
139
|
+
Exposes the current `toElementFn`, if configured.
|
|
140
|
+
|
|
141
|
+
##### Remarks
|
|
142
|
+
|
|
143
|
+
Time O(1), Space O(1).
|
|
144
|
+
|
|
145
|
+
##### Returns
|
|
146
|
+
|
|
147
|
+
((`rawElement`) => `E`) \| `undefined`
|
|
148
|
+
|
|
149
|
+
The converter function or `undefined` when not set.
|
|
150
|
+
|
|
151
|
+
#### Inherited from
|
|
152
|
+
|
|
153
|
+
[`IterableElementBase`](IterableElementBase.md).[`toElementFn`](IterableElementBase.md#toelementfn)
|
|
154
|
+
|
|
155
|
+
## Methods
|
|
156
|
+
|
|
157
|
+
### \[iterator\]()
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
iterator: IterableIterator<E>;
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
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)
|
|
164
|
+
|
|
165
|
+
Returns an iterator over the structure's elements.
|
|
166
|
+
|
|
167
|
+
#### Parameters
|
|
168
|
+
|
|
169
|
+
##### args
|
|
170
|
+
|
|
171
|
+
...`unknown`[]
|
|
172
|
+
|
|
173
|
+
Optional iterator arguments forwarded to the internal iterator.
|
|
174
|
+
|
|
175
|
+
#### Returns
|
|
176
|
+
|
|
177
|
+
`IterableIterator`\<`E`\>
|
|
178
|
+
|
|
179
|
+
An `IterableIterator<E>` that yields the elements in traversal order.
|
|
180
|
+
|
|
181
|
+
#### Remarks
|
|
182
|
+
|
|
183
|
+
Producing the iterator is O(1); consuming the entire iterator is Time O(n) with O(1) extra space.
|
|
184
|
+
|
|
185
|
+
#### Inherited from
|
|
186
|
+
|
|
187
|
+
[`IterableElementBase`](IterableElementBase.md).[`[iterator]`](IterableElementBase.md#iterator)
|
|
188
|
+
|
|
189
|
+
***
|
|
190
|
+
|
|
191
|
+
### addAt()
|
|
192
|
+
|
|
193
|
+
```ts
|
|
194
|
+
abstract addAt(index, newElementOrNode): boolean;
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Defined in: [data-structures/base/linear-base.ts:377](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L377)
|
|
198
|
+
|
|
199
|
+
Insert an element/node at a position.
|
|
200
|
+
|
|
201
|
+
#### Parameters
|
|
202
|
+
|
|
203
|
+
##### index
|
|
204
|
+
|
|
205
|
+
`number`
|
|
206
|
+
|
|
207
|
+
Position (0-based).
|
|
208
|
+
|
|
209
|
+
##### newElementOrNode
|
|
210
|
+
|
|
211
|
+
`E` \| `NODE`
|
|
212
|
+
|
|
213
|
+
Element or node to insert.
|
|
214
|
+
|
|
215
|
+
#### Returns
|
|
216
|
+
|
|
217
|
+
`boolean`
|
|
218
|
+
|
|
219
|
+
`true` if inserted.
|
|
220
|
+
|
|
221
|
+
#### Remarks
|
|
222
|
+
|
|
223
|
+
Time O(1)~O(n) depending on implementation, Space O(1)
|
|
224
|
+
|
|
225
|
+
***
|
|
226
|
+
|
|
227
|
+
### at()
|
|
228
|
+
|
|
229
|
+
```ts
|
|
230
|
+
abstract at(index): E | undefined;
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Defined in: [data-structures/base/linear-base.ts:360](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L360)
|
|
234
|
+
|
|
235
|
+
Get element at an index.
|
|
236
|
+
|
|
237
|
+
#### Parameters
|
|
238
|
+
|
|
239
|
+
##### index
|
|
240
|
+
|
|
241
|
+
`number`
|
|
242
|
+
|
|
243
|
+
Position (0-based).
|
|
244
|
+
|
|
245
|
+
#### Returns
|
|
246
|
+
|
|
247
|
+
`E` \| `undefined`
|
|
248
|
+
|
|
249
|
+
Element or `undefined`.
|
|
250
|
+
|
|
251
|
+
#### Remarks
|
|
252
|
+
|
|
253
|
+
Time O(1)~O(n) depending on implementation, Space O(1)
|
|
254
|
+
|
|
255
|
+
***
|
|
256
|
+
|
|
257
|
+
### clear()
|
|
258
|
+
|
|
259
|
+
```ts
|
|
260
|
+
abstract clear(): void;
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Defined in: [data-structures/base/iterable-element-base.ts:288](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-element-base.ts#L288)
|
|
264
|
+
|
|
265
|
+
Removes all elements from the structure.
|
|
266
|
+
|
|
267
|
+
#### Returns
|
|
268
|
+
|
|
269
|
+
`void`
|
|
270
|
+
|
|
271
|
+
`void`.
|
|
272
|
+
|
|
273
|
+
#### Remarks
|
|
274
|
+
|
|
275
|
+
Expected Time O(1) or O(n) depending on the implementation; Space O(1).
|
|
276
|
+
|
|
277
|
+
#### Inherited from
|
|
278
|
+
|
|
279
|
+
[`IterableElementBase`](IterableElementBase.md).[`clear`](IterableElementBase.md#clear)
|
|
280
|
+
|
|
281
|
+
***
|
|
282
|
+
|
|
283
|
+
### clone()
|
|
284
|
+
|
|
285
|
+
```ts
|
|
286
|
+
abstract clone(): this;
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Defined in: [data-structures/base/linear-base.ts:321](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L321)
|
|
290
|
+
|
|
291
|
+
Deep clone while preserving concrete subtype.
|
|
292
|
+
|
|
293
|
+
#### Returns
|
|
294
|
+
|
|
295
|
+
`this`
|
|
296
|
+
|
|
297
|
+
New list of the same species (`this` type).
|
|
298
|
+
|
|
299
|
+
#### Remarks
|
|
300
|
+
|
|
301
|
+
Time O(n), Space O(n)
|
|
302
|
+
|
|
303
|
+
#### Overrides
|
|
304
|
+
|
|
305
|
+
[`IterableElementBase`](IterableElementBase.md).[`clone`](IterableElementBase.md#clone)
|
|
306
|
+
|
|
307
|
+
***
|
|
308
|
+
|
|
309
|
+
### concat()
|
|
310
|
+
|
|
311
|
+
```ts
|
|
312
|
+
concat(...items): this;
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
Defined in: [data-structures/base/linear-base.ts:165](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L165)
|
|
316
|
+
|
|
317
|
+
Concatenate elements and/or containers.
|
|
318
|
+
|
|
319
|
+
#### Parameters
|
|
320
|
+
|
|
321
|
+
##### items
|
|
322
|
+
|
|
323
|
+
...(`E` \| `LinearBase`\<`E`, `R`, `NODE`\>)[]
|
|
324
|
+
|
|
325
|
+
Elements or other containers.
|
|
326
|
+
|
|
327
|
+
#### Returns
|
|
328
|
+
|
|
329
|
+
`this`
|
|
330
|
+
|
|
331
|
+
New container with combined elements (`this` type).
|
|
332
|
+
|
|
333
|
+
#### Remarks
|
|
334
|
+
|
|
335
|
+
Time O(sum(length)), Space O(sum(length))
|
|
336
|
+
|
|
337
|
+
***
|
|
338
|
+
|
|
339
|
+
### delete()
|
|
340
|
+
|
|
341
|
+
```ts
|
|
342
|
+
abstract delete(elementOrNode): boolean;
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
Defined in: [data-structures/base/linear-base.ts:352](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L352)
|
|
346
|
+
|
|
347
|
+
Remove one element or node if present.
|
|
348
|
+
|
|
349
|
+
#### Parameters
|
|
350
|
+
|
|
351
|
+
##### elementOrNode
|
|
352
|
+
|
|
353
|
+
`E` \| `NODE` \| `undefined`
|
|
354
|
+
|
|
355
|
+
Element or node to delete.
|
|
356
|
+
|
|
357
|
+
#### Returns
|
|
358
|
+
|
|
359
|
+
`boolean`
|
|
360
|
+
|
|
361
|
+
`true` if removed.
|
|
362
|
+
|
|
363
|
+
#### Remarks
|
|
364
|
+
|
|
365
|
+
Time O(1)~O(n) depending on implementation, Space O(1)
|
|
366
|
+
|
|
367
|
+
***
|
|
368
|
+
|
|
369
|
+
### deleteAt()
|
|
370
|
+
|
|
371
|
+
```ts
|
|
372
|
+
abstract deleteAt(pos): E | undefined;
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
Defined in: [data-structures/base/linear-base.ts:368](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L368)
|
|
376
|
+
|
|
377
|
+
Remove element at a position.
|
|
378
|
+
|
|
379
|
+
#### Parameters
|
|
380
|
+
|
|
381
|
+
##### pos
|
|
382
|
+
|
|
383
|
+
`number`
|
|
384
|
+
|
|
385
|
+
Position (0-based).
|
|
386
|
+
|
|
387
|
+
#### Returns
|
|
388
|
+
|
|
389
|
+
`E` \| `undefined`
|
|
390
|
+
|
|
391
|
+
Removed element or `undefined`.
|
|
392
|
+
|
|
393
|
+
#### Remarks
|
|
394
|
+
|
|
395
|
+
Time O(1)~O(n) depending on implementation, Space O(1)
|
|
396
|
+
|
|
397
|
+
***
|
|
398
|
+
|
|
399
|
+
### every()
|
|
400
|
+
|
|
401
|
+
```ts
|
|
402
|
+
every(predicate, thisArg?): boolean;
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
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)
|
|
406
|
+
|
|
407
|
+
Tests whether all elements satisfy the predicate.
|
|
408
|
+
|
|
409
|
+
#### Parameters
|
|
410
|
+
|
|
411
|
+
##### predicate
|
|
412
|
+
|
|
413
|
+
`ElementCallback`\<`E`, `R`, `boolean`\>
|
|
414
|
+
|
|
415
|
+
Function invoked for each element with signature `(value, index, self)`.
|
|
416
|
+
|
|
417
|
+
##### thisArg?
|
|
418
|
+
|
|
419
|
+
`unknown`
|
|
420
|
+
|
|
421
|
+
Optional `this` binding for the predicate.
|
|
422
|
+
|
|
423
|
+
#### Returns
|
|
424
|
+
|
|
425
|
+
`boolean`
|
|
426
|
+
|
|
427
|
+
`true` if every element passes; otherwise `false`.
|
|
428
|
+
|
|
429
|
+
#### Remarks
|
|
430
|
+
|
|
431
|
+
Time O(n) in the worst case; may exit early when the first failure is found. Space O(1).
|
|
432
|
+
|
|
433
|
+
#### Inherited from
|
|
434
|
+
|
|
435
|
+
[`IterableElementBase`](IterableElementBase.md).[`every`](IterableElementBase.md#every)
|
|
436
|
+
|
|
437
|
+
***
|
|
438
|
+
|
|
439
|
+
### fill()
|
|
440
|
+
|
|
441
|
+
```ts
|
|
442
|
+
fill(
|
|
443
|
+
value,
|
|
444
|
+
start?,
|
|
445
|
+
end?): this;
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
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)
|
|
449
|
+
|
|
450
|
+
Fill a range with a value.
|
|
451
|
+
|
|
452
|
+
#### Parameters
|
|
453
|
+
|
|
454
|
+
##### value
|
|
455
|
+
|
|
456
|
+
`E`
|
|
457
|
+
|
|
458
|
+
Value to set.
|
|
459
|
+
|
|
460
|
+
##### start?
|
|
461
|
+
|
|
462
|
+
`number` = `0`
|
|
463
|
+
|
|
464
|
+
Inclusive start.
|
|
465
|
+
|
|
466
|
+
##### end?
|
|
467
|
+
|
|
468
|
+
`number` = `...`
|
|
469
|
+
|
|
470
|
+
Exclusive end.
|
|
471
|
+
|
|
472
|
+
#### Returns
|
|
473
|
+
|
|
474
|
+
`this`
|
|
475
|
+
|
|
476
|
+
This list.
|
|
477
|
+
|
|
478
|
+
#### Remarks
|
|
479
|
+
|
|
480
|
+
Time O(n), Space O(1)
|
|
481
|
+
|
|
482
|
+
***
|
|
483
|
+
|
|
484
|
+
### filter()
|
|
485
|
+
|
|
486
|
+
```ts
|
|
487
|
+
abstract filter(predicate, thisArg?): this;
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
Defined in: [data-structures/base/iterable-element-base.ts:340](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-element-base.ts#L340)
|
|
491
|
+
|
|
492
|
+
Filters elements using the provided predicate and returns the same concrete structure type.
|
|
493
|
+
|
|
494
|
+
#### Parameters
|
|
495
|
+
|
|
496
|
+
##### predicate
|
|
497
|
+
|
|
498
|
+
`ElementCallback`\<`E`, `R`, `boolean`\>
|
|
499
|
+
|
|
500
|
+
Function with signature `(value, index, self) => boolean`.
|
|
501
|
+
|
|
502
|
+
##### thisArg?
|
|
503
|
+
|
|
504
|
+
`unknown`
|
|
505
|
+
|
|
506
|
+
Optional `this` binding for the predicate.
|
|
507
|
+
|
|
508
|
+
#### Returns
|
|
509
|
+
|
|
510
|
+
`this`
|
|
511
|
+
|
|
512
|
+
A new instance of the same concrete type containing only elements that pass the predicate.
|
|
513
|
+
|
|
514
|
+
#### Remarks
|
|
515
|
+
|
|
516
|
+
Time O(n), Space O(k) where `k` is the number of kept elements.
|
|
517
|
+
|
|
518
|
+
#### Inherited from
|
|
519
|
+
|
|
520
|
+
[`IterableElementBase`](IterableElementBase.md).[`filter`](IterableElementBase.md#filter)
|
|
521
|
+
|
|
522
|
+
***
|
|
523
|
+
|
|
524
|
+
### find()
|
|
525
|
+
|
|
526
|
+
#### Call Signature
|
|
527
|
+
|
|
528
|
+
```ts
|
|
529
|
+
find<S>(predicate, thisArg?): S | undefined;
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
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)
|
|
533
|
+
|
|
534
|
+
Finds the first element that satisfies the predicate and returns it.
|
|
535
|
+
|
|
536
|
+
Finds the first element of type `S` (a subtype of `E`) that satisfies the predicate and returns it.
|
|
537
|
+
|
|
538
|
+
##### Type Parameters
|
|
539
|
+
|
|
540
|
+
###### S
|
|
541
|
+
|
|
542
|
+
`S`
|
|
543
|
+
|
|
544
|
+
##### Parameters
|
|
545
|
+
|
|
546
|
+
###### predicate
|
|
547
|
+
|
|
548
|
+
`ElementCallback`\<`E`, `R`, `S`\>
|
|
549
|
+
|
|
550
|
+
Type-guard predicate: `(value, index, self) => value is S`.
|
|
551
|
+
|
|
552
|
+
###### thisArg?
|
|
553
|
+
|
|
554
|
+
`unknown`
|
|
555
|
+
|
|
556
|
+
Optional `this` binding for the predicate.
|
|
557
|
+
|
|
558
|
+
##### Returns
|
|
559
|
+
|
|
560
|
+
`S` \| `undefined`
|
|
561
|
+
|
|
562
|
+
The matched element typed as `S`, or `undefined` if not found.
|
|
563
|
+
|
|
564
|
+
##### Remarks
|
|
565
|
+
|
|
566
|
+
Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
567
|
+
|
|
568
|
+
##### Inherited from
|
|
569
|
+
|
|
570
|
+
[`IterableElementBase`](IterableElementBase.md).[`find`](IterableElementBase.md#find)
|
|
571
|
+
|
|
572
|
+
#### Call Signature
|
|
573
|
+
|
|
574
|
+
```ts
|
|
575
|
+
find(predicate, thisArg?): E | undefined;
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
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)
|
|
579
|
+
|
|
580
|
+
Finds the first element that satisfies the predicate and returns it.
|
|
581
|
+
|
|
582
|
+
Finds the first element of type `S` (a subtype of `E`) that satisfies the predicate and returns it.
|
|
583
|
+
|
|
584
|
+
##### Parameters
|
|
585
|
+
|
|
586
|
+
###### predicate
|
|
587
|
+
|
|
588
|
+
`ElementCallback`\<`E`, `R`, `unknown`\>
|
|
589
|
+
|
|
590
|
+
Type-guard predicate: `(value, index, self) => value is S`.
|
|
591
|
+
|
|
592
|
+
###### thisArg?
|
|
593
|
+
|
|
594
|
+
`unknown`
|
|
595
|
+
|
|
596
|
+
Optional `this` binding for the predicate.
|
|
597
|
+
|
|
598
|
+
##### Returns
|
|
599
|
+
|
|
600
|
+
`E` \| `undefined`
|
|
601
|
+
|
|
602
|
+
The matched element typed as `S`, or `undefined` if not found.
|
|
603
|
+
|
|
604
|
+
##### Remarks
|
|
605
|
+
|
|
606
|
+
Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
607
|
+
|
|
608
|
+
##### Inherited from
|
|
609
|
+
|
|
610
|
+
[`IterableElementBase`](IterableElementBase.md).[`find`](IterableElementBase.md#find)
|
|
611
|
+
|
|
612
|
+
***
|
|
613
|
+
|
|
614
|
+
### findIndex()
|
|
615
|
+
|
|
616
|
+
```ts
|
|
617
|
+
findIndex(predicate, thisArg?): number;
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
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)
|
|
621
|
+
|
|
622
|
+
Find the first index matching a predicate.
|
|
623
|
+
|
|
624
|
+
#### Parameters
|
|
625
|
+
|
|
626
|
+
##### predicate
|
|
627
|
+
|
|
628
|
+
`ElementCallback`\<`E`, `R`, `boolean`\>
|
|
629
|
+
|
|
630
|
+
`(element, index, self) => boolean`.
|
|
631
|
+
|
|
632
|
+
##### thisArg?
|
|
633
|
+
|
|
634
|
+
`any`
|
|
635
|
+
|
|
636
|
+
Optional `this` for callback.
|
|
637
|
+
|
|
638
|
+
#### Returns
|
|
639
|
+
|
|
640
|
+
`number`
|
|
641
|
+
|
|
642
|
+
Index or `-1`.
|
|
643
|
+
|
|
644
|
+
#### Remarks
|
|
645
|
+
|
|
646
|
+
Time O(n), Space O(1)
|
|
647
|
+
|
|
648
|
+
***
|
|
649
|
+
|
|
650
|
+
### forEach()
|
|
651
|
+
|
|
652
|
+
```ts
|
|
653
|
+
forEach(callbackfn, thisArg?): void;
|
|
654
|
+
```
|
|
655
|
+
|
|
656
|
+
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)
|
|
657
|
+
|
|
658
|
+
Invokes a callback for each element in iteration order.
|
|
659
|
+
|
|
660
|
+
#### Parameters
|
|
661
|
+
|
|
662
|
+
##### callbackfn
|
|
663
|
+
|
|
664
|
+
`ElementCallback`\<`E`, `R`, `void`\>
|
|
665
|
+
|
|
666
|
+
Function invoked per element with signature `(value, index, self)`.
|
|
667
|
+
|
|
668
|
+
##### thisArg?
|
|
669
|
+
|
|
670
|
+
`unknown`
|
|
671
|
+
|
|
672
|
+
Optional `this` binding for the callback.
|
|
673
|
+
|
|
674
|
+
#### Returns
|
|
675
|
+
|
|
676
|
+
`void`
|
|
677
|
+
|
|
678
|
+
`void`.
|
|
679
|
+
|
|
680
|
+
#### Remarks
|
|
681
|
+
|
|
682
|
+
Time O(n), Space O(1).
|
|
683
|
+
|
|
684
|
+
#### Inherited from
|
|
685
|
+
|
|
686
|
+
[`IterableElementBase`](IterableElementBase.md).[`forEach`](IterableElementBase.md#foreach)
|
|
687
|
+
|
|
688
|
+
***
|
|
689
|
+
|
|
690
|
+
### has()
|
|
691
|
+
|
|
692
|
+
```ts
|
|
693
|
+
has(element): boolean;
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
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)
|
|
697
|
+
|
|
698
|
+
Checks whether a strictly-equal element exists in the structure.
|
|
699
|
+
|
|
700
|
+
#### Parameters
|
|
701
|
+
|
|
702
|
+
##### element
|
|
703
|
+
|
|
704
|
+
`E`
|
|
705
|
+
|
|
706
|
+
The element to test with `===` equality.
|
|
707
|
+
|
|
708
|
+
#### Returns
|
|
709
|
+
|
|
710
|
+
`boolean`
|
|
711
|
+
|
|
712
|
+
`true` if an equal element is found; otherwise `false`.
|
|
713
|
+
|
|
714
|
+
#### Remarks
|
|
715
|
+
|
|
716
|
+
Time O(n) in the worst case. Space O(1).
|
|
717
|
+
|
|
718
|
+
#### Inherited from
|
|
719
|
+
|
|
720
|
+
[`IterableElementBase`](IterableElementBase.md).[`has`](IterableElementBase.md#has)
|
|
721
|
+
|
|
722
|
+
***
|
|
723
|
+
|
|
724
|
+
### indexOf()
|
|
725
|
+
|
|
726
|
+
```ts
|
|
727
|
+
indexOf(searchElement, fromIndex?): number;
|
|
728
|
+
```
|
|
729
|
+
|
|
730
|
+
Defined in: [data-structures/base/linear-base.ts:111](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L111)
|
|
731
|
+
|
|
732
|
+
First index of a value from the left.
|
|
733
|
+
|
|
734
|
+
#### Parameters
|
|
735
|
+
|
|
736
|
+
##### searchElement
|
|
737
|
+
|
|
738
|
+
`E`
|
|
739
|
+
|
|
740
|
+
Value to match.
|
|
741
|
+
|
|
742
|
+
##### fromIndex?
|
|
743
|
+
|
|
744
|
+
`number` = `0`
|
|
745
|
+
|
|
746
|
+
Start position (supports negative index).
|
|
747
|
+
|
|
748
|
+
#### Returns
|
|
749
|
+
|
|
750
|
+
`number`
|
|
751
|
+
|
|
752
|
+
Index or `-1` if not found.
|
|
753
|
+
|
|
754
|
+
#### Remarks
|
|
755
|
+
|
|
756
|
+
Time O(n), Space O(1)
|
|
757
|
+
|
|
758
|
+
***
|
|
759
|
+
|
|
760
|
+
### isEmpty()
|
|
761
|
+
|
|
762
|
+
```ts
|
|
763
|
+
abstract isEmpty(): boolean;
|
|
764
|
+
```
|
|
765
|
+
|
|
766
|
+
Defined in: [data-structures/base/iterable-element-base.ts:279](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-element-base.ts#L279)
|
|
767
|
+
|
|
768
|
+
Indicates whether the structure currently contains no elements.
|
|
769
|
+
|
|
770
|
+
#### Returns
|
|
771
|
+
|
|
772
|
+
`boolean`
|
|
773
|
+
|
|
774
|
+
`true` if empty; otherwise `false`.
|
|
775
|
+
|
|
776
|
+
#### Remarks
|
|
777
|
+
|
|
778
|
+
Expected Time O(1), Space O(1) for most implementations.
|
|
779
|
+
|
|
780
|
+
#### Inherited from
|
|
781
|
+
|
|
782
|
+
[`IterableElementBase`](IterableElementBase.md).[`isEmpty`](IterableElementBase.md#isempty)
|
|
783
|
+
|
|
784
|
+
***
|
|
785
|
+
|
|
786
|
+
### join()
|
|
787
|
+
|
|
788
|
+
```ts
|
|
789
|
+
join(separator?): string;
|
|
790
|
+
```
|
|
791
|
+
|
|
792
|
+
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)
|
|
793
|
+
|
|
794
|
+
Join all elements into a string.
|
|
795
|
+
|
|
796
|
+
#### Parameters
|
|
797
|
+
|
|
798
|
+
##### separator?
|
|
799
|
+
|
|
800
|
+
`string` = `','`
|
|
801
|
+
|
|
802
|
+
Separator string.
|
|
803
|
+
|
|
804
|
+
#### Returns
|
|
805
|
+
|
|
806
|
+
`string`
|
|
807
|
+
|
|
808
|
+
Concatenated string.
|
|
809
|
+
|
|
810
|
+
#### Remarks
|
|
811
|
+
|
|
812
|
+
Time O(n), Space O(n)
|
|
813
|
+
|
|
814
|
+
***
|
|
815
|
+
|
|
816
|
+
### lastIndexOf()
|
|
817
|
+
|
|
818
|
+
```ts
|
|
819
|
+
lastIndexOf(searchElement, fromIndex?): number;
|
|
820
|
+
```
|
|
821
|
+
|
|
822
|
+
Defined in: [data-structures/base/linear-base.ts:131](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L131)
|
|
823
|
+
|
|
824
|
+
Last index of a value from the right.
|
|
825
|
+
|
|
826
|
+
#### Parameters
|
|
827
|
+
|
|
828
|
+
##### searchElement
|
|
829
|
+
|
|
830
|
+
`E`
|
|
831
|
+
|
|
832
|
+
Value to match.
|
|
833
|
+
|
|
834
|
+
##### fromIndex?
|
|
835
|
+
|
|
836
|
+
`number` = `...`
|
|
837
|
+
|
|
838
|
+
Start position (supports negative index).
|
|
839
|
+
|
|
840
|
+
#### Returns
|
|
841
|
+
|
|
842
|
+
`number`
|
|
843
|
+
|
|
844
|
+
Index or `-1` if not found.
|
|
845
|
+
|
|
846
|
+
#### Remarks
|
|
847
|
+
|
|
848
|
+
Time O(n), Space O(1)
|
|
849
|
+
|
|
850
|
+
***
|
|
851
|
+
|
|
852
|
+
### map()
|
|
853
|
+
|
|
854
|
+
```ts
|
|
855
|
+
abstract map<EM, RM>(
|
|
856
|
+
callback,
|
|
857
|
+
options?,
|
|
858
|
+
thisArg?): IterableElementBase<EM, RM>;
|
|
859
|
+
```
|
|
860
|
+
|
|
861
|
+
Defined in: [data-structures/base/iterable-element-base.ts:312](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-element-base.ts#L312)
|
|
862
|
+
|
|
863
|
+
Maps each element to a new element and returns a new iterable structure.
|
|
864
|
+
|
|
865
|
+
#### Type Parameters
|
|
866
|
+
|
|
867
|
+
##### EM
|
|
868
|
+
|
|
869
|
+
`EM`
|
|
870
|
+
|
|
871
|
+
The mapped element type.
|
|
872
|
+
|
|
873
|
+
##### RM
|
|
874
|
+
|
|
875
|
+
`RM`
|
|
876
|
+
|
|
877
|
+
The mapped raw element type used internally by the target structure.
|
|
878
|
+
|
|
879
|
+
#### Parameters
|
|
880
|
+
|
|
881
|
+
##### callback
|
|
882
|
+
|
|
883
|
+
`ElementCallback`\<`E`, `R`, `EM`\>
|
|
884
|
+
|
|
885
|
+
Function with signature `(value, index, self) => mapped`.
|
|
886
|
+
|
|
887
|
+
##### options?
|
|
888
|
+
|
|
889
|
+
`IterableElementBaseOptions`\<`EM`, `RM`\>
|
|
890
|
+
|
|
891
|
+
Optional options for the returned structure, including its `toElementFn`.
|
|
892
|
+
|
|
893
|
+
##### thisArg?
|
|
894
|
+
|
|
895
|
+
`unknown`
|
|
896
|
+
|
|
897
|
+
Optional `this` binding for the callback.
|
|
898
|
+
|
|
899
|
+
#### Returns
|
|
900
|
+
|
|
901
|
+
[`IterableElementBase`](IterableElementBase.md)\<`EM`, `RM`\>
|
|
902
|
+
|
|
903
|
+
A new `IterableElementBase<EM, RM>` containing mapped elements.
|
|
904
|
+
|
|
905
|
+
#### Remarks
|
|
906
|
+
|
|
907
|
+
Time O(n), Space O(n).
|
|
908
|
+
|
|
909
|
+
#### Inherited from
|
|
910
|
+
|
|
911
|
+
[`IterableElementBase`](IterableElementBase.md).[`map`](IterableElementBase.md#map)
|
|
912
|
+
|
|
913
|
+
***
|
|
914
|
+
|
|
915
|
+
### mapSame()
|
|
916
|
+
|
|
917
|
+
```ts
|
|
918
|
+
abstract mapSame(callback, thisArg?): this;
|
|
919
|
+
```
|
|
920
|
+
|
|
921
|
+
Defined in: [data-structures/base/iterable-element-base.ts:328](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-element-base.ts#L328)
|
|
922
|
+
|
|
923
|
+
Maps each element to the same element type and returns the same concrete structure type.
|
|
924
|
+
|
|
925
|
+
#### Parameters
|
|
926
|
+
|
|
927
|
+
##### callback
|
|
928
|
+
|
|
929
|
+
`ElementCallback`\<`E`, `R`, `E`\>
|
|
930
|
+
|
|
931
|
+
Function with signature `(value, index, self) => mappedValue`.
|
|
932
|
+
|
|
933
|
+
##### thisArg?
|
|
934
|
+
|
|
935
|
+
`unknown`
|
|
936
|
+
|
|
937
|
+
Optional `this` binding for the callback.
|
|
938
|
+
|
|
939
|
+
#### Returns
|
|
940
|
+
|
|
941
|
+
`this`
|
|
942
|
+
|
|
943
|
+
A new instance of the same concrete type with mapped elements.
|
|
944
|
+
|
|
945
|
+
#### Remarks
|
|
946
|
+
|
|
947
|
+
Time O(n), Space O(n).
|
|
948
|
+
|
|
949
|
+
#### Inherited from
|
|
950
|
+
|
|
951
|
+
[`IterableElementBase`](IterableElementBase.md).[`mapSame`](IterableElementBase.md#mapsame)
|
|
952
|
+
|
|
953
|
+
***
|
|
954
|
+
|
|
955
|
+
### print()
|
|
956
|
+
|
|
957
|
+
```ts
|
|
958
|
+
print(): void;
|
|
959
|
+
```
|
|
960
|
+
|
|
961
|
+
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)
|
|
962
|
+
|
|
963
|
+
Prints `toVisual()` to the console. Intended for quick debugging.
|
|
964
|
+
|
|
965
|
+
#### Returns
|
|
966
|
+
|
|
967
|
+
`void`
|
|
968
|
+
|
|
969
|
+
`void`.
|
|
970
|
+
|
|
971
|
+
#### Remarks
|
|
972
|
+
|
|
973
|
+
Time O(n) due to materialization, Space O(n) for the intermediate representation.
|
|
974
|
+
|
|
975
|
+
#### Inherited from
|
|
976
|
+
|
|
977
|
+
[`IterableElementBase`](IterableElementBase.md).[`print`](IterableElementBase.md#print)
|
|
978
|
+
|
|
979
|
+
***
|
|
980
|
+
|
|
981
|
+
### push()
|
|
982
|
+
|
|
983
|
+
```ts
|
|
984
|
+
abstract push(elementOrNode): boolean;
|
|
985
|
+
```
|
|
986
|
+
|
|
987
|
+
Defined in: [data-structures/base/linear-base.ts:336](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L336)
|
|
988
|
+
|
|
989
|
+
Append one element or node to the tail.
|
|
990
|
+
|
|
991
|
+
#### Parameters
|
|
992
|
+
|
|
993
|
+
##### elementOrNode
|
|
994
|
+
|
|
995
|
+
`E` \| `NODE`
|
|
996
|
+
|
|
997
|
+
Element or node.
|
|
998
|
+
|
|
999
|
+
#### Returns
|
|
1000
|
+
|
|
1001
|
+
`boolean`
|
|
1002
|
+
|
|
1003
|
+
`true` if appended.
|
|
1004
|
+
|
|
1005
|
+
#### Remarks
|
|
1006
|
+
|
|
1007
|
+
Time O(1) amortized typical, Space O(1)
|
|
1008
|
+
|
|
1009
|
+
***
|
|
1010
|
+
|
|
1011
|
+
### pushMany()
|
|
1012
|
+
|
|
1013
|
+
```ts
|
|
1014
|
+
abstract pushMany(elements): boolean[];
|
|
1015
|
+
```
|
|
1016
|
+
|
|
1017
|
+
Defined in: [data-structures/base/linear-base.ts:344](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L344)
|
|
1018
|
+
|
|
1019
|
+
Append many elements/nodes at once.
|
|
1020
|
+
|
|
1021
|
+
#### Parameters
|
|
1022
|
+
|
|
1023
|
+
##### elements
|
|
1024
|
+
|
|
1025
|
+
\| `Iterable`\<`E`, `any`, `any`\>
|
|
1026
|
+
\| `Iterable`\<`R`, `any`, `any`\>
|
|
1027
|
+
\| `Iterable`\<`NODE`, `any`, `any`\>
|
|
1028
|
+
|
|
1029
|
+
Iterable of elements or nodes.
|
|
1030
|
+
|
|
1031
|
+
#### Returns
|
|
1032
|
+
|
|
1033
|
+
`boolean`[]
|
|
1034
|
+
|
|
1035
|
+
Array of booleans indicating append success.
|
|
1036
|
+
|
|
1037
|
+
#### Remarks
|
|
1038
|
+
|
|
1039
|
+
Time O(n), Space O(1)
|
|
1040
|
+
|
|
1041
|
+
***
|
|
1042
|
+
|
|
1043
|
+
### reduce()
|
|
1044
|
+
|
|
1045
|
+
Reduces all elements to a single accumulated value.
|
|
1046
|
+
|
|
1047
|
+
#### Param
|
|
1048
|
+
|
|
1049
|
+
Reducer of signature `(acc, value, index, self) => nextAcc`. The first element is used as the initial accumulator.
|
|
1050
|
+
|
|
1051
|
+
#### Param
|
|
1052
|
+
|
|
1053
|
+
Reducer of signature `(acc, value, index, self) => nextAcc`.
|
|
1054
|
+
|
|
1055
|
+
#### Param
|
|
1056
|
+
|
|
1057
|
+
The initial accumulator value of type `E`.
|
|
1058
|
+
|
|
1059
|
+
#### Template
|
|
1060
|
+
|
|
1061
|
+
The accumulator type when it differs from `E`.
|
|
1062
|
+
|
|
1063
|
+
#### Param
|
|
1064
|
+
|
|
1065
|
+
Reducer of signature `(acc: U, value, index, self) => U`.
|
|
1066
|
+
|
|
1067
|
+
#### Param
|
|
1068
|
+
|
|
1069
|
+
The initial accumulator value of type `U`.
|
|
1070
|
+
|
|
1071
|
+
#### Remarks
|
|
1072
|
+
|
|
1073
|
+
Time O(n), Space O(1). Throws if called on an empty structure without `initialValue`.
|
|
1074
|
+
|
|
1075
|
+
#### Call Signature
|
|
1076
|
+
|
|
1077
|
+
```ts
|
|
1078
|
+
reduce(callbackfn): E;
|
|
1079
|
+
```
|
|
1080
|
+
|
|
1081
|
+
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)
|
|
1082
|
+
|
|
1083
|
+
##### Parameters
|
|
1084
|
+
|
|
1085
|
+
###### callbackfn
|
|
1086
|
+
|
|
1087
|
+
`ReduceElementCallback`\<`E`, `R`\>
|
|
1088
|
+
|
|
1089
|
+
##### Returns
|
|
1090
|
+
|
|
1091
|
+
`E`
|
|
1092
|
+
|
|
1093
|
+
##### Inherited from
|
|
1094
|
+
|
|
1095
|
+
[`IterableElementBase`](IterableElementBase.md).[`reduce`](IterableElementBase.md#reduce)
|
|
1096
|
+
|
|
1097
|
+
#### Call Signature
|
|
1098
|
+
|
|
1099
|
+
```ts
|
|
1100
|
+
reduce(callbackfn, initialValue): E;
|
|
1101
|
+
```
|
|
1102
|
+
|
|
1103
|
+
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)
|
|
1104
|
+
|
|
1105
|
+
##### Parameters
|
|
1106
|
+
|
|
1107
|
+
###### callbackfn
|
|
1108
|
+
|
|
1109
|
+
`ReduceElementCallback`\<`E`, `R`\>
|
|
1110
|
+
|
|
1111
|
+
###### initialValue
|
|
1112
|
+
|
|
1113
|
+
`E`
|
|
1114
|
+
|
|
1115
|
+
##### Returns
|
|
1116
|
+
|
|
1117
|
+
`E`
|
|
1118
|
+
|
|
1119
|
+
##### Inherited from
|
|
1120
|
+
|
|
1121
|
+
[`IterableElementBase`](IterableElementBase.md).[`reduce`](IterableElementBase.md#reduce)
|
|
1122
|
+
|
|
1123
|
+
#### Call Signature
|
|
1124
|
+
|
|
1125
|
+
```ts
|
|
1126
|
+
reduce<U>(callbackfn, initialValue): U;
|
|
1127
|
+
```
|
|
1128
|
+
|
|
1129
|
+
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)
|
|
1130
|
+
|
|
1131
|
+
##### Type Parameters
|
|
1132
|
+
|
|
1133
|
+
###### U
|
|
1134
|
+
|
|
1135
|
+
`U`
|
|
1136
|
+
|
|
1137
|
+
##### Parameters
|
|
1138
|
+
|
|
1139
|
+
###### callbackfn
|
|
1140
|
+
|
|
1141
|
+
`ReduceElementCallback`\<`E`, `R`, `U`\>
|
|
1142
|
+
|
|
1143
|
+
###### initialValue
|
|
1144
|
+
|
|
1145
|
+
`U`
|
|
1146
|
+
|
|
1147
|
+
##### Returns
|
|
1148
|
+
|
|
1149
|
+
`U`
|
|
1150
|
+
|
|
1151
|
+
##### Inherited from
|
|
1152
|
+
|
|
1153
|
+
[`IterableElementBase`](IterableElementBase.md).[`reduce`](IterableElementBase.md#reduce)
|
|
1154
|
+
|
|
1155
|
+
***
|
|
1156
|
+
|
|
1157
|
+
### reduceRight()
|
|
1158
|
+
|
|
1159
|
+
```ts
|
|
1160
|
+
reduceRight<U>(callbackfn, initialValue): U;
|
|
1161
|
+
```
|
|
1162
|
+
|
|
1163
|
+
Defined in: [data-structures/base/linear-base.ts:256](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L256)
|
|
1164
|
+
|
|
1165
|
+
Right-to-left reduction over elements.
|
|
1166
|
+
|
|
1167
|
+
#### Type Parameters
|
|
1168
|
+
|
|
1169
|
+
##### U
|
|
1170
|
+
|
|
1171
|
+
`U`
|
|
1172
|
+
|
|
1173
|
+
#### Parameters
|
|
1174
|
+
|
|
1175
|
+
##### callbackfn
|
|
1176
|
+
|
|
1177
|
+
`ReduceLinearCallback`\<`E`, `U`\>
|
|
1178
|
+
|
|
1179
|
+
`(acc, element, index, self) => acc`.
|
|
1180
|
+
|
|
1181
|
+
##### initialValue
|
|
1182
|
+
|
|
1183
|
+
`U`
|
|
1184
|
+
|
|
1185
|
+
Initial accumulator (optional generic overloads supported).
|
|
1186
|
+
|
|
1187
|
+
#### Returns
|
|
1188
|
+
|
|
1189
|
+
`U`
|
|
1190
|
+
|
|
1191
|
+
Final accumulator.
|
|
1192
|
+
|
|
1193
|
+
#### Remarks
|
|
1194
|
+
|
|
1195
|
+
Time O(n), Space O(1)
|
|
1196
|
+
|
|
1197
|
+
***
|
|
1198
|
+
|
|
1199
|
+
### reverse()
|
|
1200
|
+
|
|
1201
|
+
```ts
|
|
1202
|
+
abstract reverse(): this;
|
|
1203
|
+
```
|
|
1204
|
+
|
|
1205
|
+
Defined in: [data-structures/base/linear-base.ts:328](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L328)
|
|
1206
|
+
|
|
1207
|
+
Reverse the order of elements in-place (or equivalent).
|
|
1208
|
+
|
|
1209
|
+
#### Returns
|
|
1210
|
+
|
|
1211
|
+
`this`
|
|
1212
|
+
|
|
1213
|
+
This list.
|
|
1214
|
+
|
|
1215
|
+
#### Remarks
|
|
1216
|
+
|
|
1217
|
+
Time O(n), Space O(1)
|
|
1218
|
+
|
|
1219
|
+
***
|
|
1220
|
+
|
|
1221
|
+
### setAt()
|
|
1222
|
+
|
|
1223
|
+
```ts
|
|
1224
|
+
abstract setAt(index, value): boolean;
|
|
1225
|
+
```
|
|
1226
|
+
|
|
1227
|
+
Defined in: [data-structures/base/linear-base.ts:314](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L314)
|
|
1228
|
+
|
|
1229
|
+
Set the value at an index.
|
|
1230
|
+
|
|
1231
|
+
#### Parameters
|
|
1232
|
+
|
|
1233
|
+
##### index
|
|
1234
|
+
|
|
1235
|
+
`number`
|
|
1236
|
+
|
|
1237
|
+
Position (0-based).
|
|
1238
|
+
|
|
1239
|
+
##### value
|
|
1240
|
+
|
|
1241
|
+
`E`
|
|
1242
|
+
|
|
1243
|
+
New value.
|
|
1244
|
+
|
|
1245
|
+
#### Returns
|
|
1246
|
+
|
|
1247
|
+
`boolean`
|
|
1248
|
+
|
|
1249
|
+
`true` if updated.
|
|
1250
|
+
|
|
1251
|
+
#### Remarks
|
|
1252
|
+
|
|
1253
|
+
Time O(1) typical, Space O(1)
|
|
1254
|
+
|
|
1255
|
+
***
|
|
1256
|
+
|
|
1257
|
+
### slice()
|
|
1258
|
+
|
|
1259
|
+
```ts
|
|
1260
|
+
slice(start?, end?): this;
|
|
1261
|
+
```
|
|
1262
|
+
|
|
1263
|
+
Defined in: [data-structures/base/linear-base.ts:273](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L273)
|
|
1264
|
+
|
|
1265
|
+
Create a shallow copy of a subrange.
|
|
1266
|
+
|
|
1267
|
+
#### Parameters
|
|
1268
|
+
|
|
1269
|
+
##### start?
|
|
1270
|
+
|
|
1271
|
+
`number` = `0`
|
|
1272
|
+
|
|
1273
|
+
Inclusive start (supports negative index).
|
|
1274
|
+
|
|
1275
|
+
##### end?
|
|
1276
|
+
|
|
1277
|
+
`number` = `...`
|
|
1278
|
+
|
|
1279
|
+
Exclusive end (supports negative index).
|
|
1280
|
+
|
|
1281
|
+
#### Returns
|
|
1282
|
+
|
|
1283
|
+
`this`
|
|
1284
|
+
|
|
1285
|
+
New list with the range (`this` type).
|
|
1286
|
+
|
|
1287
|
+
#### Remarks
|
|
1288
|
+
|
|
1289
|
+
Time O(n), Space O(n)
|
|
1290
|
+
|
|
1291
|
+
***
|
|
1292
|
+
|
|
1293
|
+
### some()
|
|
1294
|
+
|
|
1295
|
+
```ts
|
|
1296
|
+
some(predicate, thisArg?): boolean;
|
|
1297
|
+
```
|
|
1298
|
+
|
|
1299
|
+
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)
|
|
1300
|
+
|
|
1301
|
+
Tests whether at least one element satisfies the predicate.
|
|
1302
|
+
|
|
1303
|
+
#### Parameters
|
|
1304
|
+
|
|
1305
|
+
##### predicate
|
|
1306
|
+
|
|
1307
|
+
`ElementCallback`\<`E`, `R`, `boolean`\>
|
|
1308
|
+
|
|
1309
|
+
Function invoked for each element with signature `(value, index, self)`.
|
|
1310
|
+
|
|
1311
|
+
##### thisArg?
|
|
1312
|
+
|
|
1313
|
+
`unknown`
|
|
1314
|
+
|
|
1315
|
+
Optional `this` binding for the predicate.
|
|
1316
|
+
|
|
1317
|
+
#### Returns
|
|
1318
|
+
|
|
1319
|
+
`boolean`
|
|
1320
|
+
|
|
1321
|
+
`true` if any element passes; otherwise `false`.
|
|
1322
|
+
|
|
1323
|
+
#### Remarks
|
|
1324
|
+
|
|
1325
|
+
Time O(n) in the worst case; may exit early on first success. Space O(1).
|
|
1326
|
+
|
|
1327
|
+
#### Inherited from
|
|
1328
|
+
|
|
1329
|
+
[`IterableElementBase`](IterableElementBase.md).[`some`](IterableElementBase.md#some)
|
|
1330
|
+
|
|
1331
|
+
***
|
|
1332
|
+
|
|
1333
|
+
### sort()
|
|
1334
|
+
|
|
1335
|
+
```ts
|
|
1336
|
+
sort(compareFn?): this;
|
|
1337
|
+
```
|
|
1338
|
+
|
|
1339
|
+
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)
|
|
1340
|
+
|
|
1341
|
+
In-place stable order via array sort semantics.
|
|
1342
|
+
|
|
1343
|
+
#### Parameters
|
|
1344
|
+
|
|
1345
|
+
##### compareFn?
|
|
1346
|
+
|
|
1347
|
+
(`a`, `b`) => `number`
|
|
1348
|
+
|
|
1349
|
+
Comparator `(a, b) => number`.
|
|
1350
|
+
|
|
1351
|
+
#### Returns
|
|
1352
|
+
|
|
1353
|
+
`this`
|
|
1354
|
+
|
|
1355
|
+
This container.
|
|
1356
|
+
|
|
1357
|
+
#### Remarks
|
|
1358
|
+
|
|
1359
|
+
Time O(n log n), Space O(n) (materializes to array temporarily)
|
|
1360
|
+
|
|
1361
|
+
***
|
|
1362
|
+
|
|
1363
|
+
### splice()
|
|
1364
|
+
|
|
1365
|
+
```ts
|
|
1366
|
+
splice(
|
|
1367
|
+
start,
|
|
1368
|
+
deleteCount?, ...
|
|
1369
|
+
items): this;
|
|
1370
|
+
```
|
|
1371
|
+
|
|
1372
|
+
Defined in: [data-structures/base/linear-base.ts:201](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L201)
|
|
1373
|
+
|
|
1374
|
+
Remove and/or insert elements at a position (array-compatible).
|
|
1375
|
+
|
|
1376
|
+
#### Parameters
|
|
1377
|
+
|
|
1378
|
+
##### start
|
|
1379
|
+
|
|
1380
|
+
`number`
|
|
1381
|
+
|
|
1382
|
+
Start index (supports negative index).
|
|
1383
|
+
|
|
1384
|
+
##### deleteCount?
|
|
1385
|
+
|
|
1386
|
+
`number` = `0`
|
|
1387
|
+
|
|
1388
|
+
How many to remove.
|
|
1389
|
+
|
|
1390
|
+
##### items
|
|
1391
|
+
|
|
1392
|
+
...`E`[]
|
|
1393
|
+
|
|
1394
|
+
Elements to insert.
|
|
1395
|
+
|
|
1396
|
+
#### Returns
|
|
1397
|
+
|
|
1398
|
+
`this`
|
|
1399
|
+
|
|
1400
|
+
Removed elements as a new list (`this` type).
|
|
1401
|
+
|
|
1402
|
+
#### Remarks
|
|
1403
|
+
|
|
1404
|
+
Time O(n + m), Space O(min(n, m)) where `m = items.length`
|
|
1405
|
+
|
|
1406
|
+
***
|
|
1407
|
+
|
|
1408
|
+
### toArray()
|
|
1409
|
+
|
|
1410
|
+
```ts
|
|
1411
|
+
toArray(): E[];
|
|
1412
|
+
```
|
|
1413
|
+
|
|
1414
|
+
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)
|
|
1415
|
+
|
|
1416
|
+
Materializes the elements into a new array.
|
|
1417
|
+
|
|
1418
|
+
#### Returns
|
|
1419
|
+
|
|
1420
|
+
`E`[]
|
|
1421
|
+
|
|
1422
|
+
A shallow array copy of the iteration order.
|
|
1423
|
+
|
|
1424
|
+
#### Remarks
|
|
1425
|
+
|
|
1426
|
+
Time O(n), Space O(n).
|
|
1427
|
+
|
|
1428
|
+
#### Inherited from
|
|
1429
|
+
|
|
1430
|
+
[`IterableElementBase`](IterableElementBase.md).[`toArray`](IterableElementBase.md#toarray)
|
|
1431
|
+
|
|
1432
|
+
***
|
|
1433
|
+
|
|
1434
|
+
### toReversedArray()
|
|
1435
|
+
|
|
1436
|
+
```ts
|
|
1437
|
+
toReversedArray(): E[];
|
|
1438
|
+
```
|
|
1439
|
+
|
|
1440
|
+
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)
|
|
1441
|
+
|
|
1442
|
+
Snapshot elements into a reversed array.
|
|
1443
|
+
|
|
1444
|
+
#### Returns
|
|
1445
|
+
|
|
1446
|
+
`E`[]
|
|
1447
|
+
|
|
1448
|
+
New reversed array.
|
|
1449
|
+
|
|
1450
|
+
#### Remarks
|
|
1451
|
+
|
|
1452
|
+
Time O(n), Space O(n)
|
|
1453
|
+
|
|
1454
|
+
***
|
|
1455
|
+
|
|
1456
|
+
### toVisual()
|
|
1457
|
+
|
|
1458
|
+
```ts
|
|
1459
|
+
toVisual(): E[];
|
|
1460
|
+
```
|
|
1461
|
+
|
|
1462
|
+
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)
|
|
1463
|
+
|
|
1464
|
+
Returns a representation of the structure suitable for quick visualization.
|
|
1465
|
+
Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
1466
|
+
|
|
1467
|
+
#### Returns
|
|
1468
|
+
|
|
1469
|
+
`E`[]
|
|
1470
|
+
|
|
1471
|
+
A visual representation (array by default).
|
|
1472
|
+
|
|
1473
|
+
#### Remarks
|
|
1474
|
+
|
|
1475
|
+
Time O(n), Space O(n).
|
|
1476
|
+
|
|
1477
|
+
#### Inherited from
|
|
1478
|
+
|
|
1479
|
+
[`IterableElementBase`](IterableElementBase.md).[`toVisual`](IterableElementBase.md#tovisual)
|
|
1480
|
+
|
|
1481
|
+
***
|
|
1482
|
+
|
|
1483
|
+
### values()
|
|
1484
|
+
|
|
1485
|
+
```ts
|
|
1486
|
+
values(): IterableIterator<E>;
|
|
1487
|
+
```
|
|
1488
|
+
|
|
1489
|
+
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)
|
|
1490
|
+
|
|
1491
|
+
Returns an iterator over the values (alias of the default iterator).
|
|
1492
|
+
|
|
1493
|
+
#### Returns
|
|
1494
|
+
|
|
1495
|
+
`IterableIterator`\<`E`\>
|
|
1496
|
+
|
|
1497
|
+
An `IterableIterator<E>` over all elements.
|
|
1498
|
+
|
|
1499
|
+
#### Remarks
|
|
1500
|
+
|
|
1501
|
+
Creating the iterator is O(1); full iteration is Time O(n), Space O(1).
|
|
1502
|
+
|
|
1503
|
+
#### Inherited from
|
|
1504
|
+
|
|
1505
|
+
[`IterableElementBase`](IterableElementBase.md).[`values`](IterableElementBase.md#values)
|
|
1506
|
+
|
|
1507
|
+
|
|
1508
|
+
---
|
|
1509
|
+
|
|
1510
|
+
## Protected Members
|
|
1511
|
+
|
|
1512
|
+
### \_toElementFn?
|
|
1513
|
+
|
|
1514
|
+
```ts
|
|
1515
|
+
protected optional _toElementFn?: (rawElement) => E;
|
|
1516
|
+
```
|
|
1517
|
+
|
|
1518
|
+
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)
|
|
1519
|
+
|
|
1520
|
+
The converter used to transform a raw element (`R`) into a public element (`E`).
|
|
1521
|
+
|
|
1522
|
+
#### Parameters
|
|
1523
|
+
|
|
1524
|
+
##### rawElement
|
|
1525
|
+
|
|
1526
|
+
`R`
|
|
1527
|
+
|
|
1528
|
+
#### Returns
|
|
1529
|
+
|
|
1530
|
+
`E`
|
|
1531
|
+
|
|
1532
|
+
#### Remarks
|
|
1533
|
+
|
|
1534
|
+
Time O(1), Space O(1).
|
|
1535
|
+
|
|
1536
|
+
#### Inherited from
|
|
1537
|
+
|
|
1538
|
+
[`IterableElementBase`](IterableElementBase.md).[`_toElementFn`](IterableElementBase.md#_toelementfn)
|
|
1539
|
+
|
|
1540
|
+
## Accessors
|
|
1541
|
+
|
|
1542
|
+
### \_createInstance()
|
|
1543
|
+
|
|
1544
|
+
```ts
|
|
1545
|
+
abstract protected _createInstance(options?): this;
|
|
1546
|
+
```
|
|
1547
|
+
|
|
1548
|
+
Defined in: [data-structures/base/linear-base.ts:385](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L385)
|
|
1549
|
+
|
|
1550
|
+
Create an empty list of the same species.
|
|
1551
|
+
|
|
1552
|
+
#### Parameters
|
|
1553
|
+
|
|
1554
|
+
##### options?
|
|
1555
|
+
|
|
1556
|
+
`LinearBaseOptions`\<`E`, `R`\>
|
|
1557
|
+
|
|
1558
|
+
Runtime options to carry.
|
|
1559
|
+
|
|
1560
|
+
#### Returns
|
|
1561
|
+
|
|
1562
|
+
`this`
|
|
1563
|
+
|
|
1564
|
+
Empty list (`this` type).
|
|
1565
|
+
|
|
1566
|
+
#### Remarks
|
|
1567
|
+
|
|
1568
|
+
Time O(1), Space O(1)
|
|
1569
|
+
|
|
1570
|
+
***
|
|
1571
|
+
|
|
1572
|
+
### \_getIterator()
|
|
1573
|
+
|
|
1574
|
+
```ts
|
|
1575
|
+
abstract protected _getIterator(...args): IterableIterator<E>;
|
|
1576
|
+
```
|
|
1577
|
+
|
|
1578
|
+
Defined in: [data-structures/base/iterable-element-base.ts:351](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/iterable-element-base.ts#L351)
|
|
1579
|
+
|
|
1580
|
+
Internal iterator factory used by the default iterator.
|
|
1581
|
+
|
|
1582
|
+
#### Parameters
|
|
1583
|
+
|
|
1584
|
+
##### args
|
|
1585
|
+
|
|
1586
|
+
...`unknown`[]
|
|
1587
|
+
|
|
1588
|
+
Optional iterator arguments.
|
|
1589
|
+
|
|
1590
|
+
#### Returns
|
|
1591
|
+
|
|
1592
|
+
`IterableIterator`\<`E`\>
|
|
1593
|
+
|
|
1594
|
+
An iterator over elements.
|
|
1595
|
+
|
|
1596
|
+
#### Remarks
|
|
1597
|
+
|
|
1598
|
+
Implementations should yield in O(1) per element with O(1) extra space when possible.
|
|
1599
|
+
|
|
1600
|
+
#### Inherited from
|
|
1601
|
+
|
|
1602
|
+
[`IterableElementBase`](IterableElementBase.md).[`_getIterator`](IterableElementBase.md#_getiterator)
|
|
1603
|
+
|
|
1604
|
+
***
|
|
1605
|
+
|
|
1606
|
+
### \_getReverseIterator()
|
|
1607
|
+
|
|
1608
|
+
```ts
|
|
1609
|
+
abstract protected _getReverseIterator(...args): IterableIterator<E>;
|
|
1610
|
+
```
|
|
1611
|
+
|
|
1612
|
+
Defined in: [data-structures/base/linear-base.ts:392](https://github.com/zrwusa/data-structure-typed/blob/2f6ceb3aee852228efc88b111e19c0809753e805/src/data-structures/base/linear-base.ts#L392)
|
|
1613
|
+
|
|
1614
|
+
Reverse-direction iterator over elements.
|
|
1615
|
+
|
|
1616
|
+
#### Parameters
|
|
1617
|
+
|
|
1618
|
+
##### args
|
|
1619
|
+
|
|
1620
|
+
...`any`[]
|
|
1621
|
+
|
|
1622
|
+
#### Returns
|
|
1623
|
+
|
|
1624
|
+
`IterableIterator`\<`E`\>
|
|
1625
|
+
|
|
1626
|
+
Iterator of elements from tail to head.
|
|
1627
|
+
|
|
1628
|
+
#### Remarks
|
|
1629
|
+
|
|
1630
|
+
Time O(n), Space O(1)
|
|
1631
|
+
|
|
1632
|
+
***
|