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.
Files changed (158) hide show
  1. package/.github/workflows/ci.yml +7 -2
  2. package/.github/workflows/release-package.yml +9 -2
  3. package/.husky/pre-commit +3 -0
  4. package/CHANGELOG.md +1 -1
  5. package/MIGRATION.md +48 -0
  6. package/README.md +20 -2
  7. package/README_CN.md +20 -2
  8. package/SPECIFICATION.md +24 -0
  9. package/SPECIFICATION.zh-CN.md +24 -0
  10. package/dist/cjs/binary-tree.cjs +1897 -19
  11. package/dist/cjs/graph.cjs +174 -0
  12. package/dist/cjs/hash.cjs +33 -0
  13. package/dist/cjs/heap.cjs +71 -0
  14. package/dist/cjs/index.cjs +2383 -3
  15. package/dist/cjs/linked-list.cjs +224 -2
  16. package/dist/cjs/matrix.cjs +24 -0
  17. package/dist/cjs/priority-queue.cjs +71 -0
  18. package/dist/cjs/queue.cjs +221 -1
  19. package/dist/cjs/stack.cjs +59 -0
  20. package/dist/cjs/trie.cjs +62 -0
  21. package/dist/cjs-legacy/binary-tree.cjs +1897 -19
  22. package/dist/cjs-legacy/graph.cjs +174 -0
  23. package/dist/cjs-legacy/hash.cjs +33 -0
  24. package/dist/cjs-legacy/heap.cjs +71 -0
  25. package/dist/cjs-legacy/index.cjs +2383 -3
  26. package/dist/cjs-legacy/linked-list.cjs +224 -2
  27. package/dist/cjs-legacy/matrix.cjs +24 -0
  28. package/dist/cjs-legacy/priority-queue.cjs +71 -0
  29. package/dist/cjs-legacy/queue.cjs +221 -1
  30. package/dist/cjs-legacy/stack.cjs +59 -0
  31. package/dist/cjs-legacy/trie.cjs +62 -0
  32. package/dist/esm/binary-tree.mjs +1897 -19
  33. package/dist/esm/graph.mjs +174 -0
  34. package/dist/esm/hash.mjs +33 -0
  35. package/dist/esm/heap.mjs +71 -0
  36. package/dist/esm/index.mjs +2383 -3
  37. package/dist/esm/linked-list.mjs +224 -2
  38. package/dist/esm/matrix.mjs +24 -0
  39. package/dist/esm/priority-queue.mjs +71 -0
  40. package/dist/esm/queue.mjs +221 -1
  41. package/dist/esm/stack.mjs +59 -0
  42. package/dist/esm/trie.mjs +62 -0
  43. package/dist/esm-legacy/binary-tree.mjs +1897 -19
  44. package/dist/esm-legacy/graph.mjs +174 -0
  45. package/dist/esm-legacy/hash.mjs +33 -0
  46. package/dist/esm-legacy/heap.mjs +71 -0
  47. package/dist/esm-legacy/index.mjs +2383 -3
  48. package/dist/esm-legacy/linked-list.mjs +224 -2
  49. package/dist/esm-legacy/matrix.mjs +24 -0
  50. package/dist/esm-legacy/priority-queue.mjs +71 -0
  51. package/dist/esm-legacy/queue.mjs +221 -1
  52. package/dist/esm-legacy/stack.mjs +59 -0
  53. package/dist/esm-legacy/trie.mjs +62 -0
  54. package/dist/types/data-structures/base/iterable-element-base.d.ts +17 -0
  55. package/dist/types/data-structures/base/linear-base.d.ts +6 -0
  56. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +36 -0
  57. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +42 -0
  58. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +75 -0
  59. package/dist/types/data-structures/binary-tree/bst.d.ts +72 -0
  60. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +57 -0
  61. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +18 -0
  62. package/dist/types/data-structures/binary-tree/tree-map.d.ts +375 -0
  63. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +389 -0
  64. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +330 -0
  65. package/dist/types/data-structures/binary-tree/tree-set.d.ts +438 -0
  66. package/dist/types/data-structures/graph/directed-graph.d.ts +30 -0
  67. package/dist/types/data-structures/graph/undirected-graph.d.ts +27 -0
  68. package/dist/types/data-structures/hash/hash-map.d.ts +33 -0
  69. package/dist/types/data-structures/heap/heap.d.ts +42 -0
  70. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +75 -2
  71. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +45 -0
  72. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +54 -0
  73. package/dist/types/data-structures/matrix/matrix.d.ts +24 -0
  74. package/dist/types/data-structures/queue/deque.d.ts +90 -1
  75. package/dist/types/data-structures/queue/queue.d.ts +36 -0
  76. package/dist/types/data-structures/stack/stack.d.ts +30 -0
  77. package/dist/types/data-structures/trie/trie.d.ts +36 -0
  78. package/dist/umd/data-structure-typed.js +2383 -3
  79. package/dist/umd/data-structure-typed.min.js +3 -3
  80. package/docs-site-docusaurus/docs/api/classes/AVLTree.md +108 -108
  81. package/docs-site-docusaurus/docs/api/classes/BST.md +101 -101
  82. package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +13 -13
  83. package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +66 -66
  84. package/docs-site-docusaurus/docs/api/classes/Deque.md +235 -51
  85. package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +21 -21
  86. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +231 -67
  87. package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +9 -9
  88. package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
  89. package/docs-site-docusaurus/docs/api/classes/HashMap.md +14 -14
  90. package/docs-site-docusaurus/docs/api/classes/Heap.md +117 -34
  91. package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +83 -13
  92. package/docs-site-docusaurus/docs/api/classes/LinearBase.md +124 -20
  93. package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +140 -32
  94. package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +30 -26
  95. package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +159 -51
  96. package/docs-site-docusaurus/docs/api/classes/MapGraph.md +20 -20
  97. package/docs-site-docusaurus/docs/api/classes/Matrix.md +23 -23
  98. package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +117 -34
  99. package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +117 -34
  100. package/docs-site-docusaurus/docs/api/classes/MinHeap.md +117 -34
  101. package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +117 -34
  102. package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +117 -34
  103. package/docs-site-docusaurus/docs/api/classes/Queue.md +142 -34
  104. package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +117 -117
  105. package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +8 -8
  106. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +158 -50
  107. package/docs-site-docusaurus/docs/api/classes/SkipList.md +21 -21
  108. package/docs-site-docusaurus/docs/api/classes/Stack.md +108 -26
  109. package/docs-site-docusaurus/docs/api/classes/TreeMap.md +33 -33
  110. package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +75 -39
  111. package/docs-site-docusaurus/docs/api/classes/TreeSet.md +301 -39
  112. package/docs-site-docusaurus/docs/api/classes/Trie.md +110 -28
  113. package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +20 -20
  114. package/jest.integration.config.js +1 -2
  115. package/package.json +51 -50
  116. package/src/common/error.ts +15 -32
  117. package/src/common/index.ts +0 -3
  118. package/src/data-structures/base/iterable-element-base.ts +32 -3
  119. package/src/data-structures/base/linear-base.ts +13 -36
  120. package/src/data-structures/binary-tree/avl-tree.ts +31 -493
  121. package/src/data-structures/binary-tree/binary-indexed-tree.ts +47 -530
  122. package/src/data-structures/binary-tree/binary-tree.ts +326 -1236
  123. package/src/data-structures/binary-tree/bst.ts +158 -1010
  124. package/src/data-structures/binary-tree/red-black-tree.ts +451 -1233
  125. package/src/data-structures/binary-tree/segment-tree.ts +73 -333
  126. package/src/data-structures/binary-tree/tree-map.ts +462 -4749
  127. package/src/data-structures/binary-tree/tree-multi-map.ts +310 -4530
  128. package/src/data-structures/binary-tree/tree-multi-set.ts +300 -3652
  129. package/src/data-structures/binary-tree/tree-set.ts +437 -4443
  130. package/src/data-structures/graph/abstract-graph.ts +98 -167
  131. package/src/data-structures/graph/directed-graph.ts +137 -532
  132. package/src/data-structures/graph/map-graph.ts +0 -3
  133. package/src/data-structures/graph/undirected-graph.ts +132 -484
  134. package/src/data-structures/hash/hash-map.ts +154 -549
  135. package/src/data-structures/heap/heap.ts +200 -753
  136. package/src/data-structures/linked-list/doubly-linked-list.ts +153 -809
  137. package/src/data-structures/linked-list/singly-linked-list.ts +122 -749
  138. package/src/data-structures/linked-list/skip-linked-list.ts +211 -864
  139. package/src/data-structures/matrix/matrix.ts +179 -494
  140. package/src/data-structures/matrix/navigator.ts +0 -1
  141. package/src/data-structures/priority-queue/max-priority-queue.ts +1 -6
  142. package/src/data-structures/priority-queue/min-priority-queue.ts +6 -11
  143. package/src/data-structures/priority-queue/priority-queue.ts +1 -2
  144. package/src/data-structures/queue/deque.ts +241 -807
  145. package/src/data-structures/queue/queue.ts +102 -589
  146. package/src/data-structures/stack/stack.ts +76 -475
  147. package/src/data-structures/trie/trie.ts +98 -592
  148. package/src/types/common.ts +0 -10
  149. package/src/types/data-structures/binary-tree/bst.ts +0 -7
  150. package/src/types/data-structures/binary-tree/red-black-tree.ts +0 -1
  151. package/src/types/data-structures/graph/abstract-graph.ts +0 -2
  152. package/src/types/data-structures/hash/hash-map.ts +0 -3
  153. package/src/types/data-structures/hash/index.ts +0 -1
  154. package/src/types/data-structures/matrix/navigator.ts +0 -2
  155. package/src/types/utils/utils.ts +0 -7
  156. package/src/types/utils/validate-type.ts +0 -7
  157. package/src/utils/number.ts +0 -2
  158. package/src/utils/utils.ts +0 -5
