data-structure-typed 2.6.0 → 2.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +7 -2
- package/.github/workflows/release-package.yml +9 -2
- package/CHANGELOG.md +9 -1
- package/dist/cjs/binary-tree.cjs +2927 -23688
- package/dist/cjs/graph.cjs +845 -2634
- package/dist/cjs/hash.cjs +185 -616
- package/dist/cjs/heap.cjs +266 -818
- package/dist/cjs/index.cjs +5116 -31358
- package/dist/cjs/linked-list.cjs +644 -2615
- package/dist/cjs/matrix.cjs +220 -535
- package/dist/cjs/priority-queue.cjs +266 -818
- package/dist/cjs/queue.cjs +637 -2343
- package/dist/cjs/stack.cjs +124 -530
- package/dist/cjs/trie.cjs +145 -592
- package/dist/cjs-legacy/binary-tree.cjs +4352 -25113
- package/dist/cjs-legacy/graph.cjs +847 -2636
- package/dist/cjs-legacy/hash.cjs +181 -612
- package/dist/cjs-legacy/heap.cjs +266 -818
- package/dist/cjs-legacy/index.cjs +6657 -32899
- package/dist/cjs-legacy/linked-list.cjs +640 -2611
- package/dist/cjs-legacy/matrix.cjs +220 -535
- package/dist/cjs-legacy/priority-queue.cjs +266 -818
- package/dist/cjs-legacy/queue.cjs +634 -2340
- package/dist/cjs-legacy/stack.cjs +124 -530
- package/dist/cjs-legacy/trie.cjs +145 -592
- package/dist/esm/binary-tree.mjs +2927 -23688
- package/dist/esm/graph.mjs +845 -2634
- package/dist/esm/hash.mjs +185 -616
- package/dist/esm/heap.mjs +266 -818
- package/dist/esm/index.mjs +5116 -31358
- package/dist/esm/linked-list.mjs +644 -2615
- package/dist/esm/matrix.mjs +220 -535
- package/dist/esm/priority-queue.mjs +266 -818
- package/dist/esm/queue.mjs +637 -2343
- package/dist/esm/stack.mjs +124 -530
- package/dist/esm/trie.mjs +145 -592
- package/dist/esm-legacy/binary-tree.mjs +4352 -25113
- package/dist/esm-legacy/graph.mjs +847 -2636
- package/dist/esm-legacy/hash.mjs +181 -612
- package/dist/esm-legacy/heap.mjs +266 -818
- package/dist/esm-legacy/index.mjs +6657 -32899
- package/dist/esm-legacy/linked-list.mjs +640 -2611
- package/dist/esm-legacy/matrix.mjs +220 -535
- package/dist/esm-legacy/priority-queue.mjs +266 -818
- package/dist/esm-legacy/queue.mjs +634 -2340
- package/dist/esm-legacy/stack.mjs +124 -530
- package/dist/esm-legacy/trie.mjs +145 -592
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +29 -500
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +38 -563
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +230 -1212
- package/dist/types/data-structures/binary-tree/bst.d.ts +124 -1063
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +99 -854
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +62 -314
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +366 -5057
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +277 -4885
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +253 -3929
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +261 -4782
- package/dist/types/data-structures/graph/abstract-graph.d.ts +44 -44
- package/dist/types/data-structures/graph/directed-graph.d.ts +130 -527
- package/dist/types/data-structures/graph/undirected-graph.d.ts +125 -482
- package/dist/types/data-structures/hash/hash-map.d.ts +132 -562
- package/dist/types/data-structures/heap/heap.d.ts +194 -746
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +120 -809
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +121 -733
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +193 -863
- package/dist/types/data-structures/matrix/matrix.d.ts +159 -474
- package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -6
- package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +6 -11
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
- package/dist/types/data-structures/queue/deque.d.ts +196 -804
- package/dist/types/data-structures/queue/queue.d.ts +99 -585
- package/dist/types/data-structures/stack/stack.d.ts +75 -481
- package/dist/types/data-structures/trie/trie.d.ts +98 -584
- package/dist/umd/data-structure-typed.js +6580 -32822
- package/dist/umd/data-structure-typed.min.js +3 -3
- package/docs-site-docusaurus/docs/api/classes/AVLTree.md +162 -215
- package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +9 -9
- package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +47 -47
- package/docs-site-docusaurus/docs/api/classes/BST.md +155 -208
- package/docs-site-docusaurus/docs/api/classes/BSTNode.md +7 -7
- package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +13 -29
- package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +104 -158
- package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/Deque.md +253 -101
- package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +60 -80
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +244 -114
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +6 -6
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +9 -9
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
- package/docs-site-docusaurus/docs/api/classes/HashMap.md +52 -48
- package/docs-site-docusaurus/docs/api/classes/Heap.md +119 -64
- package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +84 -14
- package/docs-site-docusaurus/docs/api/classes/LinearBase.md +138 -34
- package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +149 -41
- package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +23 -23
- package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +172 -92
- package/docs-site-docusaurus/docs/api/classes/MapGraph.md +60 -80
- package/docs-site-docusaurus/docs/api/classes/Matrix.md +57 -52
- package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +117 -62
- package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +120 -70
- package/docs-site-docusaurus/docs/api/classes/MinHeap.md +117 -62
- package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +125 -75
- package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +119 -64
- package/docs-site-docusaurus/docs/api/classes/Queue.md +158 -74
- package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +171 -225
- package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -22
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +172 -94
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +4 -4
- package/docs-site-docusaurus/docs/api/classes/SkipList.md +98 -75
- package/docs-site-docusaurus/docs/api/classes/Stack.md +112 -50
- package/docs-site-docusaurus/docs/api/classes/TreeMap.md +104 -129
- package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +90 -121
- package/docs-site-docusaurus/docs/api/classes/TreeSet.md +298 -107
- package/docs-site-docusaurus/docs/api/classes/Trie.md +116 -58
- package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +59 -77
- package/package.json +45 -46
- package/src/common/error.ts +15 -32
- package/src/common/index.ts +0 -3
- package/src/data-structures/base/iterable-element-base.ts +0 -3
- package/src/data-structures/base/linear-base.ts +2 -36
- package/src/data-structures/binary-tree/avl-tree.ts +31 -529
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +47 -572
- package/src/data-structures/binary-tree/binary-tree.ts +326 -1311
- package/src/data-structures/binary-tree/bst.ts +158 -1082
- package/src/data-structures/binary-tree/red-black-tree.ts +451 -1290
- package/src/data-structures/binary-tree/segment-tree.ts +73 -351
- package/src/data-structures/binary-tree/tree-map.ts +462 -5124
- package/src/data-structures/binary-tree/tree-multi-map.ts +302 -4914
- package/src/data-structures/binary-tree/tree-multi-set.ts +299 -3983
- package/src/data-structures/binary-tree/tree-set.ts +338 -4836
- package/src/data-structures/graph/abstract-graph.ts +98 -167
- package/src/data-structures/graph/directed-graph.ts +137 -562
- package/src/data-structures/graph/map-graph.ts +0 -3
- package/src/data-structures/graph/undirected-graph.ts +132 -511
- package/src/data-structures/hash/hash-map.ts +154 -582
- package/src/data-structures/heap/heap.ts +200 -795
- package/src/data-structures/linked-list/doubly-linked-list.ts +121 -865
- package/src/data-structures/linked-list/singly-linked-list.ts +122 -794
- package/src/data-structures/linked-list/skip-linked-list.ts +211 -918
- package/src/data-structures/matrix/matrix.ts +179 -518
- package/src/data-structures/matrix/navigator.ts +0 -1
- package/src/data-structures/priority-queue/max-priority-queue.ts +1 -6
- package/src/data-structures/priority-queue/min-priority-queue.ts +6 -11
- package/src/data-structures/priority-queue/priority-queue.ts +1 -2
- package/src/data-structures/queue/deque.ts +214 -882
- package/src/data-structures/queue/queue.ts +102 -625
- package/src/data-structures/stack/stack.ts +76 -505
- package/src/data-structures/trie/trie.ts +98 -628
- package/src/types/common.ts +0 -10
- package/src/types/data-structures/binary-tree/bst.ts +0 -7
- package/src/types/data-structures/binary-tree/red-black-tree.ts +0 -1
- package/src/types/data-structures/graph/abstract-graph.ts +0 -2
- package/src/types/data-structures/hash/hash-map.ts +0 -3
- package/src/types/data-structures/hash/index.ts +0 -1
- package/src/types/data-structures/matrix/navigator.ts +0 -2
- package/src/types/utils/utils.ts +0 -7
- package/src/types/utils/validate-type.ts +0 -7
- package/src/utils/number.ts +0 -2
- package/src/utils/utils.ts +0 -5
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Abstract Class: LinearLinkedBase\<E, R, NODE\>
|
|
8
8
|
|
|
9
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
9
|
+
Defined in: [data-structures/base/linear-base.ts:397](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L397)
|
|
10
10
|
|
|
11
11
|
Linked-list specialized linear container.
|
|
12
12
|
|
|
@@ -169,7 +169,7 @@ Producing the iterator is O(1); consuming the entire iterator is Time O(n) with
|
|
|
169
169
|
abstract addAfter(existingElementOrNode, newElementOrNode): boolean;
|
|
170
170
|
```
|
|
171
171
|
|
|
172
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
172
|
+
Defined in: [data-structures/base/linear-base.ts:586](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L586)
|
|
173
173
|
|
|
174
174
|
Insert new element/node after an existing node.
|
|
175
175
|
|
|
@@ -205,7 +205,7 @@ Time O(1)~O(n) depending on reference access, Space O(1)
|
|
|
205
205
|
abstract addAt(index, newElementOrNode): boolean;
|
|
206
206
|
```
|
|
207
207
|
|
|
208
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
208
|
+
Defined in: [data-structures/base/linear-base.ts:372](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L372)
|
|
209
209
|
|
|
210
210
|
Insert an element/node at a position.
|
|
211
211
|
|
|
@@ -245,7 +245,7 @@ Time O(1)~O(n) depending on implementation, Space O(1)
|
|
|
245
245
|
abstract addBefore(existingElementOrNode, newElementOrNode): boolean;
|
|
246
246
|
```
|
|
247
247
|
|
|
248
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
248
|
+
Defined in: [data-structures/base/linear-base.ts:577](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L577)
|
|
249
249
|
|
|
250
250
|
Insert new element/node before an existing node.
|
|
251
251
|
|
|
@@ -281,7 +281,7 @@ Time O(1)~O(n) depending on reference access, Space O(1)
|
|
|
281
281
|
abstract at(index): E | undefined;
|
|
282
282
|
```
|
|
283
283
|
|
|
284
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
284
|
+
Defined in: [data-structures/base/linear-base.ts:355](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L355)
|
|
285
285
|
|
|
286
286
|
Get element at an index.
|
|
287
287
|
|
|
@@ -315,7 +315,7 @@ Time O(1)~O(n) depending on implementation, Space O(1)
|
|
|
315
315
|
abstract clear(): void;
|
|
316
316
|
```
|
|
317
317
|
|
|
318
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
318
|
+
Defined in: [data-structures/base/iterable-element-base.ts:318](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L318)
|
|
319
319
|
|
|
320
320
|
Removes all elements from the structure.
|
|
321
321
|
|
|
@@ -341,7 +341,7 @@ Expected Time O(1) or O(n) depending on the implementation; Space O(1).
|
|
|
341
341
|
abstract clone(): this;
|
|
342
342
|
```
|
|
343
343
|
|
|
344
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
344
|
+
Defined in: [data-structures/base/linear-base.ts:305](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L305)
|
|
345
345
|
|
|
346
346
|
Deep clone while preserving concrete subtype.
|
|
347
347
|
|
|
@@ -367,7 +367,7 @@ Time O(n), Space O(n)
|
|
|
367
367
|
concat(...items): this;
|
|
368
368
|
```
|
|
369
369
|
|
|
370
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
370
|
+
Defined in: [data-structures/base/linear-base.ts:462](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L462)
|
|
371
371
|
|
|
372
372
|
Concatenate lists/elements preserving order.
|
|
373
373
|
|
|
@@ -403,7 +403,7 @@ Time O(sum(length)), Space O(sum(length))
|
|
|
403
403
|
abstract delete(elementOrNode): boolean;
|
|
404
404
|
```
|
|
405
405
|
|
|
406
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
406
|
+
Defined in: [data-structures/base/linear-base.ts:568](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L568)
|
|
407
407
|
|
|
408
408
|
Delete by element or node in a linked list.
|
|
409
409
|
|
|
@@ -437,7 +437,7 @@ Time O(1)~O(n) depending on availability of links, Space O(1)
|
|
|
437
437
|
abstract deleteAt(pos): E | undefined;
|
|
438
438
|
```
|
|
439
439
|
|
|
440
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
440
|
+
Defined in: [data-structures/base/linear-base.ts:363](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L363)
|
|
441
441
|
|
|
442
442
|
Remove element at a position.
|
|
443
443
|
|
|
@@ -465,6 +465,30 @@ Time O(1)~O(n) depending on implementation, Space O(1)
|
|
|
465
465
|
|
|
466
466
|
***
|
|
467
467
|
|
|
468
|
+
### entries()
|
|
469
|
+
|
|
470
|
+
```ts
|
|
471
|
+
entries(): IterableIterator<[number, E]>;
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
Defined in: [data-structures/base/iterable-element-base.ts:207](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L207)
|
|
475
|
+
|
|
476
|
+
Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
477
|
+
|
|
478
|
+
#### Returns
|
|
479
|
+
|
|
480
|
+
`IterableIterator`\<\[`number`, `E`\]\>
|
|
481
|
+
|
|
482
|
+
#### Remarks
|
|
483
|
+
|
|
484
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
485
|
+
|
|
486
|
+
#### Inherited from
|
|
487
|
+
|
|
488
|
+
[`LinearBase`](LinearBase.md).[`entries`](LinearBase.md#entries)
|
|
489
|
+
|
|
490
|
+
***
|
|
491
|
+
|
|
468
492
|
### every()
|
|
469
493
|
|
|
470
494
|
```ts
|
|
@@ -514,7 +538,7 @@ fill(
|
|
|
514
538
|
end?): this;
|
|
515
539
|
```
|
|
516
540
|
|
|
517
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
541
|
+
Defined in: [data-structures/base/linear-base.ts:279](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L279)
|
|
518
542
|
|
|
519
543
|
Fill a range with a value.
|
|
520
544
|
|
|
@@ -560,7 +584,7 @@ Time O(n), Space O(1)
|
|
|
560
584
|
abstract filter(predicate, thisArg?): this;
|
|
561
585
|
```
|
|
562
586
|
|
|
563
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
587
|
+
Defined in: [data-structures/base/iterable-element-base.ts:370](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L370)
|
|
564
588
|
|
|
565
589
|
Filters elements using the provided predicate and returns the same concrete structure type.
|
|
566
590
|
|
|
@@ -690,7 +714,7 @@ Time O(n) in the worst case; may exit early on the first match. Space O(1).
|
|
|
690
714
|
findIndex(predicate, thisArg?): number;
|
|
691
715
|
```
|
|
692
716
|
|
|
693
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
717
|
+
Defined in: [data-structures/base/linear-base.ts:147](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L147)
|
|
694
718
|
|
|
695
719
|
Find the first index matching a predicate.
|
|
696
720
|
|
|
@@ -770,7 +794,7 @@ Time O(n), Space O(1).
|
|
|
770
794
|
abstract getNodeAt(index): NODE | undefined;
|
|
771
795
|
```
|
|
772
796
|
|
|
773
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
797
|
+
Defined in: [data-structures/base/linear-base.ts:594](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L594)
|
|
774
798
|
|
|
775
799
|
Node at index (for random-access emulation).
|
|
776
800
|
|
|
@@ -800,7 +824,7 @@ Time O(n), Space O(1)
|
|
|
800
824
|
has(element): boolean;
|
|
801
825
|
```
|
|
802
826
|
|
|
803
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
827
|
+
Defined in: [data-structures/base/iterable-element-base.ts:188](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L188)
|
|
804
828
|
|
|
805
829
|
Checks whether a strictly-equal element exists in the structure.
|
|
806
830
|
|
|
@@ -828,13 +852,47 @@ Time O(n) in the worst case. Space O(1).
|
|
|
828
852
|
|
|
829
853
|
***
|
|
830
854
|
|
|
855
|
+
### includes()
|
|
856
|
+
|
|
857
|
+
```ts
|
|
858
|
+
includes(element): boolean;
|
|
859
|
+
```
|
|
860
|
+
|
|
861
|
+
Defined in: [data-structures/base/iterable-element-base.ts:199](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L199)
|
|
862
|
+
|
|
863
|
+
Check whether a value exists (Array-compatible alias for `has`).
|
|
864
|
+
|
|
865
|
+
#### Parameters
|
|
866
|
+
|
|
867
|
+
##### element
|
|
868
|
+
|
|
869
|
+
`E`
|
|
870
|
+
|
|
871
|
+
Element to search for (uses `===`).
|
|
872
|
+
|
|
873
|
+
#### Returns
|
|
874
|
+
|
|
875
|
+
`boolean`
|
|
876
|
+
|
|
877
|
+
`true` if found.
|
|
878
|
+
|
|
879
|
+
#### Remarks
|
|
880
|
+
|
|
881
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
882
|
+
|
|
883
|
+
#### Inherited from
|
|
884
|
+
|
|
885
|
+
[`LinearBase`](LinearBase.md).[`includes`](LinearBase.md#includes)
|
|
886
|
+
|
|
887
|
+
***
|
|
888
|
+
|
|
831
889
|
### indexOf()
|
|
832
890
|
|
|
833
891
|
```ts
|
|
834
892
|
indexOf(searchElement, fromIndex?): number;
|
|
835
893
|
```
|
|
836
894
|
|
|
837
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
895
|
+
Defined in: [data-structures/base/linear-base.ts:417](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L417)
|
|
838
896
|
|
|
839
897
|
Linked-list optimized `indexOf` (forwards scan).
|
|
840
898
|
|
|
@@ -874,7 +932,7 @@ Time O(n), Space O(1)
|
|
|
874
932
|
abstract isEmpty(): boolean;
|
|
875
933
|
```
|
|
876
934
|
|
|
877
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
935
|
+
Defined in: [data-structures/base/iterable-element-base.ts:309](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L309)
|
|
878
936
|
|
|
879
937
|
Indicates whether the structure currently contains no elements.
|
|
880
938
|
|
|
@@ -900,7 +958,7 @@ Expected Time O(1), Space O(1) for most implementations.
|
|
|
900
958
|
join(separator?): string;
|
|
901
959
|
```
|
|
902
960
|
|
|
903
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
961
|
+
Defined in: [data-structures/base/linear-base.ts:218](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L218)
|
|
904
962
|
|
|
905
963
|
Join all elements into a string.
|
|
906
964
|
|
|
@@ -928,13 +986,37 @@ Time O(n), Space O(n)
|
|
|
928
986
|
|
|
929
987
|
***
|
|
930
988
|
|
|
989
|
+
### keys()
|
|
990
|
+
|
|
991
|
+
```ts
|
|
992
|
+
keys(): IterableIterator<number>;
|
|
993
|
+
```
|
|
994
|
+
|
|
995
|
+
Defined in: [data-structures/base/iterable-element-base.ts:218](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L218)
|
|
996
|
+
|
|
997
|
+
Return an iterator of numeric indices (Array-compatible).
|
|
998
|
+
|
|
999
|
+
#### Returns
|
|
1000
|
+
|
|
1001
|
+
`IterableIterator`\<`number`\>
|
|
1002
|
+
|
|
1003
|
+
#### Remarks
|
|
1004
|
+
|
|
1005
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
1006
|
+
|
|
1007
|
+
#### Inherited from
|
|
1008
|
+
|
|
1009
|
+
[`LinearBase`](LinearBase.md).[`keys`](LinearBase.md#keys)
|
|
1010
|
+
|
|
1011
|
+
***
|
|
1012
|
+
|
|
931
1013
|
### lastIndexOf()
|
|
932
1014
|
|
|
933
1015
|
```ts
|
|
934
1016
|
lastIndexOf(searchElement, fromIndex?): number;
|
|
935
1017
|
```
|
|
936
1018
|
|
|
937
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1019
|
+
Defined in: [data-structures/base/linear-base.ts:440](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L440)
|
|
938
1020
|
|
|
939
1021
|
Linked-list optimized `lastIndexOf` (reverse scan).
|
|
940
1022
|
|
|
@@ -977,7 +1059,7 @@ abstract map<EM, RM>(
|
|
|
977
1059
|
thisArg?): IterableElementBase<EM, RM>;
|
|
978
1060
|
```
|
|
979
1061
|
|
|
980
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1062
|
+
Defined in: [data-structures/base/iterable-element-base.ts:342](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L342)
|
|
981
1063
|
|
|
982
1064
|
Maps each element to a new element and returns a new iterable structure.
|
|
983
1065
|
|
|
@@ -1037,7 +1119,7 @@ Time O(n), Space O(n).
|
|
|
1037
1119
|
abstract mapSame(callback, thisArg?): this;
|
|
1038
1120
|
```
|
|
1039
1121
|
|
|
1040
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1122
|
+
Defined in: [data-structures/base/iterable-element-base.ts:358](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L358)
|
|
1041
1123
|
|
|
1042
1124
|
Maps each element to the same element type and returns the same concrete structure type.
|
|
1043
1125
|
|
|
@@ -1077,7 +1159,7 @@ Time O(n), Space O(n).
|
|
|
1077
1159
|
print(): void;
|
|
1078
1160
|
```
|
|
1079
1161
|
|
|
1080
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1162
|
+
Defined in: [data-structures/base/iterable-element-base.ts:298](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L298)
|
|
1081
1163
|
|
|
1082
1164
|
Prints `toVisual()` to the console. Intended for quick debugging.
|
|
1083
1165
|
|
|
@@ -1103,7 +1185,7 @@ Time O(n) due to materialization, Space O(n) for the intermediate representation
|
|
|
1103
1185
|
abstract push(elementOrNode): boolean;
|
|
1104
1186
|
```
|
|
1105
1187
|
|
|
1106
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1188
|
+
Defined in: [data-structures/base/linear-base.ts:331](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L331)
|
|
1107
1189
|
|
|
1108
1190
|
Append one element or node to the tail.
|
|
1109
1191
|
|
|
@@ -1137,7 +1219,7 @@ Time O(1) amortized typical, Space O(1)
|
|
|
1137
1219
|
abstract pushMany(elements): boolean[];
|
|
1138
1220
|
```
|
|
1139
1221
|
|
|
1140
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1222
|
+
Defined in: [data-structures/base/linear-base.ts:339](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L339)
|
|
1141
1223
|
|
|
1142
1224
|
Append many elements/nodes at once.
|
|
1143
1225
|
|
|
@@ -1205,7 +1287,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
|
|
|
1205
1287
|
reduce(callbackfn): E;
|
|
1206
1288
|
```
|
|
1207
1289
|
|
|
1208
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1290
|
+
Defined in: [data-structures/base/iterable-element-base.ts:225](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L225)
|
|
1209
1291
|
|
|
1210
1292
|
##### Parameters
|
|
1211
1293
|
|
|
@@ -1227,7 +1309,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
|
|
|
1227
1309
|
reduce(callbackfn, initialValue): E;
|
|
1228
1310
|
```
|
|
1229
1311
|
|
|
1230
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1312
|
+
Defined in: [data-structures/base/iterable-element-base.ts:226](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L226)
|
|
1231
1313
|
|
|
1232
1314
|
##### Parameters
|
|
1233
1315
|
|
|
@@ -1253,7 +1335,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
|
|
|
1253
1335
|
reduce<U>(callbackfn, initialValue): U;
|
|
1254
1336
|
```
|
|
1255
1337
|
|
|
1256
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1338
|
+
Defined in: [data-structures/base/iterable-element-base.ts:227](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L227)
|
|
1257
1339
|
|
|
1258
1340
|
##### Type Parameters
|
|
1259
1341
|
|
|
@@ -1287,7 +1369,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.c
|
|
|
1287
1369
|
reduceRight<U>(callbackfn, initialValue): U;
|
|
1288
1370
|
```
|
|
1289
1371
|
|
|
1290
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1372
|
+
Defined in: [data-structures/base/linear-base.ts:552](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L552)
|
|
1291
1373
|
|
|
1292
1374
|
Right-to-left reduction using reverse iterator.
|
|
1293
1375
|
|
|
@@ -1333,7 +1415,7 @@ Time O(n), Space O(1)
|
|
|
1333
1415
|
abstract reverse(): this;
|
|
1334
1416
|
```
|
|
1335
1417
|
|
|
1336
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1418
|
+
Defined in: [data-structures/base/linear-base.ts:312](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L312)
|
|
1337
1419
|
|
|
1338
1420
|
Reverse the order of elements in-place (or equivalent).
|
|
1339
1421
|
|
|
@@ -1359,7 +1441,7 @@ Time O(n), Space O(1)
|
|
|
1359
1441
|
abstract setAt(index, value): boolean;
|
|
1360
1442
|
```
|
|
1361
1443
|
|
|
1362
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1444
|
+
Defined in: [data-structures/base/linear-base.ts:298](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L298)
|
|
1363
1445
|
|
|
1364
1446
|
Set the value at an index.
|
|
1365
1447
|
|
|
@@ -1399,7 +1481,7 @@ Time O(1) typical, Space O(1)
|
|
|
1399
1481
|
slice(start?, end?): this;
|
|
1400
1482
|
```
|
|
1401
1483
|
|
|
1402
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1484
|
+
Defined in: [data-structures/base/linear-base.ts:481](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L481)
|
|
1403
1485
|
|
|
1404
1486
|
Slice via forward iteration (no random access required).
|
|
1405
1487
|
|
|
@@ -1479,7 +1561,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
|
|
|
1479
1561
|
sort(compareFn?): this;
|
|
1480
1562
|
```
|
|
1481
1563
|
|
|
1482
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1564
|
+
Defined in: [data-structures/base/linear-base.ts:179](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L179)
|
|
1483
1565
|
|
|
1484
1566
|
In-place stable order via array sort semantics.
|
|
1485
1567
|
|
|
@@ -1516,7 +1598,7 @@ splice(
|
|
|
1516
1598
|
items): this;
|
|
1517
1599
|
```
|
|
1518
1600
|
|
|
1519
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1601
|
+
Defined in: [data-structures/base/linear-base.ts:507](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L507)
|
|
1520
1602
|
|
|
1521
1603
|
Splice by walking node iterators from the start index.
|
|
1522
1604
|
|
|
@@ -1562,7 +1644,7 @@ Time O(n + m), Space O(min(n, m)) where `m = items.length`
|
|
|
1562
1644
|
toArray(): E[];
|
|
1563
1645
|
```
|
|
1564
1646
|
|
|
1565
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1647
|
+
Defined in: [data-structures/base/iterable-element-base.ts:275](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L275)
|
|
1566
1648
|
|
|
1567
1649
|
Materializes the elements into a new array.
|
|
1568
1650
|
|
|
@@ -1582,13 +1664,39 @@ Time O(n), Space O(n).
|
|
|
1582
1664
|
|
|
1583
1665
|
***
|
|
1584
1666
|
|
|
1667
|
+
### toReversed()
|
|
1668
|
+
|
|
1669
|
+
```ts
|
|
1670
|
+
toReversed(): this;
|
|
1671
|
+
```
|
|
1672
|
+
|
|
1673
|
+
Defined in: [data-structures/base/linear-base.ts:319](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L319)
|
|
1674
|
+
|
|
1675
|
+
Return a new instance of the same type with elements in reverse order (non-mutating).
|
|
1676
|
+
|
|
1677
|
+
#### Returns
|
|
1678
|
+
|
|
1679
|
+
`this`
|
|
1680
|
+
|
|
1681
|
+
A new reversed instance.
|
|
1682
|
+
|
|
1683
|
+
#### Remarks
|
|
1684
|
+
|
|
1685
|
+
Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
|
|
1686
|
+
|
|
1687
|
+
#### Inherited from
|
|
1688
|
+
|
|
1689
|
+
[`LinearBase`](LinearBase.md).[`toReversed`](LinearBase.md#toreversed)
|
|
1690
|
+
|
|
1691
|
+
***
|
|
1692
|
+
|
|
1585
1693
|
### toReversedArray()
|
|
1586
1694
|
|
|
1587
1695
|
```ts
|
|
1588
1696
|
toReversedArray(): E[];
|
|
1589
1697
|
```
|
|
1590
1698
|
|
|
1591
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1699
|
+
Defined in: [data-structures/base/linear-base.ts:227](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L227)
|
|
1592
1700
|
|
|
1593
1701
|
Snapshot elements into a reversed array.
|
|
1594
1702
|
|
|
@@ -1614,7 +1722,7 @@ Time O(n), Space O(n)
|
|
|
1614
1722
|
toVisual(): E[];
|
|
1615
1723
|
```
|
|
1616
1724
|
|
|
1617
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1725
|
+
Defined in: [data-structures/base/iterable-element-base.ts:287](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L287)
|
|
1618
1726
|
|
|
1619
1727
|
Returns a representation of the structure suitable for quick visualization.
|
|
1620
1728
|
Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
@@ -1700,7 +1808,7 @@ Time O(1), Space O(1).
|
|
|
1700
1808
|
abstract protected _createInstance(options?): this;
|
|
1701
1809
|
```
|
|
1702
1810
|
|
|
1703
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1811
|
+
Defined in: [data-structures/base/linear-base.ts:380](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L380)
|
|
1704
1812
|
|
|
1705
1813
|
Create an empty list of the same species.
|
|
1706
1814
|
|
|
@@ -1734,7 +1842,7 @@ Time O(1), Space O(1)
|
|
|
1734
1842
|
abstract protected _getIterator(...args): IterableIterator<E>;
|
|
1735
1843
|
```
|
|
1736
1844
|
|
|
1737
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1845
|
+
Defined in: [data-structures/base/iterable-element-base.ts:381](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L381)
|
|
1738
1846
|
|
|
1739
1847
|
Internal iterator factory used by the default iterator.
|
|
1740
1848
|
|
|
@@ -1768,7 +1876,7 @@ Implementations should yield in O(1) per element with O(1) extra space when poss
|
|
|
1768
1876
|
abstract protected _getNodeIterator(...args): IterableIterator<NODE>;
|
|
1769
1877
|
```
|
|
1770
1878
|
|
|
1771
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1879
|
+
Defined in: [data-structures/base/linear-base.ts:601](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L601)
|
|
1772
1880
|
|
|
1773
1881
|
Iterate linked nodes from head to tail.
|
|
1774
1882
|
|
|
@@ -1796,7 +1904,7 @@ Time O(n), Space O(1)
|
|
|
1796
1904
|
abstract protected _getPrevNode(node): NODE | undefined;
|
|
1797
1905
|
```
|
|
1798
1906
|
|
|
1799
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1907
|
+
Defined in: [data-structures/base/linear-base.ts:609](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L609)
|
|
1800
1908
|
|
|
1801
1909
|
Get previous node of a given node.
|
|
1802
1910
|
|
|
@@ -1826,7 +1934,7 @@ Time O(1)~O(n) depending on list variant (singly vs doubly), Space O(1)
|
|
|
1826
1934
|
abstract protected _getReverseIterator(...args): IterableIterator<E>;
|
|
1827
1935
|
```
|
|
1828
1936
|
|
|
1829
|
-
Defined in: [data-structures/base/linear-base.ts:
|
|
1937
|
+
Defined in: [data-structures/base/linear-base.ts:387](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L387)
|
|
1830
1938
|
|
|
1831
1939
|
Reverse-direction iterator over elements.
|
|
1832
1940
|
|