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
@@ -185,6 +185,35 @@ var _IterableElementBase = class _IterableElementBase {
185
185
  for (const ele of this) if (ele === element) return true;
186
186
  return false;
187
187
  }
188
+ /**
189
+ * Check whether a value exists (Array-compatible alias for `has`).
190
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
191
+ * @param element - Element to search for (uses `===`).
192
+ * @returns `true` if found.
193
+ */
194
+ includes(element) {
195
+ return this.has(element);
196
+ }
197
+ /**
198
+ * Return an iterator of `[index, value]` pairs (Array-compatible).
199
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
200
+ */
201
+ *entries() {
202
+ let index = 0;
203
+ for (const value of this) {
204
+ yield [index++, value];
205
+ }
206
+ }
207
+ /**
208
+ * Return an iterator of numeric indices (Array-compatible).
209
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
210
+ */
211
+ *keys() {
212
+ let index = 0;
213
+ for (const _ of this) {
214
+ yield index++;
215
+ }
216
+ }
188
217
  /**
189
218
  * Reduces all elements to a single accumulated value.
190
219
  *
@@ -333,6 +362,9 @@ var _Heap = class _Heap extends IterableElementBase {
333
362
 
334
363
 
335
364
 
365
+
366
+
367
+
336
368
 
337
369
 
338
370
 
@@ -424,6 +456,9 @@ var _Heap = class _Heap extends IterableElementBase {
424
456
 
425
457
 
426
458
 
459
+
460
+
461
+
427
462
 
428
463
 
429
464
 
@@ -485,6 +520,9 @@ var _Heap = class _Heap extends IterableElementBase {
485
520
 
486
521
 
487
522
 
523
+
524
+
525
+
488
526
 
489
527
 
490
528
 
@@ -579,6 +617,9 @@ var _Heap = class _Heap extends IterableElementBase {
579
617
  */
580
618
  /**
581
619
  * @deprecated Use `pop` instead. Will be removed in a future major version.
620
+
621
+
622
+
582
623
  * @example
583
624
  * // Heap with custom comparator (MaxHeap behavior)
584
625
  * interface Task {
@@ -662,6 +703,9 @@ var _Heap = class _Heap extends IterableElementBase {
662
703
 
663
704
 
664
705
 
706
+
707
+
708
+
665
709
 
666
710
 
667
711
 
@@ -766,6 +810,9 @@ var _Heap = class _Heap extends IterableElementBase {
766
810
 
767
811
 
768
812
 
813
+
814
+
815
+
769
816
 
770
817
 
771
818
 
@@ -817,6 +864,9 @@ var _Heap = class _Heap extends IterableElementBase {
817
864
 
818
865
 
819
866
 
867
+
868
+
869
+
820
870
 
821
871
 
822
872
 
@@ -861,6 +911,9 @@ var _Heap = class _Heap extends IterableElementBase {
861
911
 
862
912
 
863
913
 
914
+
915
+
916
+
864
917
 
865
918
 
866
919
 
@@ -912,6 +965,9 @@ var _Heap = class _Heap extends IterableElementBase {
912
965
 
913
966
 
914
967
 
968
+
969
+
970
+
915
971
 
916
972
 
917
973
 
@@ -1015,6 +1071,9 @@ var _Heap = class _Heap extends IterableElementBase {
1015
1071
 
1016
1072
 
1017
1073
 
1074
+
1075
+
1076
+
1018
1077
 
1019
1078
 
1020
1079
 
@@ -1099,6 +1158,9 @@ var _Heap = class _Heap extends IterableElementBase {
1099
1158
 
1100
1159
 
1101
1160
 
1161
+
1162
+
1163
+
1102
1164
 
1103
1165
 
1104
1166
 
@@ -1156,6 +1218,9 @@ var _Heap = class _Heap extends IterableElementBase {
1156
1218
 
1157
1219
 
1158
1220
 
1221
+
1222
+
1223
+
1159
1224
 
1160
1225
 
1161
1226
 
@@ -1212,6 +1277,9 @@ var _Heap = class _Heap extends IterableElementBase {
1212
1277
 
1213
1278
 
1214
1279
 
1280
+
1281
+
1282
+
1215
1283
 
1216
1284
 
1217
1285
 
@@ -1275,6 +1343,9 @@ var _Heap = class _Heap extends IterableElementBase {
1275
1343
 
1276
1344
 
1277
1345
 
1346
+
1347
+
1348
+
1278
1349
 
1279
1350
 
1280
1351
 
@@ -160,6 +160,35 @@ var _IterableElementBase = class _IterableElementBase {
160
160
  for (const ele of this) if (ele === element) return true;
161
161
  return false;
162
162
  }
163
+ /**
164
+ * Check whether a value exists (Array-compatible alias for `has`).
165
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
166
+ * @param element - Element to search for (uses `===`).
167
+ * @returns `true` if found.
168
+ */
169
+ includes(element) {
170
+ return this.has(element);
171
+ }
172
+ /**
173
+ * Return an iterator of `[index, value]` pairs (Array-compatible).
174
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
175
+ */
176
+ *entries() {
177
+ let index = 0;
178
+ for (const value of this) {
179
+ yield [index++, value];
180
+ }
181
+ }
182
+ /**
183
+ * Return an iterator of numeric indices (Array-compatible).
184
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
185
+ */
186
+ *keys() {
187
+ let index = 0;
188
+ for (const _ of this) {
189
+ yield index++;
190
+ }
191
+ }
163
192
  /**
164
193
  * Reduces all elements to a single accumulated value.
165
194
  *
@@ -468,6 +497,16 @@ var _LinearBase = class _LinearBase extends IterableElementBase {
468
497
  }
469
498
  return this;
470
499
  }
500
+ /**
501
+ * Return a new instance of the same type with elements in reverse order (non-mutating).
502
+ * @remarks Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
503
+ * @returns A new reversed instance.
504
+ */
505
+ toReversed() {
506
+ const cloned = this.clone();
507
+ cloned.reverse();
508
+ return cloned;
509
+ }
471
510
  };