@@ -186,6 +186,35 @@ var IterableElementBase = class {
186
186
  for (const ele of this) if (ele === element) return true;
187
187
  return false;
188
188
  }
189
+ /**
190
+ * Check whether a value exists (Array-compatible alias for `has`).
191
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
192
+ * @param element - Element to search for (uses `===`).
193
+ * @returns `true` if found.
194
+ */
195
+ includes(element) {
196
+ return this.has(element);
197
+ }
198
+ /**
199
+ * Return an iterator of `[index, value]` pairs (Array-compatible).
200
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
201
+ */
202
+ *entries() {
203
+ let index = 0;
204
+ for (const value of this) {
205
+ yield [index++, value];
206
+ }
207
+ }
208
+ /**
209
+ * Return an iterator of numeric indices (Array-compatible).
210
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
211
+ */
212
+ *keys() {
213
+ let index = 0;
214
+ for (const _ of this) {
215
+ yield index++;
216
+ }
217
+ }
189
218
  /**
190
219
  * Reduces all elements to a single accumulated value.
191
220
  *
@@ -326,6 +355,9 @@ var Heap = class _Heap extends IterableElementBase {
326
355
 
327
356
 
328
357
 
358
+
359
+
360
+
329
361
 
330
362
 
331
363
 
@@ -416,6 +448,9 @@ var Heap = class _Heap extends IterableElementBase {
416
448
 
417
449
 
418
450
 
451
+
452
+
453
+
419
454
 
420
455
 
421
456
 
@@ -477,6 +512,9 @@ var Heap = class _Heap extends IterableElementBase {
477
512
 
478
513
 
479
514
 
515
+
516
+
517
+
480
518
 
481
519
 
482
520
 
@@ -571,6 +609,9 @@ var Heap = class _Heap extends IterableElementBase {
571
609
  */
