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
@@ -184,6 +184,35 @@ var IterableElementBase = class {
184
184
  for (const ele of this) if (ele === element) return true;
185
185
  return false;
186
186
  }
187
+ /**
188
+ * Check whether a value exists (Array-compatible alias for `has`).
189
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
190
+ * @param element - Element to search for (uses `===`).
191
+ * @returns `true` if found.
192
+ */
193
+ includes(element) {
194
+ return this.has(element);
195
+ }
196
+ /**
197
+ * Return an iterator of `[index, value]` pairs (Array-compatible).
198
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
199
+ */
200
+ *entries() {
201
+ let index = 0;
202
+ for (const value of this) {
203
+ yield [index++, value];
204
+ }
205
+ }
206
+ /**
207
+ * Return an iterator of numeric indices (Array-compatible).
208
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
209
+ */
210
+ *keys() {
211
+ let index = 0;
212
+ for (const _ of this) {
213
+ yield index++;
214
+ }
215
+ }
187
216
  /**
188
217
  * Reduces all elements to a single accumulated value.
189
218
  *
@@ -324,6 +353,9 @@ var Heap = class _Heap extends IterableElementBase {
324
353
 
325
354
 
326
355
 
356
+
357
+
358
+
327
359
 
328
360
 
329
361
 
@@ -414,6 +446,9 @@ var Heap = class _Heap extends IterableElementBase {
414
446
 
415
447
 
416
448
 
449
+
450
+
451
+
417
452
 
418
453
 
419
454
 
@@ -475,6 +510,9 @@ var Heap = class _Heap extends IterableElementBase {
475
510
 
476
511
 
477
512
 
513
+
514
+
515
+
478
516
 
479
517
 
480
518
 
@@ -569,6 +607,9 @@ var Heap = class _Heap extends IterableElementBase {
569
607
  */
570
608
  /**
571
609
  * @deprecated Use `pop` instead. Will be removed in a future major version.
610
+
611
+
612
+
572
613
  * @example
573
614
  * // Heap with custom comparator (MaxHeap behavior)
574
615
  * interface Task {
@@ -652,6 +693,9 @@ var Heap = class _Heap extends IterableElementBase {
652
693
 
653
694
 
654
695
 
696
+
697
+
698
+
655
699
 
656
700
 
657
701
 
@@ -756,6 +800,9 @@ var Heap = class _Heap extends IterableElementBase {
756
800
 
757
801
 
758
802
 
803
+
804
+
805
+
759
806
 
760
807
 
761
808
 
@@ -807,6 +854,9 @@ var Heap = class _Heap extends IterableElementBase {
807
854
 
808
855
 
809
856
 
857
+
858
+
859
+
810
860
 
811
861
 
812
862
 
@@ -851,6 +901,9 @@ var Heap = class _Heap extends IterableElementBase {
851
901
 
852
902
 
853
903
 
904
+
905
+
906
+
854
907
 
855
908
 
856
909
 
@@ -902,6 +955,9 @@ var Heap = class _Heap extends IterableElementBase {
902
955
 
903
956
 
904
957
 
958
+
959
+
960
+
905
961
 
906
962
 
907
963
 
@@ -1005,6 +1061,9 @@ var Heap = class _Heap extends IterableElementBase {
1005
1061
 
1006
1062
 
1007
1063
 
1064
+
1065
+
1066
+
1008
1067
 
1009
1068
 
1010
1069
 
@@ -1089,6 +1148,9 @@ var Heap = class _Heap extends IterableElementBase {
1089
1148
 
1090
1149
 
1091
1150
 
1151
+
1152
+
1153
+
1092
1154
 
1093
1155
 
1094
1156
 
@@ -1146,6 +1208,9 @@ var Heap = class _Heap extends IterableElementBase {
1146
1208
 
1147
1209
 
1148
1210
 
1211
+
1212
+
1213
+
1149
1214
 
1150
1215
 
1151
1216
 
@@ -1202,6 +1267,9 @@ var Heap = class _Heap extends IterableElementBase {
1202
1267
 
1203
1268
 
1204
1269
 
1270
+
1271
+
1272
+
1205
1273
 
1206
1274
 
1207
1275
 
@@ -1265,6 +1333,9 @@ var Heap = class _Heap extends IterableElementBase {
1265
1333
 
1266
1334
 
1267
1335
 
1336
+
1337
+
1338
+
1268
1339
 
1269
1340
 
1270
1341
 
@@ -159,6 +159,35 @@ var IterableElementBase = class {
159
159
  for (const ele of this) if (ele === element) return true;
160
160
  return false;
161
161
  }
162
+ /**
163
+ * Check whether a value exists (Array-compatible alias for `has`).
164
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
165
+ * @param element - Element to search for (uses `===`).
166
+ * @returns `true` if found.
167
+ */
168
+ includes(element) {
169
+ return this.has(element);
170
+ }
171
+ /**
172
+ * Return an iterator of `[index, value]` pairs (Array-compatible).
173
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
174
+ */
175
+ *entries() {
176
+ let index = 0;
177
+ for (const value of this) {
178
+ yield [index++, value];
179
+ }
180
+ }
181
+ /**
182
+ * Return an iterator of numeric indices (Array-compatible).
183
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
184
+ */
185
+ *keys() {
186
+ let index = 0;
187
+ for (const _ of this) {
188
+ yield index++;
189
+ }
190
+ }
162
191
  /**
163
192
  * Reduces all elements to a single accumulated value.
164
193
  *
@@ -469,6 +498,16 @@ var LinearBase = class _LinearBase extends IterableElementBase {
469
498
  }
470
499
  return this;
471
500
  }
501
+ /**
502
+ * Return a new instance of the same type with elements in reverse order (non-mutating).
503
+ * @remarks Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
504
+ * @returns A new reversed instance.
505
+ */
506
+ toReversed() {
507
+ const cloned = this.clone();
508
+ cloned.reverse();
509
+ return cloned;
510
+ }
472
511
  };
