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
|
@@ -233,7 +233,7 @@ Backing array of elements.
|
|
|
233
233
|
get first(): E | undefined;
|
|
234
234
|
```
|
|
235
235
|
|
|
236
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
236
|
+
Defined in: [data-structures/queue/queue.ts:268](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L268)
|
|
237
237
|
|
|
238
238
|
Get the first element (front) without removing it.
|
|
239
239
|
|
|
@@ -268,7 +268,7 @@ Front element or undefined.
|
|
|
268
268
|
get last(): E | undefined;
|
|
269
269
|
```
|
|
270
270
|
|
|
271
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
271
|
+
Defined in: [data-structures/queue/queue.ts:287](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L287)
|
|
272
272
|
|
|
273
273
|
Get the last element (back) without removing it.
|
|
274
274
|
|
|
@@ -292,7 +292,7 @@ Back element or undefined.
|
|
|
292
292
|
get length(): number;
|
|
293
293
|
```
|
|
294
294
|
|
|
295
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
295
|
+
Defined in: [data-structures/queue/queue.ts:211](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L211)
|
|
296
296
|
|
|
297
297
|
Get the number of elements currently in the queue.
|
|
298
298
|
|
|
@@ -445,7 +445,7 @@ Producing the iterator is O(1); consuming the entire iterator is Time O(n) with
|
|
|
445
445
|
addAt(index, newElement): boolean;
|
|
446
446
|
```
|
|
447
447
|
|
|
448
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
448
|
+
Defined in: [data-structures/queue/queue.ts:663](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L663)
|
|
449
449
|
|
|
450
450
|
Insert a new element at a given index.
|
|
451
451
|
|
|
@@ -485,7 +485,7 @@ Time O(N), Space O(1)
|
|
|
485
485
|
at(index): E | undefined;
|
|
486
486
|
```
|
|
487
487
|
|
|
488
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
488
|
+
Defined in: [data-structures/queue/queue.ts:636](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L636)
|
|
489
489
|
|
|
490
490
|
Get the element at a given logical index.
|
|
491
491
|
|
|
@@ -530,7 +530,7 @@ Time O(1), Space O(1)
|
|
|
530
530
|
clear(): void;
|
|
531
531
|
```
|
|
532
532
|
|
|
533
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
533
|
+
Defined in: [data-structures/queue/queue.ts:762](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L762)
|
|
534
534
|
|
|
535
535
|
Remove all elements and reset offset.
|
|
536
536
|
|
|
@@ -567,7 +567,7 @@ Time O(1), Space O(1)
|
|
|
567
567
|
clone(): this;
|
|
568
568
|
```
|
|
569
569
|
|
|
570
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
570
|
+
Defined in: [data-structures/queue/queue.ts:903](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L903)
|
|
571
571
|
|
|
572
572
|
Deep clone this queue and its parameters.
|
|
573
573
|
|
|
@@ -606,7 +606,7 @@ Time O(N), Space O(N)
|
|
|
606
606
|
compact(): boolean;
|
|
607
607
|
```
|
|
608
608
|
|
|
609
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
609
|
+
Defined in: [data-structures/queue/queue.ts:819](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L819)
|
|
610
610
|
|
|
611
611
|
Compact storage by discarding consumed head elements.
|
|
612
612
|
|
|
@@ -675,7 +675,7 @@ Time O(sum(length)), Space O(sum(length))
|
|
|
675
675
|
delete(element): boolean;
|
|
676
676
|
```
|
|
677
677
|
|
|
678
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
678
|
+
Defined in: [data-structures/queue/queue.ts:575](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L575)
|
|
679
679
|
|
|
680
680
|
Delete the first occurrence of a specific element.
|
|
681
681
|
|
|
@@ -720,7 +720,7 @@ Time O(N), Space O(1)
|
|
|
720
720
|
deleteAt(index): E | undefined;
|
|
721
721
|
```
|
|
722
722
|
|
|
723
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
723
|
+
Defined in: [data-structures/queue/queue.ts:648](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L648)
|
|
724
724
|
|
|
725
725
|
Delete the element at a given index.
|
|
726
726
|
|
|
@@ -754,7 +754,7 @@ Time O(N), Space O(1)
|
|
|
754
754
|
deleteWhere(predicate): boolean;
|
|
755
755
|
```
|
|
756
756
|
|
|
757
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
757
|
+
Defined in: [data-structures/queue/queue.ts:689](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L689)
|
|
758
758
|
|
|
759
759
|
Delete the first element that satisfies a predicate.
|
|
760
760
|
|
|
@@ -778,6 +778,30 @@ Time O(N), Space O(N)
|
|
|
778
778
|
|
|
779
779
|
***
|
|
780
780
|
|
|
781
|
+
### entries()
|
|
782
|
+
|
|
783
|
+
```ts
|
|
784
|
+
entries(): IterableIterator<[number, E]>;
|
|
785
|
+
```
|
|
786
|
+
|
|
787
|
+
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)
|
|
788
|
+
|
|
789
|
+
Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
790
|
+
|
|
791
|
+
#### Returns
|
|
792
|
+
|
|
793
|
+
`IterableIterator`\<\[`number`, `E`\]\>
|
|
794
|
+
|
|
795
|
+
#### Remarks
|
|
796
|
+
|
|
797
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
798
|
+
|
|
799
|
+
#### Inherited from
|
|
800
|
+
|
|
801
|
+
[`LinearBase`](LinearBase.md).[`entries`](LinearBase.md#entries)
|
|
802
|
+
|
|
803
|
+
***
|
|
804
|
+
|
|
781
805
|
### every()
|
|
782
806
|
|
|
783
807
|
```ts
|
|
@@ -873,7 +897,7 @@ Time O(n), Space O(1)
|
|
|
873
897
|
filter(predicate, thisArg?): this;
|
|
874
898
|
```
|
|
875
899
|
|
|
876
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
900
|
+
Defined in: [data-structures/queue/queue.ts:963](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L963)
|
|
877
901
|
|
|
878
902
|
Filter elements into a new queue of the same class.
|
|
879
903
|
|
|
@@ -1122,6 +1146,40 @@ Time O(n) in the worst case. Space O(1).
|
|
|
1122
1146
|
|
|
1123
1147
|
***
|
|
1124
1148
|
|
|
1149
|
+
### includes()
|
|
1150
|
+
|
|
1151
|
+
```ts
|
|
1152
|
+
includes(element): boolean;
|
|
1153
|
+
```
|
|
1154
|
+
|
|
1155
|
+
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)
|
|
1156
|
+
|
|
1157
|
+
Check whether a value exists (Array-compatible alias for `has`).
|
|
1158
|
+
|
|
1159
|
+
#### Parameters
|
|
1160
|
+
|
|
1161
|
+
##### element
|
|
1162
|
+
|
|
1163
|
+
`E`
|
|
1164
|
+
|
|
1165
|
+
Element to search for (uses `===`).
|
|
1166
|
+
|
|
1167
|
+
#### Returns
|
|
1168
|
+
|
|
1169
|
+
`boolean`
|
|
1170
|
+
|
|
1171
|
+
`true` if found.
|
|
1172
|
+
|
|
1173
|
+
#### Remarks
|
|
1174
|
+
|
|
1175
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
1176
|
+
|
|
1177
|
+
#### Inherited from
|
|
1178
|
+
|
|
1179
|
+
[`LinearBase`](LinearBase.md).[`includes`](LinearBase.md#includes)
|
|
1180
|
+
|
|
1181
|
+
***
|
|
1182
|
+
|
|
1125
1183
|
### indexOf()
|
|
1126
1184
|
|
|
1127
1185
|
```ts
|
|
@@ -1168,7 +1226,7 @@ Time O(n), Space O(1)
|
|
|
1168
1226
|
isEmpty(): boolean;
|
|
1169
1227
|
```
|
|
1170
1228
|
|
|
1171
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
1229
|
+
Defined in: [data-structures/queue/queue.ts:369](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L369)
|
|
1172
1230
|
|
|
1173
1231
|
Check whether the queue is empty.
|
|
1174
1232
|
|
|
@@ -1246,6 +1304,30 @@ Time O(n), Space O(n)
|
|
|
1246
1304
|
|
|
1247
1305
|
***
|
|
1248
1306
|
|
|
1307
|
+
### keys()
|
|
1308
|
+
|
|
1309
|
+
```ts
|
|
1310
|
+
keys(): IterableIterator<number>;
|
|
1311
|
+
```
|
|
1312
|
+
|
|
1313
|
+
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)
|
|
1314
|
+
|
|
1315
|
+
Return an iterator of numeric indices (Array-compatible).
|
|
1316
|
+
|
|
1317
|
+
#### Returns
|
|
1318
|
+
|
|
1319
|
+
`IterableIterator`\<`number`\>
|
|
1320
|
+
|
|
1321
|
+
#### Remarks
|
|
1322
|
+
|
|
1323
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
1324
|
+
|
|
1325
|
+
#### Inherited from
|
|
1326
|
+
|
|
1327
|
+
[`LinearBase`](LinearBase.md).[`keys`](LinearBase.md#keys)
|
|
1328
|
+
|
|
1329
|
+
***
|
|
1330
|
+
|
|
1249
1331
|
### lastIndexOf()
|
|
1250
1332
|
|
|
1251
1333
|
```ts
|
|
@@ -1295,7 +1377,7 @@ map<EM, RM>(
|
|
|
1295
1377
|
thisArg?): Queue<EM, RM>;
|
|
1296
1378
|
```
|
|
1297
1379
|
|
|
1298
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
1380
|
+
Defined in: [data-structures/queue/queue.ts:1029](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L1029)
|
|
1299
1381
|
|
|
1300
1382
|
Map each element to a new element in a possibly different-typed queue.
|
|
1301
1383
|
|
|
@@ -1362,7 +1444,7 @@ Time O(N), Space O(N)
|
|
|
1362
1444
|
mapSame(callback, thisArg?): this;
|
|
1363
1445
|
```
|
|
1364
1446
|
|
|
1365
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
1447
|
+
Defined in: [data-structures/queue/queue.ts:1052](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L1052)
|
|
1366
1448
|
|
|
1367
1449
|
Map each element to a new value of the same type.
|
|
1368
1450
|
|
|
@@ -1402,7 +1484,7 @@ Time O(N), Space O(N)
|
|
|
1402
1484
|
peek(): E | undefined;
|
|
1403
1485
|
```
|
|
1404
1486
|
|
|
1405
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
1487
|
+
Defined in: [data-structures/queue/queue.ts:277](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L277)
|
|
1406
1488
|
|
|
1407
1489
|
Peek at the front element without removing it (alias for `first`).
|
|
1408
1490
|
|
|
@@ -1424,7 +1506,7 @@ Time O(1), Space O(1)
|
|
|
1424
1506
|
print(): void;
|
|
1425
1507
|
```
|
|
1426
1508
|
|
|
1427
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1509
|
+
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)
|
|
1428
1510
|
|
|
1429
1511
|
Prints `toVisual()` to the console. Intended for quick debugging.
|
|
1430
1512
|
|
|
@@ -1450,7 +1532,7 @@ Time O(n) due to materialization, Space O(n) for the intermediate representation
|
|
|
1450
1532
|
push(element): boolean;
|
|
1451
1533
|
```
|
|
1452
1534
|
|
|
1453
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
1535
|
+
Defined in: [data-structures/queue/queue.ts:432](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L432)
|
|
1454
1536
|
|
|
1455
1537
|
Enqueue one element at the back.
|
|
1456
1538
|
|
|
@@ -1500,7 +1582,7 @@ Time O(1), Space O(1)
|
|
|
1500
1582
|
pushMany(elements): boolean[];
|
|
1501
1583
|
```
|
|
1502
1584
|
|
|
1503
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
1585
|
+
Defined in: [data-structures/queue/queue.ts:445](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L445)
|
|
1504
1586
|
|
|
1505
1587
|
Enqueue many elements from an iterable.
|
|
1506
1588
|
|
|
@@ -1566,7 +1648,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
|
|
|
1566
1648
|
reduce(callbackfn): E;
|
|
1567
1649
|
```
|
|
1568
1650
|
|
|
1569
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1651
|
+
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)
|
|
1570
1652
|
|
|
1571
1653
|
##### Parameters
|
|
1572
1654
|
|
|
@@ -1588,7 +1670,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
|
|
|
1588
1670
|
reduce(callbackfn, initialValue): E;
|
|
1589
1671
|
```
|
|
1590
1672
|
|
|
1591
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1673
|
+
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)
|
|
1592
1674
|
|
|
1593
1675
|
##### Parameters
|
|
1594
1676
|
|
|
@@ -1614,7 +1696,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
|
|
|
1614
1696
|
reduce<U>(callbackfn, initialValue): U;
|
|
1615
1697
|
```
|
|
1616
1698
|
|
|
1617
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1699
|
+
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)
|
|
1618
1700
|
|
|
1619
1701
|
##### Type Parameters
|
|
1620
1702
|
|
|
@@ -1694,7 +1776,7 @@ Time O(n), Space O(1)
|
|
|
1694
1776
|
reverse(): this;
|
|
1695
1777
|
```
|
|
1696
1778
|
|
|
1697
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
1779
|
+
Defined in: [data-structures/queue/queue.ts:705](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L705)
|
|
1698
1780
|
|
|
1699
1781
|
Reverse the queue in-place by compacting then reversing.
|
|
1700
1782
|
|
|
@@ -1720,7 +1802,7 @@ Time O(N), Space O(N)
|
|
|
1720
1802
|
setAt(index, newElement): boolean;
|
|
1721
1803
|
```
|
|
1722
1804
|
|
|
1723
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
1805
|
+
Defined in: [data-structures/queue/queue.ts:677](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L677)
|
|
1724
1806
|
|
|
1725
1807
|
Replace the element at a given index.
|
|
1726
1808
|
|
|
@@ -1760,7 +1842,7 @@ Time O(1), Space O(1)
|
|
|
1760
1842
|
shift(): E | undefined;
|
|
1761
1843
|
```
|
|
1762
1844
|
|
|
1763
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
1845
|
+
Defined in: [data-structures/queue/queue.ts:516](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L516)
|
|
1764
1846
|
|
|
1765
1847
|
Dequeue one element from the front (amortized via offset).
|
|
1766
1848
|
|
|
@@ -1919,7 +2001,7 @@ splice(
|
|
|
1919
2001
|
items?): this;
|
|
1920
2002
|
```
|
|
1921
2003
|
|
|
1922
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
2004
|
+
Defined in: [data-structures/queue/queue.ts:834](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L834)
|
|
1923
2005
|
|
|
1924
2006
|
Remove and/or insert elements at a position (array-like).
|
|
1925
2007
|
|
|
@@ -1965,7 +2047,7 @@ Time O(N + M), Space O(M)
|
|
|
1965
2047
|
toArray(): E[];
|
|
1966
2048
|
```
|
|
1967
2049
|
|
|
1968
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
2050
|
+
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)
|
|
1969
2051
|
|
|
1970
2052
|
Materializes the elements into a new array.
|
|
1971
2053
|
|
|
@@ -1985,6 +2067,32 @@ Time O(n), Space O(n).
|
|
|
1985
2067
|
|
|
1986
2068
|
***
|
|
1987
2069
|
|
|
2070
|
+
### toReversed()
|
|
2071
|
+
|
|
2072
|
+
```ts
|
|
2073
|
+
toReversed(): this;
|
|
2074
|
+
```
|
|
2075
|
+
|
|
2076
|
+
Defined in: [data-structures/base/linear-base.ts:335](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/linear-base.ts#L335)
|
|
2077
|
+
|
|
2078
|
+
Return a new instance of the same type with elements in reverse order (non-mutating).
|
|
2079
|
+
|
|
2080
|
+
#### Returns
|
|
2081
|
+
|
|
2082
|
+
`this`
|
|
2083
|
+
|
|
2084
|
+
A new reversed instance.
|
|
2085
|
+
|
|
2086
|
+
#### Remarks
|
|
2087
|
+
|
|
2088
|
+
Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
|
|
2089
|
+
|
|
2090
|
+
#### Inherited from
|
|
2091
|
+
|
|
2092
|
+
[`LinearBase`](LinearBase.md).[`toReversed`](LinearBase.md#toreversed)
|
|
2093
|
+
|
|
2094
|
+
***
|
|
2095
|
+
|
|
1988
2096
|
### toReversedArray()
|
|
1989
2097
|
|
|
1990
2098
|
```ts
|
|
@@ -2017,7 +2125,7 @@ Time O(n), Space O(n)
|
|
|
2017
2125
|
toVisual(): E[];
|
|
2018
2126
|
```
|
|
2019
2127
|
|
|
2020
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
2128
|
+
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)
|
|
2021
2129
|
|
|
2022
2130
|
Returns a representation of the structure suitable for quick visualization.
|
|
2023
2131
|
Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
@@ -2070,7 +2178,7 @@ Creating the iterator is O(1); full iteration is Time O(n), Space O(1).
|
|
|
2070
2178
|
static fromArray<E>(elements): Queue<E>;
|
|
2071
2179
|
```
|
|
2072
2180
|
|
|
2073
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
2181
|
+
Defined in: [data-structures/queue/queue.ts:299](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L299)
|
|
2074
2182
|
|
|
2075
2183
|
Create a queue from an array of elements.
|
|
2076
2184
|
|
|
@@ -2139,7 +2247,7 @@ Time O(1), Space O(1).
|
|
|
2139
2247
|
protected _createInstance(options?): this;
|
|
2140
2248
|
```
|
|
2141
2249
|
|
|
2142
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
2250
|
+
Defined in: [data-structures/queue/queue.ts:1112](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L1112)
|
|
2143
2251
|
|
|
2144
2252
|
(Protected) Create an empty instance of the same concrete class.
|
|
2145
2253
|
|
|
@@ -2173,7 +2281,7 @@ Time O(1), Space O(1)
|
|
|
2173
2281
|
protected _createLike<EM, RM>(elements?, options?): Queue<EM, RM>;
|
|
2174
2282
|
```
|
|
2175
2283
|
|
|
2176
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
2284
|
+
Defined in: [data-structures/queue/queue.ts:1127](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L1127)
|
|
2177
2285
|
|
|
2178
2286
|
(Protected) Create a like-kind queue and seed it from an iterable.
|
|
2179
2287
|
|
|
@@ -2219,7 +2327,7 @@ Time O(N), Space O(N)
|
|
|
2219
2327
|
protected _getIterator(): IterableIterator<E>;
|
|
2220
2328
|
```
|
|
2221
2329
|
|
|
2222
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
2330
|
+
Defined in: [data-structures/queue/queue.ts:1088](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L1088)
|
|
2223
2331
|
|
|
2224
2332
|
(Protected) Iterate elements from front to back.
|
|
2225
2333
|
|
|
@@ -2245,7 +2353,7 @@ Time O(N), Space O(1)
|
|
|
2245
2353
|
protected _getReverseIterator(): IterableIterator<E>;
|
|
2246
2354
|
```
|
|
2247
2355
|
|
|
2248
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
2356
|
+
Defined in: [data-structures/queue/queue.ts:1098](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L1098)
|
|
2249
2357
|
|
|
2250
2358
|
(Protected) Iterate elements from back to front.
|
|
2251
2359
|
|
|
@@ -2271,7 +2379,7 @@ Time O(N), Space O(1)
|
|
|
2271
2379
|
protected _setAutoCompactRatio(value): void;
|
|
2272
2380
|
```
|
|
2273
2381
|
|
|
2274
|
-
Defined in: [data-structures/queue/queue.ts:
|
|
2382
|
+
Defined in: [data-structures/queue/queue.ts:1078](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/queue.ts#L1078)
|
|
2275
2383
|
|
|
2276
2384
|
(Protected) Set the internal auto-compaction ratio.
|
|
2277
2385
|
|