472
511
  __name(_LinearBase, "LinearBase");
473
512
  var LinearBase = _LinearBase;
@@ -766,6 +805,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
766
805
 
767
806
 
768
807
 
808
+
809
+
810
+
769
811
 
770
812
 
771
813
 
@@ -837,6 +879,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
837
879
 
838
880
 
839
881
 
882
+
883
+
884
+
840
885
 
841
886
 
842
887
 
@@ -914,6 +959,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
914
959
 
915
960
 
916
961
 
962
+
963
+
964
+
917
965
 
918
966
 
919
967
 
@@ -972,6 +1020,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
972
1020
 
973
1021
 
974
1022
 
1023
+
1024
+
1025
+
975
1026
 
976
1027
 
977
1028
 
@@ -1091,6 +1142,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1091
1142
 
1092
1143
 
1093
1144
 
1145
+
1146
+
1147
+
1094
1148
 
1095
1149
 
1096
1150
 
@@ -1154,6 +1208,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1154
1208
 
1155
1209
 
1156
1210
 
1211
+
1212
+
1213
+
1157
1214
 
1158
1215
 
1159
1216
 
@@ -1206,6 +1263,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1206
1263
 
1207
1264
 
1208
1265
 
1266
+
1267
+
1268
+
1209
1269
 
1210
1270
 
1211
1271
 
@@ -1264,6 +1324,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1264
1324
 
1265
1325
 
1266
1326
 
1327
+
1328
+
1329
+
1267
1330
 
1268
1331
 
1269
1332
 
@@ -1327,6 +1390,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1327
1390
 
1328
1391
 
1329
1392
 
1393
+
1394
+
1395
+
1330
1396
 
1331
1397
 
1332
1398
 
@@ -1398,6 +1464,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1398
1464
 
1399
1465
 
1400
1466
 
1467
+
1468
+
1469
+
1401
1470
 
1402
1471
 
1403
1472
 
@@ -1446,6 +1515,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1446
1515
 
1447
1516
 
1448
1517
 
1518
+
1519
+
1520
+
1449
1521
 
1450
1522
 
1451
1523
 
@@ -1500,6 +1572,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1500
1572
 
1501
1573
 
1502
1574
 
1575
+
1576
+
1577
+
1503
1578
 
1504
1579
 
1505
1580
 
@@ -1720,6 +1795,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1720
1795
 
1721
1796
 
1722
1797
 
1798
+
1799
+
1800
+
1723
1801
 
1724
1802
 
1725
1803
 
@@ -1778,6 +1856,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1778
1856
 
1779
1857
 
1780
1858
 
1859
+
1860
+
1861
+
1781
1862
 
1782
1863
 
1783
1864
 
@@ -1864,6 +1945,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1864
1945
 
1865
1946
 
1866
1947
 
1948
+
1949
+
1950
+
1867
1951
 
1868
1952
 
1869
1953
 
