data-structure-typed 2.6.0 → 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/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 +23 -23
- 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/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 +284 -3972
- 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
|
@@ -317,10 +317,12 @@ Bucket capacity per bucket.
|
|
|
317
317
|
get first(): E | undefined;
|
|
318
318
|
```
|
|
319
319
|
|
|
320
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
320
|
+
Defined in: [data-structures/queue/deque.ts:335](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L335)
|
|
321
321
|
|
|
322
322
|
Deque peek at both ends
|
|
323
323
|
|
|
324
|
+
*
|
|
325
|
+
|
|
324
326
|
##### Example
|
|
325
327
|
|
|
326
328
|
```ts
|
|
@@ -377,7 +379,7 @@ Zero-based index within the first bucket.
|
|
|
377
379
|
get last(): E | undefined;
|
|
378
380
|
```
|
|
379
381
|
|
|
380
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
382
|
+
Defined in: [data-structures/queue/deque.ts:393](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L393)
|
|
381
383
|
|
|
382
384
|
Get the last element without removing it.
|
|
383
385
|
|
|
@@ -555,7 +557,7 @@ addAt(
|
|
|
555
557
|
num?): boolean;
|
|
556
558
|
```
|
|
557
559
|
|
|
558
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
560
|
+
Defined in: [data-structures/queue/deque.ts:964](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L964)
|
|
559
561
|
|
|
560
562
|
Insert repeated copies of an element at a position.
|
|
561
563
|
|
|
@@ -601,7 +603,7 @@ Time O(N), Space O(1)
|
|
|
601
603
|
at(pos): E | undefined;
|
|
602
604
|
```
|
|
603
605
|
|
|
604
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
606
|
+
Defined in: [data-structures/queue/deque.ts:934](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L934)
|
|
605
607
|
|
|
606
608
|
Get the element at a given position.
|
|
607
609
|
|
|
@@ -646,7 +648,7 @@ Time O(1), Space O(1)
|
|
|
646
648
|
clear(): void;
|
|
647
649
|
```
|
|
648
650
|
|
|
649
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
651
|
+
Defined in: [data-structures/queue/deque.ts:876](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L876)
|
|
650
652
|
|
|
651
653
|
Remove all elements and reset structure.
|
|
652
654
|
|
|
@@ -683,7 +685,7 @@ Time O(1), Space O(1)
|
|
|
683
685
|
clone(): this;
|
|
684
686
|
```
|
|
685
687
|
|
|
686
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
688
|
+
Defined in: [data-structures/queue/deque.ts:1531](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1531)
|
|
687
689
|
|
|
688
690
|
Deep clone this deque, preserving options.
|
|
689
691
|
|
|
@@ -722,7 +724,7 @@ Time O(N), Space O(N)
|
|
|
722
724
|
compact(): boolean;
|
|
723
725
|
```
|
|
724
726
|
|
|
725
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
727
|
+
Defined in: [data-structures/queue/deque.ts:1450](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1450)
|
|
726
728
|
|
|
727
729
|
Compact the deque by removing unused buckets.
|
|
728
730
|
|
|
@@ -791,7 +793,7 @@ Time O(sum(length)), Space O(sum(length))
|
|
|
791
793
|
cut(pos, isCutSelf?): Deque<E>;
|
|
792
794
|
```
|
|
793
795
|
|
|
794
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
796
|
+
Defined in: [data-structures/queue/deque.ts:992](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L992)
|
|
795
797
|
|
|
796
798
|
Cut the deque to keep items up to index; optionally mutate in-place.
|
|
797
799
|
|
|
@@ -827,7 +829,7 @@ Time O(N), Space O(1)
|
|
|
827
829
|
cutRest(pos, isCutSelf?): Deque<E>;
|
|
828
830
|
```
|
|
829
831
|
|
|
830
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
832
|
+
Defined in: [data-structures/queue/deque.ts:1059](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1059)
|
|
831
833
|
|
|
832
834
|
Cut the deque to keep items from index onward; optionally mutate in-place.
|
|
833
835
|
|
|
@@ -863,7 +865,7 @@ Time O(N), Space O(1)
|
|
|
863
865
|
delete(element): boolean;
|
|
864
866
|
```
|
|
865
867
|
|
|
866
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
868
|
+
Defined in: [data-structures/queue/deque.ts:1165](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1165)
|
|
867
869
|
|
|
868
870
|
Delete the first occurrence of a value.
|
|
869
871
|
|
|
@@ -908,7 +910,7 @@ Time O(N), Space O(1)
|
|
|
908
910
|
deleteAt(pos): E | undefined;
|
|
909
911
|
```
|
|
910
912
|
|
|
911
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
913
|
+
Defined in: [data-structures/queue/deque.ts:1088](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1088)
|
|
912
914
|
|
|
913
915
|
Delete the element at a given position.
|
|
914
916
|
|
|
@@ -942,7 +944,7 @@ Time O(N), Space O(1)
|
|
|
942
944
|
deleteWhere(predicate): boolean;
|
|
943
945
|
```
|
|
944
946
|
|
|
945
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
947
|
+
Defined in: [data-structures/queue/deque.ts:1189](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1189)
|
|
946
948
|
|
|
947
949
|
Delete the first element matching a predicate.
|
|
948
950
|
|
|
@@ -966,6 +968,30 @@ Time O(N), Space O(1)
|
|
|
966
968
|
|
|
967
969
|
***
|
|
968
970
|
|
|
971
|
+
### entries()
|
|
972
|
+
|
|
973
|
+
```ts
|
|
974
|
+
entries(): IterableIterator<[number, E]>;
|
|
975
|
+
```
|
|
976
|
+
|
|
977
|
+
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)
|
|
978
|
+
|
|
979
|
+
Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
980
|
+
|
|
981
|
+
#### Returns
|
|
982
|
+
|
|
983
|
+
`IterableIterator`\<\[`number`, `E`\]\>
|
|
984
|
+
|
|
985
|
+
#### Remarks
|
|
986
|
+
|
|
987
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
988
|
+
|
|
989
|
+
#### Inherited from
|
|
990
|
+
|
|
991
|
+
[`LinearBase`](LinearBase.md).[`entries`](LinearBase.md#entries)
|
|
992
|
+
|
|
993
|
+
***
|
|
994
|
+
|
|
969
995
|
### every()
|
|
970
996
|
|
|
971
997
|
```ts
|
|
@@ -1061,7 +1087,7 @@ Time O(n), Space O(1)
|
|
|
1061
1087
|
filter(predicate, thisArg?): this;
|
|
1062
1088
|
```
|
|
1063
1089
|
|
|
1064
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
1090
|
+
Defined in: [data-structures/queue/deque.ts:1592](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1592)
|
|
1065
1091
|
|
|
1066
1092
|
Filter elements into a new deque of the same class.
|
|
1067
1093
|
|
|
@@ -1236,6 +1262,86 @@ Time O(n), Space O(1)
|
|
|
1236
1262
|
|
|
1237
1263
|
***
|
|
1238
1264
|
|
|
1265
|
+
### findLast()
|
|
1266
|
+
|
|
1267
|
+
```ts
|
|
1268
|
+
findLast(predicate): E | undefined;
|
|
1269
|
+
```
|
|
1270
|
+
|
|
1271
|
+
Defined in: [data-structures/queue/deque.ts:1286](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1286)
|
|
1272
|
+
|
|
1273
|
+
Find the last value matching a predicate (scans back-to-front).
|
|
1274
|
+
|
|
1275
|
+
#### Parameters
|
|
1276
|
+
|
|
1277
|
+
##### predicate
|
|
1278
|
+
|
|
1279
|
+
(`value`, `index`, `deque`) => `boolean`
|
|
1280
|
+
|
|
1281
|
+
Function called with (value, index, deque).
|
|
1282
|
+
|
|
1283
|
+
#### Returns
|
|
1284
|
+
|
|
1285
|
+
`E` \| `undefined`
|
|
1286
|
+
|
|
1287
|
+
Matching value or undefined.
|
|
1288
|
+
*
|
|
1289
|
+
|
|
1290
|
+
#### Remarks
|
|
1291
|
+
|
|
1292
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
1293
|
+
|
|
1294
|
+
#### Example
|
|
1295
|
+
|
|
1296
|
+
```ts
|
|
1297
|
+
// Find last matching value
|
|
1298
|
+
const d = new Deque([1, 2, 3, 4, 5]);
|
|
1299
|
+
console.log(d.findLast(v => v > 2)); // 5;
|
|
1300
|
+
console.log(d.findLast(v => v % 2 === 0)); // 4;
|
|
1301
|
+
```
|
|
1302
|
+
|
|
1303
|
+
***
|
|
1304
|
+
|
|
1305
|
+
### findLastIndex()
|
|
1306
|
+
|
|
1307
|
+
```ts
|
|
1308
|
+
findLastIndex(predicate): number;
|
|
1309
|
+
```
|
|
1310
|
+
|
|
1311
|
+
Defined in: [data-structures/queue/deque.ts:1305](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1305)
|
|
1312
|
+
|
|
1313
|
+
Find the index of the last value matching a predicate (scans back-to-front).
|
|
1314
|
+
|
|
1315
|
+
#### Parameters
|
|
1316
|
+
|
|
1317
|
+
##### predicate
|
|
1318
|
+
|
|
1319
|
+
(`value`, `index`, `deque`) => `boolean`
|
|
1320
|
+
|
|
1321
|
+
Function called with (value, index, deque).
|
|
1322
|
+
|
|
1323
|
+
#### Returns
|
|
1324
|
+
|
|
1325
|
+
`number`
|
|
1326
|
+
|
|
1327
|
+
Matching index, or -1 if not found.
|
|
1328
|
+
*
|
|
1329
|
+
|
|
1330
|
+
#### Remarks
|
|
1331
|
+
|
|
1332
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
1333
|
+
|
|
1334
|
+
#### Example
|
|
1335
|
+
|
|
1336
|
+
```ts
|
|
1337
|
+
// Find last matching index
|
|
1338
|
+
const d = new Deque([10, 20, 30, 20, 10]);
|
|
1339
|
+
console.log(d.findLastIndex(v => v === 20)); // 3;
|
|
1340
|
+
console.log(d.findLastIndex(v => v === 10)); // 4;
|
|
1341
|
+
```
|
|
1342
|
+
|
|
1343
|
+
***
|
|
1344
|
+
|
|
1239
1345
|
### forEach()
|
|
1240
1346
|
|
|
1241
1347
|
```ts
|
|
@@ -1310,6 +1416,40 @@ Time O(n) in the worst case. Space O(1).
|
|
|
1310
1416
|
|
|
1311
1417
|
***
|
|
1312
1418
|
|
|
1419
|
+
### includes()
|
|
1420
|
+
|
|
1421
|
+
```ts
|
|
1422
|
+
includes(element): boolean;
|
|
1423
|
+
```
|
|
1424
|
+
|
|
1425
|
+
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)
|
|
1426
|
+
|
|
1427
|
+
Check whether a value exists (Array-compatible alias for `has`).
|
|
1428
|
+
|
|
1429
|
+
#### Parameters
|
|
1430
|
+
|
|
1431
|
+
##### element
|
|
1432
|
+
|
|
1433
|
+
`E`
|
|
1434
|
+
|
|
1435
|
+
Element to search for (uses `===`).
|
|
1436
|
+
|
|
1437
|
+
#### Returns
|
|
1438
|
+
|
|
1439
|
+
`boolean`
|
|
1440
|
+
|
|
1441
|
+
`true` if found.
|
|
1442
|
+
|
|
1443
|
+
#### Remarks
|
|
1444
|
+
|
|
1445
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
1446
|
+
|
|
1447
|
+
#### Inherited from
|
|
1448
|
+
|
|
1449
|
+
[`LinearBase`](LinearBase.md).[`includes`](LinearBase.md#includes)
|
|
1450
|
+
|
|
1451
|
+
***
|
|
1452
|
+
|
|
1313
1453
|
### indexOf()
|
|
1314
1454
|
|
|
1315
1455
|
```ts
|
|
@@ -1356,7 +1496,7 @@ Time O(n), Space O(1)
|
|
|
1356
1496
|
isEmpty(): boolean;
|
|
1357
1497
|
```
|
|
1358
1498
|
|
|
1359
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
1499
|
+
Defined in: [data-structures/queue/deque.ts:821](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L821)
|
|
1360
1500
|
|
|
1361
1501
|
Check whether the deque is empty.
|
|
1362
1502
|
|
|
@@ -1420,6 +1560,30 @@ Time O(n), Space O(n)
|
|
|
1420
1560
|
|
|
1421
1561
|
***
|
|
1422
1562
|
|
|
1563
|
+
### keys()
|
|
1564
|
+
|
|
1565
|
+
```ts
|
|
1566
|
+
keys(): IterableIterator<number>;
|
|
1567
|
+
```
|
|
1568
|
+
|
|
1569
|
+
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)
|
|
1570
|
+
|
|
1571
|
+
Return an iterator of numeric indices (Array-compatible).
|
|
1572
|
+
|
|
1573
|
+
#### Returns
|
|
1574
|
+
|
|
1575
|
+
`IterableIterator`\<`number`\>
|
|
1576
|
+
|
|
1577
|
+
#### Remarks
|
|
1578
|
+
|
|
1579
|
+
Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
1580
|
+
|
|
1581
|
+
#### Inherited from
|
|
1582
|
+
|
|
1583
|
+
[`LinearBase`](LinearBase.md).[`keys`](LinearBase.md#keys)
|
|
1584
|
+
|
|
1585
|
+
***
|
|
1586
|
+
|
|
1423
1587
|
### lastIndexOf()
|
|
1424
1588
|
|
|
1425
1589
|
```ts
|
|
@@ -1469,7 +1633,7 @@ map<EM, RM>(
|
|
|
1469
1633
|
thisArg?): Deque<EM, RM>;
|
|
1470
1634
|
```
|
|
1471
1635
|
|
|
1472
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
1636
|
+
Defined in: [data-structures/queue/deque.ts:1677](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1677)
|
|
1473
1637
|
|
|
1474
1638
|
Map elements into a new deque (possibly different element type).
|
|
1475
1639
|
|
|
@@ -1536,7 +1700,7 @@ Time O(N), Space O(N)
|
|
|
1536
1700
|
mapSame(callback, thisArg?): this;
|
|
1537
1701
|
```
|
|
1538
1702
|
|
|
1539
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
1703
|
+
Defined in: [data-structures/queue/deque.ts:1611](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1611)
|
|
1540
1704
|
|
|
1541
1705
|
Map elements into a new deque of the same element type.
|
|
1542
1706
|
|
|
@@ -1598,7 +1762,7 @@ Time O(1), Space O(1)
|
|
|
1598
1762
|
pop(): E | undefined;
|
|
1599
1763
|
```
|
|
1600
1764
|
|
|
1601
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
1765
|
+
Defined in: [data-structures/queue/deque.ts:559](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L559)
|
|
1602
1766
|
|
|
1603
1767
|
Remove and return the last element.
|
|
1604
1768
|
|
|
@@ -1631,7 +1795,7 @@ Time O(1), Space O(1)
|
|
|
1631
1795
|
print(): void;
|
|
1632
1796
|
```
|
|
1633
1797
|
|
|
1634
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1798
|
+
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)
|
|
1635
1799
|
|
|
1636
1800
|
Prints `toVisual()` to the console. Intended for quick debugging.
|
|
1637
1801
|
|
|
@@ -1657,7 +1821,7 @@ Time O(n) due to materialization, Space O(n) for the intermediate representation
|
|
|
1657
1821
|
push(element): boolean;
|
|
1658
1822
|
```
|
|
1659
1823
|
|
|
1660
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
1824
|
+
Defined in: [data-structures/queue/deque.ts:487](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L487)
|
|
1661
1825
|
|
|
1662
1826
|
Append one element at the back.
|
|
1663
1827
|
|
|
@@ -1715,7 +1879,7 @@ Time O(1) amortized, Space O(1)
|
|
|
1715
1879
|
pushMany(elements): boolean[];
|
|
1716
1880
|
```
|
|
1717
1881
|
|
|
1718
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
1882
|
+
Defined in: [data-structures/queue/deque.ts:740](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L740)
|
|
1719
1883
|
|
|
1720
1884
|
Append a sequence of elements.
|
|
1721
1885
|
|
|
@@ -1781,7 +1945,7 @@ Time O(n), Space O(1). Throws if called on an empty structure without `initialVa
|
|
|
1781
1945
|
reduce(callbackfn): E;
|
|
1782
1946
|
```
|
|
1783
1947
|
|
|
1784
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1948
|
+
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)
|
|
1785
1949
|
|
|
1786
1950
|
##### Parameters
|
|
1787
1951
|
|
|
@@ -1803,7 +1967,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:194](https://github.c
|
|
|
1803
1967
|
reduce(callbackfn, initialValue): E;
|
|
1804
1968
|
```
|
|
1805
1969
|
|
|
1806
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1970
|
+
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)
|
|
1807
1971
|
|
|
1808
1972
|
##### Parameters
|
|
1809
1973
|
|
|
@@ -1829,7 +1993,7 @@ Defined in: [data-structures/base/iterable-element-base.ts:195](https://github.c
|
|
|
1829
1993
|
reduce<U>(callbackfn, initialValue): U;
|
|
1830
1994
|
```
|
|
1831
1995
|
|
|
1832
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
1996
|
+
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)
|
|
1833
1997
|
|
|
1834
1998
|
##### Type Parameters
|
|
1835
1999
|
|
|
@@ -1909,21 +2073,15 @@ Time O(n), Space O(1)
|
|
|
1909
2073
|
reverse(): this;
|
|
1910
2074
|
```
|
|
1911
2075
|
|
|
1912
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2076
|
+
Defined in: [data-structures/queue/deque.ts:1335](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1335)
|
|
1913
2077
|
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
#### Returns
|
|
1917
|
-
|
|
1918
|
-
`this`
|
|
1919
|
-
|
|
1920
|
-
This deque.
|
|
2078
|
+
Deque for...of iteration and reverse
|
|
1921
2079
|
|
|
1922
2080
|
*
|
|
1923
2081
|
|
|
1924
|
-
####
|
|
2082
|
+
#### Returns
|
|
1925
2083
|
|
|
1926
|
-
|
|
2084
|
+
`this`
|
|
1927
2085
|
|
|
1928
2086
|
#### Example
|
|
1929
2087
|
|
|
@@ -1959,7 +2117,7 @@ Time O(N), Space O(N)
|
|
|
1959
2117
|
setAt(pos, element): boolean;
|
|
1960
2118
|
```
|
|
1961
2119
|
|
|
1962
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2120
|
+
Defined in: [data-structures/queue/deque.ts:948](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L948)
|
|
1963
2121
|
|
|
1964
2122
|
Replace the element at a given position.
|
|
1965
2123
|
|
|
@@ -1999,7 +2157,7 @@ Time O(1), Space O(1)
|
|
|
1999
2157
|
setEquality(equals): this;
|
|
2000
2158
|
```
|
|
2001
2159
|
|
|
2002
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2160
|
+
Defined in: [data-structures/queue/deque.ts:1207](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1207)
|
|
2003
2161
|
|
|
2004
2162
|
Set the equality comparator used by delete operations.
|
|
2005
2163
|
|
|
@@ -2029,7 +2187,7 @@ Time O(1), Space O(1)
|
|
|
2029
2187
|
shift(): E | undefined;
|
|
2030
2188
|
```
|
|
2031
2189
|
|
|
2032
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2190
|
+
Defined in: [data-structures/queue/deque.ts:631](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L631)
|
|
2033
2191
|
|
|
2034
2192
|
Remove and return the first element.
|
|
2035
2193
|
|
|
@@ -2179,7 +2337,7 @@ splice(
|
|
|
2179
2337
|
items?): this;
|
|
2180
2338
|
```
|
|
2181
2339
|
|
|
2182
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2340
|
+
Defined in: [data-structures/queue/deque.ts:1024](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1024)
|
|
2183
2341
|
|
|
2184
2342
|
Remove and/or insert elements at a position (array-like behavior).
|
|
2185
2343
|
|
|
@@ -2225,7 +2383,7 @@ Time O(N + M), Space O(M)
|
|
|
2225
2383
|
toArray(): E[];
|
|
2226
2384
|
```
|
|
2227
2385
|
|
|
2228
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
2386
|
+
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)
|
|
2229
2387
|
|
|
2230
2388
|
Materializes the elements into a new array.
|
|
2231
2389
|
|
|
@@ -2245,6 +2403,32 @@ Time O(n), Space O(n).
|
|
|
2245
2403
|
|
|
2246
2404
|
***
|
|
2247
2405
|
|
|
2406
|
+
### toReversed()
|
|
2407
|
+
|
|
2408
|
+
```ts
|
|
2409
|
+
toReversed(): this;
|
|
2410
|
+
```
|
|
2411
|
+
|
|
2412
|
+
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)
|
|
2413
|
+
|
|
2414
|
+
Return a new instance of the same type with elements in reverse order (non-mutating).
|
|
2415
|
+
|
|
2416
|
+
#### Returns
|
|
2417
|
+
|
|
2418
|
+
`this`
|
|
2419
|
+
|
|
2420
|
+
A new reversed instance.
|
|
2421
|
+
|
|
2422
|
+
#### Remarks
|
|
2423
|
+
|
|
2424
|
+
Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
|
|
2425
|
+
|
|
2426
|
+
#### Inherited from
|
|
2427
|
+
|
|
2428
|
+
[`LinearBase`](LinearBase.md).[`toReversed`](LinearBase.md#toreversed)
|
|
2429
|
+
|
|
2430
|
+
***
|
|
2431
|
+
|
|
2248
2432
|
### toReversedArray()
|
|
2249
2433
|
|
|
2250
2434
|
```ts
|
|
@@ -2277,7 +2461,7 @@ Time O(n), Space O(n)
|
|
|
2277
2461
|
toVisual(): E[];
|
|
2278
2462
|
```
|
|
2279
2463
|
|
|
2280
|
-
Defined in: [data-structures/base/iterable-element-base.ts:
|
|
2464
|
+
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)
|
|
2281
2465
|
|
|
2282
2466
|
Returns a representation of the structure suitable for quick visualization.
|
|
2283
2467
|
Defaults to an array of elements; subclasses may override to provide richer visuals.
|
|
@@ -2304,7 +2488,7 @@ Time O(n), Space O(n).
|
|
|
2304
2488
|
unique(): this;
|
|
2305
2489
|
```
|
|
2306
2490
|
|
|
2307
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2491
|
+
Defined in: [data-structures/queue/deque.ts:1353](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1353)
|
|
2308
2492
|
|
|
2309
2493
|
Deduplicate consecutive equal elements in-place.
|
|
2310
2494
|
|
|
@@ -2326,7 +2510,7 @@ Time O(N), Space O(1)
|
|
|
2326
2510
|
unshift(element): boolean;
|
|
2327
2511
|
```
|
|
2328
2512
|
|
|
2329
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2513
|
+
Defined in: [data-structures/queue/deque.ts:714](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L714)
|
|
2330
2514
|
|
|
2331
2515
|
Prepend one element at the front.
|
|
2332
2516
|
|
|
@@ -2377,7 +2561,7 @@ Time O(1) amortized, Space O(1)
|
|
|
2377
2561
|
unshiftMany(elements?): boolean[];
|
|
2378
2562
|
```
|
|
2379
2563
|
|
|
2380
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2564
|
+
Defined in: [data-structures/queue/deque.ts:759](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L759)
|
|
2381
2565
|
|
|
2382
2566
|
Prepend a sequence of elements.
|
|
2383
2567
|
|
|
@@ -2436,7 +2620,7 @@ static fromArray<E, R>(
|
|
|
2436
2620
|
options?): any;
|
|
2437
2621
|
```
|
|
2438
2622
|
|
|
2439
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2623
|
+
Defined in: [data-structures/queue/deque.ts:409](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L409)
|
|
2440
2624
|
|
|
2441
2625
|
Create a Deque from an array of elements.
|
|
2442
2626
|
|
|
@@ -2534,7 +2718,7 @@ Time O(1), Space O(1).
|
|
|
2534
2718
|
protected _autoCompact(): void;
|
|
2535
2719
|
```
|
|
2536
2720
|
|
|
2537
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2721
|
+
Defined in: [data-structures/queue/deque.ts:1381](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1381)
|
|
2538
2722
|
|
|
2539
2723
|
(Protected) Trigger auto-compaction if space utilization drops below threshold.
|
|
2540
2724
|
Only checks every `_bucketSize` operations to minimize hot-path overhead.
|
|
@@ -2552,7 +2736,7 @@ Uses element-based ratio: `elements / (bucketCount * bucketSize)`.
|
|
|
2552
2736
|
protected _createInstance(options?): this;
|
|
2553
2737
|
```
|
|
2554
2738
|
|
|
2555
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2739
|
+
Defined in: [data-structures/queue/deque.ts:1792](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1792)
|
|
2556
2740
|
|
|
2557
2741
|
(Protected) Create an empty instance of the same concrete class.
|
|
2558
2742
|
|
|
@@ -2586,7 +2770,7 @@ Time O(1), Space O(1)
|
|
|
2586
2770
|
protected _createLike<T, RR>(elements?, options?): Deque<T, RR>;
|
|
2587
2771
|
```
|
|
2588
2772
|
|
|
2589
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2773
|
+
Defined in: [data-structures/queue/deque.ts:1810](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1810)
|
|
2590
2774
|
|
|
2591
2775
|
(Protected) Create a like-kind deque seeded by elements.
|
|
2592
2776
|
|
|
@@ -2632,7 +2816,7 @@ Time O(N), Space O(N)
|
|
|
2632
2816
|
protected _getBucketAndPosition(pos): object;
|
|
2633
2817
|
```
|
|
2634
2818
|
|
|
2635
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2819
|
+
Defined in: [data-structures/queue/deque.ts:1766](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1766)
|
|
2636
2820
|
|
|
2637
2821
|
(Protected) Translate a logical position to bucket/offset.
|
|
2638
2822
|
|
|
@@ -2674,7 +2858,7 @@ Time O(1), Space O(1)
|
|
|
2674
2858
|
protected _getIterator(): IterableIterator<E>;
|
|
2675
2859
|
```
|
|
2676
2860
|
|
|
2677
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2861
|
+
Defined in: [data-structures/queue/deque.ts:1723](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1723)
|
|
2678
2862
|
|
|
2679
2863
|
(Protected) Iterate elements from front to back.
|
|
2680
2864
|
|
|
@@ -2700,7 +2884,7 @@ Time O(N), Space O(1)
|
|
|
2700
2884
|
protected _getReverseIterator(): IterableIterator<E>;
|
|
2701
2885
|
```
|
|
2702
2886
|
|
|
2703
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2887
|
+
Defined in: [data-structures/queue/deque.ts:1827](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1827)
|
|
2704
2888
|
|
|
2705
2889
|
(Protected) Iterate elements from back to front.
|
|
2706
2890
|
|
|
@@ -2726,7 +2910,7 @@ Time O(N), Space O(1)
|
|
|
2726
2910
|
protected _reallocate(needBucketNum?): void;
|
|
2727
2911
|
```
|
|
2728
2912
|
|
|
2729
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2913
|
+
Defined in: [data-structures/queue/deque.ts:1737](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1737)
|
|
2730
2914
|
|
|
2731
2915
|
(Protected) Reallocate buckets to make room near the ends.
|
|
2732
2916
|
|
|
@@ -2756,7 +2940,7 @@ Time O(N), Space O(N)
|
|
|
2756
2940
|
protected _setBucketSize(size): void;
|
|
2757
2941
|
```
|
|
2758
2942
|
|
|
2759
|
-
Defined in: [data-structures/queue/deque.ts:
|
|
2943
|
+
Defined in: [data-structures/queue/deque.ts:1703](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/queue/deque.ts#L1703)
|
|
2760
2944
|
|
|
2761
2945
|
(Protected) Set the internal bucket size.
|
|
2762
2946
|
|