473
512
  var LinearLinkedBase = class extends LinearBase {
474
513
  static {
@@ -768,6 +807,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
768
807
 
769
808
 
770
809
 
810
+
811
+
812
+
771
813
 
772
814
 
773
815
 
@@ -839,6 +881,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
839
881
 
840
882
 
841
883
 
884
+
885
+
886
+
842
887
 
843
888
 
844
889
 
@@ -915,6 +960,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
915
960
 
916
961
 
917
962
 
963
+
964
+
965
+
918
966
 
919
967
 
920
968
 
@@ -973,6 +1021,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
973
1021
 
974
1022
 
975
1023
 
1024
+
1025
+
1026
+
976
1027
 
977
1028
 
978
1029
 
@@ -1092,6 +1143,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1092
1143
 
1093
1144
 
1094
1145
 
1146
+
1147
+
1148
+
1095
1149
 
1096
1150
 
1097
1151
 
@@ -1155,6 +1209,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1155
1209
 
1156
1210
 
1157
1211
 
1212
+
1213
+
1214
+
1158
1215
 
1159
1216
 
1160
1217
 
@@ -1207,6 +1264,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1207
1264
 
1208
1265
 
1209
1266
 
1267
+
1268
+
1269
+
1210
1270
 
1211
1271
 
1212
1272
 
@@ -1265,6 +1325,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1265
1325
 
1266
1326
 
1267
1327
 
1328
+
1329
+
1330
+
1268
1331
 
1269
1332
 
1270
1333
 
@@ -1328,6 +1391,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1328
1391
 
1329
1392
 
1330
1393
 
1394
+
1395
+
1396
+
1331
1397
 
1332
1398
 
1333
1399
 
@@ -1399,6 +1465,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1399
1465
 
1400
1466
 
1401
1467
 
1468
+
1469
+
1470
+
1402
1471
 
1403
1472
 
1404
1473
 
@@ -1447,6 +1516,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1447
1516
 
1448
1517
 
1449
1518
 
1519
+
1520
+
1521
+
1450
1522
 
1451
1523
 
1452
1524
 
@@ -1501,6 +1573,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1501
1573
 
1502
1574
 
1503
1575
 
1576
+
1577
+
1578
+
1504
1579
 
1505
1580
 
1506
1581
 
@@ -1721,6 +1796,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1721
1796
 
1722
1797
 
1723
1798
 
1799
+
1800
+
1801
+
1724
1802
 
1725
1803
 
1726
1804
 
@@ -1779,6 +1857,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1779
1857
 
1780
1858
 
1781
1859
 
1860
+
1861
+
1862
+
1782
1863
 
1783
1864
 
1784
1865
 
@@ -1865,6 +1946,9 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1865
1946
 
1866
1947
 
1867
1948
 
1949
+
1950
+
1951
+
1868
1952
 
1869
1953
 
1870
1954
 
@@ -2104,6 +2188,9 @@ var Queue = class _Queue extends LinearBase {
2104
2188
 
2105
2189
 
2106
2190
 
2191
+
2192
+
2193
+
2107
2194
 
2108
2195
 
2109
2196
 
@@ -2158,6 +2245,9 @@ var Queue = class _Queue extends LinearBase {
2158
2245
 
2159
2246
 
2160
2247
 
2248
+
2249
+
2250
+
2161
2251
 
2162
2252
 
2163
2253
 
@@ -2236,6 +2326,9 @@ var Queue = class _Queue extends LinearBase {
2236
2326
 
2237
2327
 
2238
2328
 
2329
+
2330
+
2331
+
2239
2332
 
2240
2333
 
2241
2334
 
@@ -2302,6 +2395,9 @@ var Queue = class _Queue extends LinearBase {
2302
2395
 
2303
2396
 
2304
2397
 
2398
+
2399
+
2400
+
2305
2401
 
2306
2402
 
2307
2403
 
@@ -2375,6 +2471,9 @@ var Queue = class _Queue extends LinearBase {
2375
2471
 
2376
2472
 
2377
2473
 
2474
+
2475
+
2476
+
2378
2477
 
2379
2478
 
2380
2479
 
@@ -2438,6 +2537,9 @@ var Queue = class _Queue extends LinearBase {
2438
2537
 
2439
2538
 
2440
2539
 
2540
+
2541
+
2542
+
2441
2543
 
2442
2544
 
2443
2545
 
@@ -2494,6 +2596,9 @@ var Queue = class _Queue extends LinearBase {
2494
2596
 
2495
2597
 
2496
2598
 
2599
+
2600
+
2601
+
2497
2602
 
2498
2603
 
2499
2604
 
@@ -2606,6 +2711,9 @@ var Queue = class _Queue extends LinearBase {
2606
2711
 
2607
2712
 
2608
2713
 
2714
+
2715
+
2716
+
2609
2717
 
2610
2718
 
2611
2719
 
@@ -2656,6 +2764,9 @@ var Queue = class _Queue extends LinearBase {
2656
2764
 
2657
2765
 
2658
2766
 
2767
+
2768
+
2769
+
2659
2770
 
2660
2771
 
2661
2772
 
@@ -2729,6 +2840,9 @@ var Queue = class _Queue extends LinearBase {
2729
2840
 
2730
2841
 
2731
2842
 
2843
+
2844
+
2845
+
2732
2846
 
2733
2847
 
2734
2848
 
@@ -2786,6 +2900,9 @@ var Queue = class _Queue extends LinearBase {
2786
2900
 
2787
2901
 
2788
2902
 
2903
+
2904
+
2905
+
2789
2906
 
2790
2907
 
2791
2908
 
@@ -2847,6 +2964,9 @@ var Queue = class _Queue extends LinearBase {
2847
2964
 
2848
2965
 
2849
2966
 
2967
+
2968
+
2969
+
2850
2970
 
2851
2971
 
2852
2972
 
@@ -3157,7 +3277,10 @@ var Deque = class extends LinearBase {
3157
3277
  }
3158
3278
  /**
3159
3279
  * Deque peek at both ends
3160
- * @example
3280
+
3281
+
3282
+
3283
+ * @example
3161
3284
  * // Deque peek at both ends
3162
3285
  * const deque = new Deque<number>([10, 20, 30, 40, 50]);
3163
3286
  *
@@ -3215,6 +3338,9 @@ var Deque = class extends LinearBase {
3215
3338
 
3216
3339
 
3217
3340
 
3341
+
3342
+
3343
+
3218
3344
 
3219
3345
 
3220
3346
 
@@ -3282,6 +3408,9 @@ var Deque = class extends LinearBase {
3282
3408
 
3283
3409
 
3284
3410
 
3411
+
3412
+
3413
+
3285
3414
 
3286
3415
 
3287
3416
 
@@ -3362,6 +3491,9 @@ var Deque = class extends LinearBase {
3362
3491
 
3363
3492
 
3364
3493
 
3494
+
3495
+
3496
+
3365
3497
 
3366
3498
 
3367
3499
 
@@ -3429,6 +3561,9 @@ var Deque = class extends LinearBase {
3429
3561
 
3430
3562
 
3431
3563
 
3564
+
3565
+
3566
+
3432
3567
 
3433
3568
 
3434
3569
 
@@ -3497,6 +3632,9 @@ var Deque = class extends LinearBase {
3497
3632
 
3498
3633
 
3499
3634
 
3635
+
3636
+
3637
+
3500
3638
 
3501
3639
 
3502
3640
 
@@ -3606,6 +3744,9 @@ var Deque = class extends LinearBase {
3606
3744
 
3607
3745
 
3608
3746
 
3747
+
3748
+
3749
+
3609
3750
 
3610
3751
 
3611
3752
 
@@ -3655,6 +3796,9 @@ var Deque = class extends LinearBase {
3655
3796
 
3656
3797
 
3657
3798
 
3799
+
3800
+
3801
+
3658
3802
 
3659
3803
 
3660
3804
 
@@ -3708,6 +3852,9 @@ var Deque = class extends LinearBase {
3708
3852
 
3709
3853
 
3710
3854
 
3855
+
3856
+
3857
+
3711
3858
 
3712
3859
 
3713
3860
 
@@ -3912,6 +4059,9 @@ var Deque = class extends LinearBase {
3912
4059
 
3913
4060
 
3914
4061
 
4062
+
4063
+
4064
+
3915
4065
 
3916
4066
 
3917
4067
 
@@ -4006,6 +4156,64 @@ var Deque = class extends LinearBase {
4006
4156
 
4007
4157
 
4008
4158
 
4159
+
4160
+ * @example
4161
+ * // Deque for...of iteration and reverse
4162
+ * const deque = new Deque<string>(['A', 'B', 'C', 'D']);
4163
+ *
4164
+ * // Iterate forward
4165
+ * const forward: string[] = [];
4166
+ * for (const item of deque) {
4167
+ * forward.push(item);
4168
+ * }
4169
+ * console.log(forward); // ['A', 'B', 'C', 'D'];
4170
+ *
4171
+ * // Reverse the deque
4172
+ * deque.reverse();
4173
+ * const backward: string[] = [];
4174
+ * for (const item of deque) {
4175
+ * backward.push(item);
4176
+ * }
4177
+ * console.log(backward); // ['D', 'C', 'B', 'A'];
4178
+ */
4179
+ /**
4180
+ * Find the last value matching a predicate (scans back-to-front).
4181
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
4182
+ * @param predicate - Function called with (value, index, deque).
4183
+ * @returns Matching value or undefined.
4184
+ * @example
4185
+ * // Find last matching value
4186
+ * const d = new Deque([1, 2, 3, 4, 5]);
4187
+ * console.log(d.findLast(v => v > 2)); // 5;
4188
+ * console.log(d.findLast(v => v % 2 === 0)); // 4;
4189
+ */
4190
+ findLast(predicate) {
4191
+ for (let i = this.length - 1; i >= 0; i--) {
4192
+ const val = this.at(i);
4193
+ if (predicate(val, i, this)) return val;
4194
+ }
4195
+ return void 0;
4196
+ }
4197
+ /**
4198
+ * Find the index of the last value matching a predicate (scans back-to-front).
4199
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
4200
+ * @param predicate - Function called with (value, index, deque).
4201
+ * @returns Matching index, or -1 if not found.
4202
+ * @example
4203
+ * // Find last matching index
4204
+ * const d = new Deque([10, 20, 30, 20, 10]);
4205
+ * console.log(d.findLastIndex(v => v === 20)); // 3;
4206
+ * console.log(d.findLastIndex(v => v === 10)); // 4;
4207
+ */
4208
+ findLastIndex(predicate) {
4209
+ for (let i = this.length - 1; i >= 0; i--) {
4210
+ if (predicate(this.at(i), i, this)) return i;
4211
+ }
4212
+ return -1;
4213
+ }
4214
+ /**
4215
+ * Deque for...of iteration and reverse
4216
+
4009
4217
 
4010
4218
  * @example
4011
4219
  * // Deque for...of iteration and reverse
@@ -4119,6 +4327,9 @@ var Deque = class extends LinearBase {
4119
4327
 
4120
4328
 
4121
4329
 
4330
+
4331
+
4332
+
4122
4333
 
4123
4334
 
4124
4335
 
@@ -4194,6 +4405,9 @@ var Deque = class extends LinearBase {
4194
4405
 
4195
4406
 
4196
4407
 
4408
+
4409
+
4410
+
4197
4411
 
4198
4412
 
4199
4413
 
@@ -4252,6 +4466,9 @@ var Deque = class extends LinearBase {
4252
4466
 
4253
4467
 
4254
4468
 
4469
+
4470
+
4471
+
4255
4472
 
4256
4473
 
4257
4474
 
@@ -4330,6 +4547,9 @@ var Deque = class extends LinearBase {
4330
4547
 
4331
4548
 
4332
4549
 
4550
+
4551
+
4552
+
4333
4553
 
4334
4554
 
4335
4555