572
610
  /**
573
611
  * @deprecated Use `pop` instead. Will be removed in a future major version.
612
+
613
+
614
+
574
615
  * @example
575
616
  * // Heap with custom comparator (MaxHeap behavior)
576
617
  * interface Task {
@@ -654,6 +695,9 @@ var Heap = class _Heap extends IterableElementBase {
654
695
 
655
696
 
656
697
 
698
+
699
+
700
+
657
701
 
658
702
 
659
703
 
@@ -758,6 +802,9 @@ var Heap = class _Heap extends IterableElementBase {
758
802
 
759
803
 
760
804
 
805
+
806
+
807
+
761
808
 
762
809
 
763
810
 
@@ -809,6 +856,9 @@ var Heap = class _Heap extends IterableElementBase {
809
856
 
810
857
 
811
858
 
859
+
860
+
861
+
812
862
 
813
863
 
814
864
 
@@ -853,6 +903,9 @@ var Heap = class _Heap extends IterableElementBase {
853
903
 
854
904
 
855
905
 
906
+
907
+
908
+
856
909
 
857
910
 
858
911
 
@@ -904,6 +957,9 @@ var Heap = class _Heap extends IterableElementBase {
904
957
 
905
958
 
906
959
 
960
+
961
+
962
+
907
963
 
908
964
 
909
965
 
@@ -1007,6 +1063,9 @@ var Heap = class _Heap extends IterableElementBase {
1007
1063
 
1008
1064
 
1009
1065
 
1066
+
1067
+
1068
+
1010
1069
 
1011
1070
 
1012
1071
 
@@ -1091,6 +1150,9 @@ var Heap = class _Heap extends IterableElementBase {
1091
1150
 
1092
1151
 
1093
1152
 
1153
+
1154
+
1155
+
1094
1156
 
1095
1157
 
1096
1158
 
@@ -1148,6 +1210,9 @@ var Heap = class _Heap extends IterableElementBase {
1148
1210
 
1149
1211
 
1150
1212
 
1213
+
1214
+
1215
+
1151
1216
 
1152
1217
 
1153
1218
 
@@ -1204,6 +1269,9 @@ var Heap = class _Heap extends IterableElementBase {
1204
1269
 
1205
1270
 
1206
1271
 
1272
+
1273
+
1274
+
1207
1275
 
1208
1276
 
1209
1277
 
@@ -1267,6 +1335,9 @@ var Heap = class _Heap extends IterableElementBase {
1267
1335
 
1268
1336
 
1269
1337
 
1338
+
1339
+
1340
+
1270
1341
 
1271
1342
 
1272
1343
 
@@ -161,6 +161,35 @@ var IterableElementBase = class {
161
161
  for (const ele of this) if (ele === element) return true;
162
162
  return false;
163
163
  }
164
+ /**
165
+ * Check whether a value exists (Array-compatible alias for `has`).
166
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
167
+ * @param element - Element to search for (uses `===`).
168
+ * @returns `true` if found.
169
+ */
170
+ includes(element) {
171
+ return this.has(element);
172
+ }
173
+ /**
174
+ * Return an iterator of `[index, value]` pairs (Array-compatible).
175
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
176
+ */
177
+ *entries() {
178
+ let index = 0;
179
+ for (const value of this) {
180
+ yield [index++, value];
181
+ }
182
+ }
183
+ /**
184
+ * Return an iterator of numeric indices (Array-compatible).
185
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
186
+ */
187
+ *keys() {
188
+ let index = 0;
189
+ for (const _ of this) {
190
+ yield index++;
191
+ }
192
+ }
164
193
  /**
165
194
  * Reduces all elements to a single accumulated value.
166
195
  *
@@ -471,6 +500,16 @@ var LinearBase = class _LinearBase extends IterableElementBase {
471
500
  }
472
501
  return this;
473
502
  }
503
+ /**
504
+ * Return a new instance of the same type with elements in reverse order (non-mutating).
505
+ * @remarks Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
506
+ * @returns A new reversed instance.
507
+ */
508
+ toReversed() {
509
+ const cloned = this.clone();
510
+ cloned.reverse();
511
+ return cloned;
512
+ }
474
513
  };
