data-structure-typed 2.5.3 → 2.6.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/.github/workflows/ci.yml +7 -2
- package/.github/workflows/release-package.yml +9 -2
- package/.husky/pre-commit +3 -0
- package/CHANGELOG.md +1 -1
- package/MIGRATION.md +48 -0
- package/README.md +20 -2
- package/README_CN.md +20 -2
- package/SPECIFICATION.md +24 -0
- package/SPECIFICATION.zh-CN.md +24 -0
- package/dist/cjs/binary-tree.cjs +1897 -19
- package/dist/cjs/graph.cjs +174 -0
- package/dist/cjs/hash.cjs +33 -0
- package/dist/cjs/heap.cjs +71 -0
- package/dist/cjs/index.cjs +2383 -3
- package/dist/cjs/linked-list.cjs +224 -2
- package/dist/cjs/matrix.cjs +24 -0
- package/dist/cjs/priority-queue.cjs +71 -0
- package/dist/cjs/queue.cjs +221 -1
- package/dist/cjs/stack.cjs +59 -0
- package/dist/cjs/trie.cjs +62 -0
- package/dist/cjs-legacy/binary-tree.cjs +1897 -19
- package/dist/cjs-legacy/graph.cjs +174 -0
- package/dist/cjs-legacy/hash.cjs +33 -0
- package/dist/cjs-legacy/heap.cjs +71 -0
- package/dist/cjs-legacy/index.cjs +2383 -3
- package/dist/cjs-legacy/linked-list.cjs +224 -2
- package/dist/cjs-legacy/matrix.cjs +24 -0
- package/dist/cjs-legacy/priority-queue.cjs +71 -0
- package/dist/cjs-legacy/queue.cjs +221 -1
- package/dist/cjs-legacy/stack.cjs +59 -0
- package/dist/cjs-legacy/trie.cjs +62 -0
- package/dist/esm/binary-tree.mjs +1897 -19
- package/dist/esm/graph.mjs +174 -0
- package/dist/esm/hash.mjs +33 -0
- package/dist/esm/heap.mjs +71 -0
- package/dist/esm/index.mjs +2383 -3
- package/dist/esm/linked-list.mjs +224 -2
- package/dist/esm/matrix.mjs +24 -0
- package/dist/esm/priority-queue.mjs +71 -0
- package/dist/esm/queue.mjs +221 -1
- package/dist/esm/stack.mjs +59 -0
- package/dist/esm/trie.mjs +62 -0
- package/dist/esm-legacy/binary-tree.mjs +1897 -19
- package/dist/esm-legacy/graph.mjs +174 -0
- package/dist/esm-legacy/hash.mjs +33 -0
- package/dist/esm-legacy/heap.mjs +71 -0
- package/dist/esm-legacy/index.mjs +2383 -3
- package/dist/esm-legacy/linked-list.mjs +224 -2
- package/dist/esm-legacy/matrix.mjs +24 -0
- package/dist/esm-legacy/priority-queue.mjs +71 -0
- package/dist/esm-legacy/queue.mjs +221 -1
- package/dist/esm-legacy/stack.mjs +59 -0
- package/dist/esm-legacy/trie.mjs +62 -0
- package/dist/types/data-structures/base/iterable-element-base.d.ts +17 -0
- package/dist/types/data-structures/base/linear-base.d.ts +6 -0
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +36 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +42 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +75 -0
- package/dist/types/data-structures/binary-tree/bst.d.ts +72 -0
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +57 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +18 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +375 -0
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +389 -0
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +330 -0
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +438 -0
- package/dist/types/data-structures/graph/directed-graph.d.ts +30 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +27 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +33 -0
- package/dist/types/data-structures/heap/heap.d.ts +42 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +75 -2
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +45 -0
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +54 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +24 -0
- package/dist/types/data-structures/queue/deque.d.ts +90 -1
- package/dist/types/data-structures/queue/queue.d.ts +36 -0
- package/dist/types/data-structures/stack/stack.d.ts +30 -0
- package/dist/types/data-structures/trie/trie.d.ts +36 -0
- package/dist/umd/data-structure-typed.js +2383 -3
- package/dist/umd/data-structure-typed.min.js +3 -3
- package/docs-site-docusaurus/docs/api/classes/AVLTree.md +108 -108
- package/docs-site-docusaurus/docs/api/classes/BST.md +101 -101
- package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +66 -66
- package/docs-site-docusaurus/docs/api/classes/Deque.md +235 -51
- package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +21 -21
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +231 -67
- 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 +14 -14
- package/docs-site-docusaurus/docs/api/classes/Heap.md +117 -34
- package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +83 -13
- package/docs-site-docusaurus/docs/api/classes/LinearBase.md +124 -20
- package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +140 -32
- package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +30 -26
- package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +159 -51
- package/docs-site-docusaurus/docs/api/classes/MapGraph.md +20 -20
- package/docs-site-docusaurus/docs/api/classes/Matrix.md +23 -23
- package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +117 -34
- package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +117 -34
- package/docs-site-docusaurus/docs/api/classes/MinHeap.md +117 -34
- package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +117 -34
- package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +117 -34
- package/docs-site-docusaurus/docs/api/classes/Queue.md +142 -34
- package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +117 -117
- package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +158 -50
- package/docs-site-docusaurus/docs/api/classes/SkipList.md +21 -21
- package/docs-site-docusaurus/docs/api/classes/Stack.md +108 -26
- package/docs-site-docusaurus/docs/api/classes/TreeMap.md +33 -33
- package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +75 -39
- package/docs-site-docusaurus/docs/api/classes/TreeSet.md +301 -39
- package/docs-site-docusaurus/docs/api/classes/Trie.md +110 -28
- package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +20 -20
- package/jest.integration.config.js +1 -2
- package/package.json +51 -50
- package/src/common/error.ts +15 -32
- package/src/common/index.ts +0 -3
- package/src/data-structures/base/iterable-element-base.ts +32 -3
- package/src/data-structures/base/linear-base.ts +13 -36
- package/src/data-structures/binary-tree/avl-tree.ts +31 -493
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +47 -530
- package/src/data-structures/binary-tree/binary-tree.ts +326 -1236
- package/src/data-structures/binary-tree/bst.ts +158 -1010
- package/src/data-structures/binary-tree/red-black-tree.ts +451 -1233
- package/src/data-structures/binary-tree/segment-tree.ts +73 -333
- package/src/data-structures/binary-tree/tree-map.ts +462 -4749
- package/src/data-structures/binary-tree/tree-multi-map.ts +310 -4530
- package/src/data-structures/binary-tree/tree-multi-set.ts +300 -3652
- package/src/data-structures/binary-tree/tree-set.ts +437 -4443
- package/src/data-structures/graph/abstract-graph.ts +98 -167
- package/src/data-structures/graph/directed-graph.ts +137 -532
- package/src/data-structures/graph/map-graph.ts +0 -3
- package/src/data-structures/graph/undirected-graph.ts +132 -484
- package/src/data-structures/hash/hash-map.ts +154 -549
- package/src/data-structures/heap/heap.ts +200 -753
- package/src/data-structures/linked-list/doubly-linked-list.ts +153 -809
- package/src/data-structures/linked-list/singly-linked-list.ts +122 -749
- package/src/data-structures/linked-list/skip-linked-list.ts +211 -864
- package/src/data-structures/matrix/matrix.ts +179 -494
- 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 +241 -807
- package/src/data-structures/queue/queue.ts +102 -589
- package/src/data-structures/stack/stack.ts +76 -475
- package/src/data-structures/trie/trie.ts +98 -592
- 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
|
@@ -107,7 +107,7 @@ Time O(n) to iterate, Space O(1)
|
|
|
107
107
|
ceiling(key): [K, V | undefined] | undefined;
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
110
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:867](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L867)
|
|
111
111
|
|
|
112
112
|
Least entry ≥ key, or `undefined`.
|
|
113
113
|
|
|
@@ -140,7 +140,7 @@ Least entry ≥ key, or `undefined`.
|
|
|
140
140
|
clear(): void;
|
|
141
141
|
```
|
|
142
142
|
|
|
143
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
143
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:235](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L235)
|
|
144
144
|
|
|
145
145
|
Remove all entries
|
|
146
146
|
|
|
@@ -171,7 +171,7 @@ Remove all entries
|
|
|
171
171
|
clone(): this;
|
|
172
172
|
```
|
|
173
173
|
|
|
174
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
174
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:289](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L289)
|
|
175
175
|
|
|
176
176
|
Create independent copy
|
|
177
177
|
|
|
@@ -203,7 +203,7 @@ Create independent copy
|
|
|
203
203
|
delete(key): boolean;
|
|
204
204
|
```
|
|
205
205
|
|
|
206
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
206
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:574](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L574)
|
|
207
207
|
|
|
208
208
|
Delete a key. Returns `true` if the key was found and removed.
|
|
209
209
|
|
|
@@ -309,7 +309,7 @@ Time O(n), Space O(1)
|
|
|
309
309
|
filter(callbackfn, thisArg?): this;
|
|
310
310
|
```
|
|
311
311
|
|
|
312
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
312
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:1255](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L1255)
|
|
313
313
|
|
|
314
314
|
Creates a new SkipList with entries that pass the predicate.
|
|
315
315
|
|
|
@@ -390,7 +390,7 @@ Time O(n), Space O(1)
|
|
|
390
390
|
first(): [K, V | undefined] | undefined;
|
|
391
391
|
```
|
|
392
392
|
|
|
393
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
393
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:645](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L645)
|
|
394
394
|
|
|
395
395
|
Returns the first (smallest key) entry, or `undefined` if empty.
|
|
396
396
|
|
|
@@ -416,7 +416,7 @@ Returns the first (smallest key) entry, or `undefined` if empty.
|
|
|
416
416
|
floor(key): [K, V | undefined] | undefined;
|
|
417
417
|
```
|
|
418
418
|
|
|
419
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
419
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:929](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L929)
|
|
420
420
|
|
|
421
421
|
Greatest entry ≤ key, or `undefined`.
|
|
422
422
|
|
|
@@ -487,7 +487,7 @@ Time O(n), Space O(1)
|
|
|
487
487
|
get(key): V | undefined;
|
|
488
488
|
```
|
|
489
489
|
|
|
490
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
490
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:457](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L457)
|
|
491
491
|
|
|
492
492
|
Get the value for a key, or `undefined` if not found.
|
|
493
493
|
Overrides base O(n) with O(log n) skip-list search.
|
|
@@ -540,7 +540,7 @@ Overrides base O(n) with O(log n) skip-list search.
|
|
|
540
540
|
has(key): boolean;
|
|
541
541
|
```
|
|
542
542
|
|
|
543
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
543
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:513](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L513)
|
|
544
544
|
|
|
545
545
|
Check if a key exists.
|
|
546
546
|
Overrides base O(n) with O(log n) skip-list search.
|
|
@@ -612,7 +612,7 @@ Time O(n), Space O(1)
|
|
|
612
612
|
higher(key): [K, V | undefined] | undefined;
|
|
613
613
|
```
|
|
614
614
|
|
|
615
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
615
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:991](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L991)
|
|
616
616
|
|
|
617
617
|
Least entry strictly > key, or `undefined`.
|
|
618
618
|
|
|
@@ -645,7 +645,7 @@ Least entry strictly > key, or `undefined`.
|
|
|
645
645
|
isEmpty(): boolean;
|
|
646
646
|
```
|
|
647
647
|
|
|
648
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
648
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:184](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L184)
|
|
649
649
|
|
|
650
650
|
Check if empty
|
|
651
651
|
|
|
@@ -701,7 +701,7 @@ Time O(n), Space O(1)
|
|
|
701
701
|
last(): [K, V | undefined] | undefined;
|
|
702
702
|
```
|
|
703
703
|
|
|
704
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
704
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:699](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L699)
|
|
705
705
|
|
|
706
706
|
Returns the last (largest key) entry, or `undefined` if empty.
|
|
707
707
|
|
|
@@ -727,7 +727,7 @@ Returns the last (largest key) entry, or `undefined` if empty.
|
|
|
727
727
|
lower(key): [K, V | undefined] | undefined;
|
|
728
728
|
```
|
|
729
729
|
|
|
730
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
730
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:1050](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L1050)
|
|
731
731
|
|
|
732
732
|
Greatest entry strictly < key, or `undefined`.
|
|
733
733
|
|
|
@@ -760,7 +760,7 @@ Greatest entry strictly < key, or `undefined`.
|
|
|
760
760
|
map<MK, MV>(callback, options?): SkipList<MK, MV>;
|
|
761
761
|
```
|
|
762
762
|
|
|
763
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
763
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:1195](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L1195)
|
|
764
764
|
|
|
765
765
|
Creates a new SkipList with entries transformed by callback.
|
|
766
766
|
|
|
@@ -811,7 +811,7 @@ Creates a new SkipList with entries transformed by callback.
|
|
|
811
811
|
pollFirst(): [K, V | undefined] | undefined;
|
|
812
812
|
```
|
|
813
813
|
|
|
814
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
814
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:756](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L756)
|
|
815
815
|
|
|
816
816
|
Remove and return the first (smallest key) entry.
|
|
817
817
|
|
|
@@ -838,7 +838,7 @@ Remove and return the first (smallest key) entry.
|
|
|
838
838
|
pollLast(): [K, V | undefined] | undefined;
|
|
839
839
|
```
|
|
840
840
|
|
|
841
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
841
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:810](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L810)
|
|
842
842
|
|
|
843
843
|
Remove and return the last (largest key) entry.
|
|
844
844
|
|
|
@@ -889,7 +889,7 @@ Time O(n), Space O(n)
|
|
|
889
889
|
rangeSearch(range, options?): [K, V | undefined][];
|
|
890
890
|
```
|
|
891
891
|
|
|
892
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
892
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:1115](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L1115)
|
|
893
893
|
|
|
894
894
|
Returns entries within the given key range.
|
|
895
895
|
|
|
@@ -972,7 +972,7 @@ Time O(n), Space O(1)
|
|
|
972
972
|
set(key, value): this;
|
|
973
973
|
```
|
|
974
974
|
|
|
975
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
975
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:361](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L361)
|
|
976
976
|
|
|
977
977
|
Insert or update a key-value pair. Returns `this` for chaining.
|
|
978
978
|
Unique keys only — if key exists, value is updated in place.
|
|
@@ -1164,7 +1164,7 @@ Creates a default comparator supporting number, string, Date, and bigint.
|
|
|
1164
1164
|
protected _findNode(key): SkipListNode<K, V> | undefined;
|
|
1165
1165
|
```
|
|
1166
1166
|
|
|
1167
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
1167
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:1308](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L1308)
|
|
1168
1168
|
|
|
1169
1169
|
Finds the node for a given key, or undefined.
|
|
1170
1170
|
|
|
@@ -1186,7 +1186,7 @@ Finds the node for a given key, or undefined.
|
|
|
1186
1186
|
protected _findUpdate(key): SkipListNode<K, V>[];
|
|
1187
1187
|
```
|
|
1188
1188
|
|
|
1189
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
1189
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:1290](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L1290)
|
|
1190
1190
|
|
|
1191
1191
|
Finds the update array (predecessors at each level) for a given key.
|
|
1192
1192
|
|
|
@@ -1208,7 +1208,7 @@ Finds the update array (predecessors at each level) for a given key.
|
|
|
1208
1208
|
protected _getIterator(): IterableIterator<[K, V | undefined]>;
|
|
1209
1209
|
```
|
|
1210
1210
|
|
|
1211
|
-
Defined in: [data-structures/linked-list/skip-linked-list.ts:
|
|
1211
|
+
Defined in: [data-structures/linked-list/skip-linked-list.ts:1274](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/linked-list/skip-linked-list.ts#L1274)
|
|
1212
1212
|
|
|
1213
1213
|
Underlying iterator for the default iteration protocol.
|
|
1214
1214
|
|
|
@@ -236,7 +236,7 @@ Internal elements array.
|
|
|
236
236
|
get size(): number;
|
|
237
237
|
```
|
|
238
238
|
|
|
239
|
-
Defined in: [data-structures/stack/stack.ts:
|
|
239
|
+
Defined in: [data-structures/stack/stack.ts:213](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/stack/stack.ts#L213)
|
|
240
240
|
|
|
241
241
|
Get the number of stored elements.
|
|
242
242
|
|
|
@@ -330,7 +330,7 @@ Producing the iterator is O(1); consuming the entire iterator is Time O(n) with
|
|
|
330
330
|
clear(): void;
|
|
331
331
|
```
|
|
332
332
|
|
|
333
|
-
Defined in: [data-structures/stack/stack.ts:
|
|
333
|
+
Defined in: [data-structures/stack/stack.ts:642](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/stack/stack.ts#L642)
|
|
334
334
|
|
|
335
335
|
Remove all elements and reset storage.
|
|
336
336
|
|
|
@@ -367,7 +367,7 @@ Time O(1), Space O(1)
|
|
|
367
367
|
clone(): this;
|
|
368
368
|
```
|
|
369
369
|
|
|
370
|
-
Defined in: [data-structures/stack/stack.ts:
|
|
370
|
+
Defined in: [data-structures/stack/stack.ts:699](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/stack/stack.ts#L699)
|
|
371
371
|
|
|
372
372
|
Deep clone this stack.
|
|
373
373
|
|
|
@@ -406,7 +406,7 @@ Time O(N), Space O(N)
|
|
|
406
406
|
delete(element): boolean;
|
|
407
407
|
```
|
|
408
408
|
|
|
409
|
-
Defined in: [data-structures/stack/stack.ts:
|
|
409
|
+
Defined in: [data-structures/stack/stack.ts:556](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/stack/stack.ts#L556)
|
|
410
410
|
|
|
411
411
|
Delete the first occurrence of a specific element.
|
|
412
412
|
|
|
@@ -447,7 +447,7 @@ Time O(N), Space O(1)
|
|
|
447
447
|
deleteAt(index): E | undefined;
|
|
448
448
|
```
|
|
449
449
|
|
|
450
|
-
Defined in: [data-structures/stack/stack.ts:
|
|
450
|
+
Defined in: [data-structures/stack/stack.ts:568](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/stack/stack.ts#L568)
|
|
451
451
|
|
|
452
452
|
Delete the element at an index.
|
|
453
453
|
|
|
@@ -477,7 +477,7 @@ Time O(N), Space O(1)
|
|
|
477
477
|
deleteWhere(predicate): boolean;
|
|
478
478
|
```
|
|
479
479
|
|
|
480
|
-
Defined in: [data-structures/stack/stack.ts:
|
|
480
|
+
Defined in: [data-structures/stack/stack.ts:581](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/stack/stack.ts#L581)
|
|
481
481
|
|
|
482
482
|
Delete the first element that satisfies a predicate.
|
|
483
483
|
|
|
@@ -501,6 +501,30 @@ Time O(N), Space O(1)
|
|
|
501
501
|
|
|
502
502
|
***
|
|
503
503
|
|
|
504
|
+
### entries()
|
|
505
|
+
|
|
506
|
+
```ts
|
|
507
|
+
entries(): IterableIterator<[number, E]>;
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
Defined in: [data-structures/base/iterable-element-base.ts:208](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L208)
|
|
511
|
+
|
|
512
|
+
Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
513
|
+
|
|
514
|
+
#### Returns
|
|
515
|
+
|
|
516
|
+
`IterableIterator`\<\[`number`, `E`\]\>
|
|
517
|
+
|
|
518
|
+
#### Remarks
|
|
519
|
+
|
|
520
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
521
|
+
|
|
522
|
+
#### Inherited from
|
|
523
|
+
|
|
524
|
+
[`IterableElementBase`](IterableElementBase.md).[`entries`](IterableElementBase.md#entries)
|
|
525
|
+
|
|
526
|
+
***
|
|
527
|
+
|
|
504
528
|
### every()
|
|
505
529
|
|
|
506
530
|
```ts
|
|
@@ -547,7 +571,7 @@ Time O(n) in the worst case; may exit early when the first failure is found. Spa
|
|
|
547
571
|
filter(predicate, thisArg?): this;
|
|
548
572
|
```
|
|
549
573
|
|
|
550
|
-
Defined in: [data-structures/stack/stack.ts:
|
|
574
|
+
Defined in: [data-structures/stack/stack.ts:758](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/stack/stack.ts#L758)
|
|
551
575
|
|
|
552
576
|
Filter elements into a new stack of the same class.
|
|
553
577
|
|
|
@@ -756,13 +780,47 @@ Time O(n) in the worst case. Space O(1).
|
|
|
756
780
|
|
|
757
781
|
***
|
|
758
782
|
|
|
783
|
+
### includes()
|
|
784
|
+
|
|
785
|
+
```ts
|
|
786
|
+
includes(element): boolean;
|
|
787
|
+
```
|
|
788
|
+
|
|
789
|
+
Defined in: [data-structures/base/iterable-element-base.ts:200](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L200)
|
|
790
|
+
|
|
791
|
+
Check whether a value exists (Array-compatible alias for `has`).
|
|
792
|
+
|
|
793
|
+
#### Parameters
|
|
794
|
+
|
|
795
|
+
##### element
|
|
796
|
+
|
|
797
|
+
`E`
|
|
798
|
+
|
|
799
|
+
Element to search for (uses `===`).
|
|
800
|
+
|
|
801
|
+
#### Returns
|
|
802
|
+
|
|
803
|
+
`boolean`
|
|
804
|
+
|
|
805
|
+
`true` if found.
|
|
806
|
+
|
|
807
|
+
#### Remarks
|
|
808
|
+
|
|
809
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
810
|
+
|
|
811
|
+
#### Inherited from
|
|
812
|
+
|
|
813
|
+
[`IterableElementBase`](IterableElementBase.md).[`includes`](IterableElementBase.md#includes)
|
|
814
|
+
|
|
815
|
+
***
|
|
816
|
+
|
|
759
817
|
### isEmpty()
|
|
760
818
|
|
|
761
819
|
```ts
|
|
762
820
|
isEmpty(): boolean;
|
|
763
821
|
```
|
|
764
822
|
|
|
765
|
-
Defined in: [data-structures/stack/stack.ts:
|
|
823
|
+
Defined in: [data-structures/stack/stack.ts:290](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/stack/stack.ts#L290)
|
|
766
824
|
|
|
767
825
|
Check whether the stack is empty.
|
|
768
826
|
|
|
@@ -794,6 +852,30 @@ Time O(1), Space O(1)
|
|
|
794
852
|
|
|
795
853
|
***
|
|
796
854
|
|
|
855
|
+
### keys()
|
|
856
|
+
|
|
857
|
+
```ts
|
|
858
|
+
keys(): IterableIterator<number>;
|
|
859
|
+
```
|
|
860
|
+
|
|
861
|
+
Defined in: [data-structures/base/iterable-element-base.ts:219](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L219)
|
|
862
|
+
|
|
863
|
+
Return an iterator of numeric indices (Array-compatible).
|
|
864
|
+
|
|
865
|
+
#### Returns
|
|
866
|
+
|
|
867
|
+
`IterableIterator`\<`number`\>
|
|
868
|
+
|
|
869
|
+
#### Remarks
|
|
870
|
+
|
|
871
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
872
|
+
|
|
873
|
+
#### Inherited from
|
|
874
|
+
|
|
875
|
+
[`IterableElementBase`](IterableElementBase.md).[`keys`](IterableElementBase.md#keys)
|
|
876
|
+
|
|
877
|
+
***
|
|
878
|
+
|
|
797
879
|
### map()
|
|
798
880
|
|
|
799
881
|
```ts
|
|
@@ -803,7 +885,7 @@ map<EM, RM>(
|
|
|
803
885
|
thisArg?): Stack<EM, RM>;
|
|
804
886
|
```
|
|
805
887
|
|
|
806
|
-
Defined in: [data-structures/stack/stack.ts:
|
|
888
|
+
Defined in: [data-structures/stack/stack.ts:841](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/stack/stack.ts#L841)
|
|
807
889
|
|
|
808
890
|
Map values into a new stack (possibly different element type).
|
|
809
891
|
|
|
@@ -870,7 +952,7 @@ Time O(N), Space O(N)
|
|
|
870
952
|
mapSame(callback, thisArg?): this;
|
|
871
953
|
```
|
|
872
954
|
|
|
873
|
-
Defined in: [data-structures/stack/stack.ts:
|
|
955
|
+
Defined in: [data-structures/stack/stack.ts:776](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/stack/stack.ts#L776)
|
|
874
956
|
|
|
875
957
|
Map values into a new stack of the same element type.
|
|
876
958
|
|
|
@@ -910,7 +992,7 @@ Time O(N), Space O(N)
|
|
|
910
992
|
peek(): E | undefined;
|
|
911
993
|
```
|
|
912
994
|
|
|
913
|
-
Defined in: [data-structures/stack/stack.ts:
|
|
995
|
+
Defined in: [data-structures/stack/stack.ts:347](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/stack/stack.ts#L347)
|
|
914
996
|
|
|
915
997
|
Get the top element without removing it.
|
|
916
998
|
|
|
@@ -943,7 +1025,7 @@ Time O(1), Space O(1)
|
|
|
943
1025
|
pop(): E | undefined;
|
|
944
1026
|
```
|
|
945
1027
|
|
|
946
|
-
Defined in: [data-structures/stack/stack.ts:
|
|
1028
|
+
Defined in: [data-structures/stack/stack.ts:485](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/stack/stack.ts#L485)
|
|
947
1029
|
|
|
948
1030
|
Pop and return the top element.
|
|
949
1031
|
|
|
@@ -989,7 +1071,7 @@ Time O(1), Space O(1)
|
|
|
989
1071
|
print(): void;
|
|
990
1072
|
```
|
|
991
1073
|
|
|
992
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1074
|
+
Defined in: [data-structures/base/iterable-element-base.ts:301](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L301)
|
|
993
1075
|
|
|
994
1076
|
Prints `toVisual()` to the console. Intended for quick debugging.
|
|
995
1077
|
|
|
@@ -1015,7 +1097,7 @@ Time O(n) due to materialization, Space O(n) for the intermediate representation
|
|
|
1015
1097
|
push(element): boolean;
|
|
1016
1098
|
```
|
|
1017
1099
|
|
|
1018
|
-
Defined in: [data-structures/stack/stack.ts:
|
|
1100
|
+
Defined in: [data-structures/stack/stack.ts:414](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/stack/stack.ts#L414)
|
|
1019
1101
|
|
|
1020
1102
|
Push one element onto the top.
|
|
1021
1103
|
|
|
@@ -1065,7 +1147,7 @@ Time O(1), Space O(1)
|
|
|
1065
1147
|
pushMany(elements): boolean[];
|
|
1066
1148
|
```
|
|
1067
1149
|
|
|
1068
|
-
Defined in: [data-structures/stack/stack.ts:
|
|
1150
|
+
Defined in: [data-structures/stack/stack.ts:496](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/stack/stack.ts#L496)
|
|
1069
1151
|
|
|
1070
1152
|
Push many elements from an iterable.
|
|
1071
1153
|
|
|
@@ -1127,7 +1209,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
|
|
|
1127
1209
|
reduce(callbackfn): E;
|
|
1128
1210
|
```
|
|
1129
1211
|
|
|
1130
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1212
|
+
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)
|
|
1131
1213
|
|
|
1132
1214
|
##### Parameters
|
|
1133
1215
|
|
|
@@ -1149,7 +1231,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
|
|
|
1149
1231
|
reduce(callbackfn, initialValue): E;
|
|
1150
1232
|
```
|
|
1151
1233
|
|
|
1152
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1234
|
+
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)
|
|
1153
1235
|
|
|
1154
1236
|
##### Parameters
|
|
1155
1237
|
|
|
@@ -1175,7 +1257,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
|
|
|
1175
1257
|
reduce<U>(callbackfn, initialValue): U;
|
|
1176
1258
|
```
|
|
1177
1259
|
|
|
1178
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1260
|
+
Defined in: [data-structures/base/iterable-element-base.ts:228](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L228)
|
|
1179
1261
|
|
|
1180
1262
|
##### Type Parameters
|
|
1181
1263
|
|
|
@@ -1209,7 +1291,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:196](https://github.c
|
|
|
1209
1291
|
setEquality(equals): this;
|
|
1210
1292
|
```
|
|
1211
1293
|
|
|
1212
|
-
Defined in: [data-structures/stack/stack.ts:
|
|
1294
|
+
Defined in: [data-structures/stack/stack.ts:862](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/stack/stack.ts#L862)
|
|
1213
1295
|
|
|
1214
1296
|
Set the equality comparator used by delete/search operations.
|
|
1215
1297
|
|
|
@@ -1279,7 +1361,7 @@ Time O(n) in the worst case; may exit early on first success. Space O(1).
|
|
|
1279
1361
|
toArray(): E[];
|
|
1280
1362
|
```
|
|
1281
1363
|
|
|
1282
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1364
|
+
Defined in: [data-structures/base/iterable-element-base.ts:278](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L278)
|
|
1283
1365
|
|
|
1284
1366
|
Materializes the elements into a new array.
|
|
1285
1367
|
|
|
@@ -1305,7 +1387,7 @@ Time O(n), Space O(n).
|
|
|
1305
1387
|
toVisual(): E[];
|
|
1306
1388
|
```
|
|
1307
1389
|
|
|
1308
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1390
|
+
Defined in: [data-structures/base/iterable-element-base.ts:290](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-element-base.ts#L290)
|
|
1309
1391
|
|
|
1310
1392
|
Returns a representation of the structure suitable for quick visualization.
|
|
1311
1393
|
Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
@@ -1361,7 +1443,7 @@ static fromArray<E, R>(
|
|
|
1361
1443
|
options?): any;
|
|
1362
1444
|
```
|
|
1363
1445
|
|
|
1364
|
-
Defined in: [data-structures/stack/stack.ts:
|
|
1446
|
+
Defined in: [data-structures/stack/stack.ts:228](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/stack/stack.ts#L228)
|
|
1365
1447
|
|
|
1366
1448
|
Create a stack from an array of elements.
|
|
1367
1449
|
|
|
@@ -1446,7 +1528,7 @@ Time O(1), Space O(1).
|
|
|
1446
1528
|
protected _createInstance(options?): this;
|
|
1447
1529
|
```
|
|
1448
1530
|
|
|
1449
|
-
Defined in: [data-structures/stack/stack.ts:
|
|
1531
|
+
Defined in: [data-structures/stack/stack.ts:886](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/stack/stack.ts#L886)
|
|
1450
1532
|
|
|
1451
1533
|
(Protected) Create an empty instance of the same concrete class.
|
|
1452
1534
|
|
|
@@ -1476,7 +1558,7 @@ Time O(1), Space O(1)
|
|
|
1476
1558
|
protected _createLike<T, RR>(elements?, options?): Stack<T, RR>;
|
|
1477
1559
|
```
|
|
1478
1560
|
|
|
1479
|
-
Defined in: [data-structures/stack/stack.ts:
|
|
1561
|
+
Defined in: [data-structures/stack/stack.ts:901](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/stack/stack.ts#L901)
|
|
1480
1562
|
|
|
1481
1563
|
(Protected) Create a like-kind stack and seed it from an iterable.
|
|
1482
1564
|
|
|
@@ -1522,7 +1604,7 @@ Time O(N), Space O(N)
|
|
|
1522
1604
|
protected _getIterator(): IterableIterator<E>;
|
|
1523
1605
|
```
|
|
1524
1606
|
|
|
1525
|
-
Defined in: [data-structures/stack/stack.ts:
|
|
1607
|
+
Defined in: [data-structures/stack/stack.ts:918](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/stack/stack.ts#L918)
|
|
1526
1608
|
|
|
1527
1609
|
(Protected) Iterate elements from bottom to top.
|
|
1528
1610
|
|
|
@@ -1548,7 +1630,7 @@ Time O(N), Space O(1)
|
|
|
1548
1630
|
protected _indexOfByEquals(target): number;
|
|
1549
1631
|
```
|
|
1550
1632
|
|
|
1551
|
-
Defined in: [data-structures/stack/stack.ts:
|
|
1633
|
+
Defined in: [data-structures/stack/stack.ts:874](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/stack/stack.ts#L874)
|
|
1552
1634
|
|
|
1553
1635
|
(Protected) Find the index of a target element using the equality function.
|
|
1554
1636
|
|