@@ -2102,6 +2186,9 @@ var _Queue = class _Queue extends LinearBase {
2102
2186
 
2103
2187
 
2104
2188
 
2189
+
2190
+
2191
+
2105
2192
 
2106
2193
 
2107
2194
 
@@ -2156,6 +2243,9 @@ var _Queue = class _Queue extends LinearBase {
2156
2243
 
2157
2244
 
2158
2245
 
2246
+
2247
+
2248
+
2159
2249
 
2160
2250
 
2161
2251
 
@@ -2234,6 +2324,9 @@ var _Queue = class _Queue extends LinearBase {
2234
2324
 
2235
2325
 
2236
2326
 
2327
+
2328
+
2329
+
2237
2330
 
2238
2331
 
2239
2332
 
@@ -2300,6 +2393,9 @@ var _Queue = class _Queue extends LinearBase {
2300
2393
 
2301
2394
 
2302
2395
 
2396
+
2397
+
2398
+
2303
2399
 
2304
2400
 
2305
2401
 
@@ -2373,6 +2469,9 @@ var _Queue = class _Queue extends LinearBase {
2373
2469
 
2374
2470
 
2375
2471
 
2472
+
2473
+
2474
+
2376
2475
 
2377
2476
 
2378
2477
 
@@ -2436,6 +2535,9 @@ var _Queue = class _Queue extends LinearBase {
2436
2535
 
2437
2536
 
2438
2537
 
2538
+
2539
+
2540
+
2439
2541
 
2440
2542
 
2441
2543
 
@@ -2492,6 +2594,9 @@ var _Queue = class _Queue extends LinearBase {
2492
2594
 
2493
2595
 
2494
2596
 
2597
+
2598
+
2599
+
2495
2600
 
2496
2601
 
2497
2602
 
@@ -2604,6 +2709,9 @@ var _Queue = class _Queue extends LinearBase {
2604
2709
 
2605
2710
 
2606
2711
 
2712
+
2713
+
2714
+
2607
2715
 
2608
2716
 
2609
2717
 
@@ -2654,6 +2762,9 @@ var _Queue = class _Queue extends LinearBase {
2654
2762
 
2655
2763
 
2656
2764
 
2765
+
2766
+
2767
+
2657
2768
 
2658
2769
 
2659
2770
 
@@ -2727,6 +2838,9 @@ var _Queue = class _Queue extends LinearBase {
2727
2838
 
2728
2839
 
2729
2840
 
2841
+
2842
+
2843
+
2730
2844
 
2731
2845
 
2732
2846
 
@@ -2784,6 +2898,9 @@ var _Queue = class _Queue extends LinearBase {
2784
2898
 
2785
2899
 
2786
2900
 
2901
+
2902
+
2903
+
2787
2904
 
2788
2905
 
2789
2906
 
@@ -2845,6 +2962,9 @@ var _Queue = class _Queue extends LinearBase {
2845
2962
 
2846
2963
 
2847
2964
 
2965
+
2966
+
2967
+
2848
2968
 
2849
2969
 
2850
2970
 
@@ -3155,7 +3275,10 @@ var _Deque = class _Deque extends LinearBase {
3155
3275
  }
3156
3276
  /**
3157
3277
  * Deque peek at both ends
3158
- * @example
3278
+
3279
+
3280
+
3281
+ * @example
3159
3282
  * // Deque peek at both ends
3160
3283
  * const deque = new Deque<number>([10, 20, 30, 40, 50]);
3161
3284
  *
@@ -3213,6 +3336,9 @@ var _Deque = class _Deque extends LinearBase {
3213
3336
 
3214
3337
 
3215
3338
 
3339
+
3340
+
3341
+
3216
3342
 
3217
3343
 
3218
3344
 
@@ -3280,6 +3406,9 @@ var _Deque = class _Deque extends LinearBase {
3280
3406
 
3281
3407
 
3282
3408
 
3409
+
3410
+
3411
+
3283
3412
 
3284
3413
 
3285
3414
 
@@ -3360,6 +3489,9 @@ var _Deque = class _Deque extends LinearBase {
3360
3489
 
3361
3490
 
3362
3491
 
3492
+
3493
+
3494
+
3363
3495
 
3364
3496
 
3365
3497
 
@@ -3427,6 +3559,9 @@ var _Deque = class _Deque extends LinearBase {
3427
3559
 
3428
3560
 
3429
3561
 
3562
+
3563
+
3564
+
3430
3565
 
3431
3566
 
3432
3567
 
@@ -3495,6 +3630,9 @@ var _Deque = class _Deque extends LinearBase {
3495
3630
 
3496
3631
 
3497
3632
 
3633
+
3634
+
3635
+
3498
3636
 
3499
3637
 
3500
3638
 
@@ -3604,6 +3742,9 @@ var _Deque = class _Deque extends LinearBase {
3604
3742
 
3605
3743
 
3606
3744
 
3745
+
3746
+
3747
+
3607
3748
 
3608
3749
 
3609
3750
 
@@ -3653,6 +3794,9 @@ var _Deque = class _Deque extends LinearBase {
3653
3794
 
3654
3795
 
3655
3796
 
3797
+
3798
+
3799
+
3656
3800
 
3657
3801
 
3658
3802
 
@@ -3706,6 +3850,9 @@ var _Deque = class _Deque extends LinearBase {
3706
3850
 
3707
3851
 
3708
3852
 
3853
+
3854
+
3855
+
3709
3856
 
3710
3857
 
3711
3858
 
@@ -3910,6 +4057,9 @@ var _Deque = class _Deque extends LinearBase {
3910
4057
 
3911
4058
 
3912
4059
 
4060
+
4061
+
4062
+
3913
4063
 
3914
4064
 
3915
4065
 
@@ -4004,6 +4154,64 @@ var _Deque = class _Deque extends LinearBase {
4004
4154
 
4005
4155
 
4006
4156
 
4157
+
4158
+ * @example
4159
+ * // Deque for...of iteration and reverse
4160
+ * const deque = new Deque<string>(['A', 'B', 'C', 'D']);
4161
+ *
4162
+ * // Iterate forward
4163
+ * const forward: string[] = [];
4164
+ * for (const item of deque) {
4165
+ * forward.push(item);
4166
+ * }
4167
+ * console.log(forward); // ['A', 'B', 'C', 'D'];
4168
+ *
4169
+ * // Reverse the deque
4170
+ * deque.reverse();
4171
+ * const backward: string[] = [];
4172
+ * for (const item of deque) {
4173
+ * backward.push(item);
4174
+ * }
4175
+ * console.log(backward); // ['D', 'C', 'B', 'A'];
4176
+ */
4177
+ /**
4178
+ * Find the last value matching a predicate (scans back-to-front).
4179
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
4180
+ * @param predicate - Function called with (value, index, deque).
4181
+ * @returns Matching value or undefined.
4182
+ * @example
4183
+ * // Find last matching value
4184
+ * const d = new Deque([1, 2, 3, 4, 5]);
4185
+ * console.log(d.findLast(v => v > 2)); // 5;
4186
+ * console.log(d.findLast(v => v % 2 === 0)); // 4;
4187
+ */
4188
+ findLast(predicate) {
4189
+ for (let i = this.length - 1; i >= 0; i--) {
4190
+ const val = this.at(i);
4191
+ if (predicate(val, i, this)) return val;
4192
+ }
4193
+ return void 0;
4194
+ }
4195
+ /**
4196
+ * Find the index of the last value matching a predicate (scans back-to-front).
4197
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
4198
+ * @param predicate - Function called with (value, index, deque).
4199
+ * @returns Matching index, or -1 if not found.
4200
+ * @example
4201
+ * // Find last matching index
4202
+ * const d = new Deque([10, 20, 30, 20, 10]);
4203
+ * console.log(d.findLastIndex(v => v === 20)); // 3;
4204
+ * console.log(d.findLastIndex(v => v === 10)); // 4;
4205
+ */
4206
+ findLastIndex(predicate) {
4207
+ for (let i = this.length - 1; i >= 0; i--) {
4208
+ if (predicate(this.at(i), i, this)) return i;
4209
+ }
4210
+ return -1;
4211
+ }
4212
+ /**
4213
+ * Deque for...of iteration and reverse
4214
+
4007
4215
 
4008
4216
  * @example
4009
4217
  * // Deque for...of iteration and reverse
@@ -4117,6 +4325,9 @@ var _Deque = class _Deque extends LinearBase {
4117
4325
 
4118
4326
 
4119
4327
 
4328
+
4329
+
4330
+
4120
4331
 
4121
4332
 
4122
4333
 
@@ -4192,6 +4403,9 @@ var _Deque = class _Deque extends LinearBase {
4192
4403
 
4193
4404
 
4194
4405
 
4406
+
4407
+
4408
+
4195
4409
 
4196
4410
 
4197
4411
 
@@ -4250,6 +4464,9 @@ var _Deque = class _Deque extends LinearBase {
4250
4464
 
4251
4465
 
4252
4466
 
4467
+
4468
+
4469
+
4253
4470
 
4254
4471
 
4255
4472
 
@@ -4328,6 +4545,9 @@ var _Deque = class _Deque extends LinearBase {
4328
4545
 
4329
4546
 
4330
4547
 
4548
+
4549
+
4550
+
4331
4551
 
4332
4552
 
4333
4553