475
514
  var LinearLinkedBase = class extends LinearBase {
476
515
  static {
@@ -770,6 +809,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
770
809
 
771
810
 
772
811
 
812
+
813
+
814
+
773
815
 
774
816
 
775
817
 
@@ -841,6 +883,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
841
883
 
842
884
 
843
885
 
886
+
887
+
888
+
844
889
 
845
890
 
846
891
 
@@ -917,6 +962,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
917
962
 
918
963
 
919
964
 
965
+
966
+
967
+
920
968
 
921
969
 
922
970
 
@@ -975,6 +1023,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
975
1023
 
976
1024
 
977
1025
 
1026
+
1027
+
1028
+
978
1029
 
979
1030
 
980
1031
 
@@ -1094,6 +1145,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1094
1145
 
1095
1146
 
1096
1147
 
1148
+
1149
+
1150
+
1097
1151
 
1098
1152
 
1099
1153
 
@@ -1157,6 +1211,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1157
1211
 
1158
1212
 
1159
1213
 
1214
+
1215
+
1216
+
1160
1217
 
1161
1218
 
1162
1219
 
@@ -1209,6 +1266,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1209
1266
 
1210
1267
 
1211
1268
 
1269
+
1270
+
1271
+
1212
1272
 
1213
1273
 
1214
1274
 
@@ -1267,6 +1327,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1267
1327
 
1268
1328
 
1269
1329
 
1330
+
1331
+
1332
+
1270
1333
 
1271
1334
 
1272
1335
 
@@ -1330,6 +1393,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1330
1393
 
1331
1394
 
1332
1395
 
1396
+
1397
+
1398
+
1333
1399
 
1334
1400
 
1335
1401
 
@@ -1401,6 +1467,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1401
1467
 
1402
1468
 
1403
1469
 
1470
+
1471
+
1472
+
1404
1473
 
1405
1474
 
1406
1475
 
@@ -1449,6 +1518,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1449
1518
 
1450
1519
 
1451
1520
 
1521
+
1522
+
1523
+
1452
1524
 
1453
1525
 
1454
1526
 
@@ -1503,6 +1575,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1503
1575
 
1504
1576
 
1505
1577
 
1578
+
1579
+
1580
+
1506
1581
 
1507
1582
 
1508
1583
 
@@ -1723,6 +1798,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1723
1798
 
1724
1799
 
1725
1800
 
1801
+
1802
+
1803
+
1726
1804
 
1727
1805
 
1728
1806
 
@@ -1781,6 +1859,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1781
1859
 
1782
1860
 
1783
1861
 
1862
+
1863
+
1864
+
1784
1865
 
1785
1866
 
1786
1867
 
@@ -1867,6 +1948,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1867
1948
 
1868
1949
 
1869
1950
 
1951
+
1952
+
1953
+
1870
1954
 
1871
1955
 
1872
1956
 
@@ -2106,6 +2190,9 @@ var Queue = class _Queue extends LinearBase {
2106
2190
 
2107
2191
 
2108
2192
 
2193
+
2194
+
2195
+
2109
2196
 
2110
2197
 
2111
2198
 
@@ -2160,6 +2247,9 @@ var Queue = class _Queue extends LinearBase {
2160
2247
 
2161
2248
 
2162
2249
 
2250
+
2251
+
2252
+
2163
2253
 
2164
2254
 
2165
2255
 
@@ -2238,6 +2328,9 @@ var Queue = class _Queue extends LinearBase {
2238
2328
 
2239
2329
 
2240
2330
 
2331
+
2332
+
2333
+
2241
2334
 
2242
2335
 
2243
2336
 
@@ -2304,6 +2397,9 @@ var Queue = class _Queue extends LinearBase {
2304
2397
 
2305
2398
 
2306
2399
 
2400
+
2401
+
2402
+
2307
2403
 
2308
2404
 
2309
2405
 
@@ -2377,6 +2473,9 @@ var Queue = class _Queue extends LinearBase {
2377
2473
 
2378
2474
 
2379
2475
 
2476
+
2477
+
2478
+
2380
2479
 
2381
2480
 
2382
2481
 
@@ -2440,6 +2539,9 @@ var Queue = class _Queue extends LinearBase {
2440
2539
 
2441
2540
 
2442
2541
 
2542
+
2543
+
2544
+
2443
2545
 
2444
2546
 
2445
2547
 
@@ -2496,6 +2598,9 @@ var Queue = class _Queue extends LinearBase {
2496
2598
 
2497
2599
 
2498
2600
 
2601
+
2602
+
2603
+
2499
2604
 
2500
2605
 
2501
2606
 
@@ -2608,6 +2713,9 @@ var Queue = class _Queue extends LinearBase {
2608
2713
 
2609
2714
 
2610
2715
 
2716
+
2717
+
2718
+
2611
2719
 
2612
2720
 
2613
2721
 
@@ -2658,6 +2766,9 @@ var Queue = class _Queue extends LinearBase {
2658
2766
 
2659
2767
 
2660
2768
 
2769
+
2770
+
2771
+
2661
2772
 
2662
2773
 
2663
2774
 
@@ -2731,6 +2842,9 @@ var Queue = class _Queue extends LinearBase {
2731
2842
 
2732
2843
 
2733
2844
 
2845
+
2846
+
2847
+
2734
2848
 
2735
2849
 
2736
2850
 
@@ -2788,6 +2902,9 @@ var Queue = class _Queue extends LinearBase {
2788
2902
 
2789
2903
 
2790
2904
 
2905
+
2906
+
2907
+
2791
2908
 
2792
2909
 
2793
2910
 
@@ -2849,6 +2966,9 @@ var Queue = class _Queue extends LinearBase {
2849
2966
 
2850
2967
 
2851
2968
 
2969
+
2970
+
2971
+
2852
2972
 
2853
2973
 
2854
2974
 
@@ -3159,7 +3279,10 @@ var Deque = class extends LinearBase {
3159
3279
  }
3160
3280
  /**
3161
3281
  * Deque peek at both ends
3162
- * @example
3282
+
3283
+
3284
+
3285
+ * @example
3163
3286
  * // Deque peek at both ends
3164
3287
  * const deque = new Deque<number>([10, 20, 30, 40, 50]);
3165
3288
  *
@@ -3217,6 +3340,9 @@ var Deque = class extends LinearBase {
3217
3340
 
3218
3341
 
3219
3342
 
3343
+
3344
+
3345
+
3220
3346
 
3221
3347
 
3222
3348
 
@@ -3284,6 +3410,9 @@ var Deque = class extends LinearBase {
3284
3410
 
3285
3411
 
3286
3412
 
3413
+
3414
+
3415
+
3287
3416
 
3288
3417
 
3289
3418
 
@@ -3364,6 +3493,9 @@ var Deque = class extends LinearBase {
3364
3493
 
3365
3494
 
3366
3495
 
3496
+
3497
+
3498
+
3367
3499
 
3368
3500
 
3369
3501
 
@@ -3431,6 +3563,9 @@ var Deque = class extends LinearBase {
3431
3563
 
3432
3564
 
3433
3565
 
3566
+
3567
+
3568
+
3434
3569
 
3435
3570
 
3436
3571
 
@@ -3499,6 +3634,9 @@ var Deque = class extends LinearBase {
3499
3634
 
3500
3635
 
3501
3636
 
3637
+
3638
+
3639
+
3502
3640
 
3503
3641
 
3504
3642
 
@@ -3608,6 +3746,9 @@ var Deque = class extends LinearBase {
3608
3746
 
3609
3747
 
3610
3748
 
3749
+
3750
+
3751
+
3611
3752
 
3612
3753
 
3613
3754
 
@@ -3657,6 +3798,9 @@ var Deque = class extends LinearBase {
3657
3798
 
3658
3799
 
3659
3800
 
3801
+
3802
+
3803
+
3660
3804
 
3661
3805
 
3662
3806
 
@@ -3710,6 +3854,9 @@ var Deque = class extends LinearBase {
3710
3854
 
3711
3855
 
3712
3856
 
3857
+
3858
+
3859
+
3713
3860
 
3714
3861
 
3715
3862
 
@@ -3914,6 +4061,9 @@ var Deque = class extends LinearBase {
3914
4061
 
3915
4062
 
3916
4063
 
4064
+
4065
+
4066
+
3917
4067
 
3918
4068
 
3919
4069
 
@@ -4008,6 +4158,64 @@ var Deque = class extends LinearBase {
4008
4158
 
4009
4159
 
4010
4160
 
4161
+
4162
+ * @example
4163
+ * // Deque for...of iteration and reverse
4164
+ * const deque = new Deque<string>(['A', 'B', 'C', 'D']);
4165
+ *
4166
+ * // Iterate forward
4167
+ * const forward: string[] = [];
4168
+ * for (const item of deque) {
4169
+ * forward.push(item);
4170
+ * }
4171
+ * console.log(forward); // ['A', 'B', 'C', 'D'];
4172
+ *
4173
+ * // Reverse the deque
4174
+ * deque.reverse();
4175
+ * const backward: string[] = [];
4176
+ * for (const item of deque) {
4177
+ * backward.push(item);
4178
+ * }
4179
+ * console.log(backward); // ['D', 'C', 'B', 'A'];
4180
+ */
4181
+ /**
4182
+ * Find the last value matching a predicate (scans back-to-front).
4183
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
4184
+ * @param predicate - Function called with (value, index, deque).
4185
+ * @returns Matching value or undefined.
4186
+ * @example
4187
+ * // Find last matching value
4188
+ * const d = new Deque([1, 2, 3, 4, 5]);
4189
+ * console.log(d.findLast(v => v > 2)); // 5;
4190
+ * console.log(d.findLast(v => v % 2 === 0)); // 4;
4191
+ */
4192
+ findLast(predicate) {
4193
+ for (let i = this.length - 1; i >= 0; i--) {
4194
+ const val = this.at(i);
4195
+ if (predicate(val, i, this)) return val;
4196
+ }
4197
+ return void 0;
4198
+ }
4199
+ /**
4200
+ * Find the index of the last value matching a predicate (scans back-to-front).
4201
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
4202
+ * @param predicate - Function called with (value, index, deque).
4203
+ * @returns Matching index, or -1 if not found.
4204
+ * @example
4205
+ * // Find last matching index
4206
+ * const d = new Deque([10, 20, 30, 20, 10]);
4207
+ * console.log(d.findLastIndex(v => v === 20)); // 3;
4208
+ * console.log(d.findLastIndex(v => v === 10)); // 4;
4209
+ */
4210
+ findLastIndex(predicate) {
4211
+ for (let i = this.length - 1; i >= 0; i--) {
4212
+ if (predicate(this.at(i), i, this)) return i;
4213
+ }
4214
+ return -1;
4215
+ }
4216
+ /**
4217
+ * Deque for...of iteration and reverse
4218
+
4011
4219
 
4012
4220
  * @example
4013
4221
  * // Deque for...of iteration and reverse
@@ -4121,6 +4329,9 @@ var Deque = class extends LinearBase {
4121
4329
 
4122
4330
 
4123
4331
 
4332
+
4333
+
4334
+
4124
4335
 
4125
4336
 
4126
4337
 
@@ -4196,6 +4407,9 @@ var Deque = class extends LinearBase {
4196
4407
 
4197
4408
 
4198
4409
 
4410
+
4411
+
4412
+
4199
4413
 
4200
4414
 
4201
4415
 
@@ -4254,6 +4468,9 @@ var Deque = class extends LinearBase {
4254
4468
 
4255
4469
 
4256
4470
 
4471
+
4472
+
4473
+
4257
4474
 
4258
4475
 
4259
4476
 
@@ -4332,6 +4549,9 @@ var Deque = class extends LinearBase {
4332
4549
 
4333
4550
 
4334
4551
 
4552
+
4553
+
4554
+
4335
4555
 
4336
4556
 
4337
4557