data-structure-typed 2.5.2 → 2.6.0

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 (162) hide show
  1. package/.husky/pre-commit +3 -0
  2. package/CHANGELOG.md +3 -1
  3. package/MIGRATION.md +217 -0
  4. package/README.md +80 -8
  5. package/README_CN.md +569 -143
  6. package/SPECIFICATION.md +44 -14
  7. package/SPECIFICATION.zh-CN.md +44 -14
  8. package/dist/cjs/binary-tree.cjs +5841 -1678
  9. package/dist/cjs/graph.cjs +422 -14
  10. package/dist/cjs/hash.cjs +95 -7
  11. package/dist/cjs/heap.cjs +174 -16
  12. package/dist/cjs/index.cjs +7751 -2449
  13. package/dist/cjs/linked-list.cjs +443 -2
  14. package/dist/cjs/matrix.cjs +56 -0
  15. package/dist/cjs/priority-queue.cjs +172 -14
  16. package/dist/cjs/queue.cjs +435 -0
  17. package/dist/cjs/stack.cjs +103 -4
  18. package/dist/cjs/trie.cjs +106 -0
  19. package/dist/cjs-legacy/binary-tree.cjs +5933 -1772
  20. package/dist/cjs-legacy/graph.cjs +422 -14
  21. package/dist/cjs-legacy/hash.cjs +95 -7
  22. package/dist/cjs-legacy/heap.cjs +174 -16
  23. package/dist/cjs-legacy/index.cjs +8154 -2854
  24. package/dist/cjs-legacy/linked-list.cjs +443 -2
  25. package/dist/cjs-legacy/matrix.cjs +56 -0
  26. package/dist/cjs-legacy/priority-queue.cjs +172 -14
  27. package/dist/cjs-legacy/queue.cjs +435 -0
  28. package/dist/cjs-legacy/stack.cjs +103 -4
  29. package/dist/cjs-legacy/trie.cjs +106 -0
  30. package/dist/esm/binary-tree.mjs +5841 -1678
  31. package/dist/esm/graph.mjs +422 -14
  32. package/dist/esm/hash.mjs +95 -7
  33. package/dist/esm/heap.mjs +174 -16
  34. package/dist/esm/index.mjs +7751 -2449
  35. package/dist/esm/linked-list.mjs +443 -2
  36. package/dist/esm/matrix.mjs +56 -0
  37. package/dist/esm/priority-queue.mjs +172 -14
  38. package/dist/esm/queue.mjs +435 -0
  39. package/dist/esm/stack.mjs +103 -4
  40. package/dist/esm/trie.mjs +106 -0
  41. package/dist/esm-legacy/binary-tree.mjs +5933 -1772
  42. package/dist/esm-legacy/graph.mjs +422 -14
  43. package/dist/esm-legacy/hash.mjs +95 -7
  44. package/dist/esm-legacy/heap.mjs +174 -16
  45. package/dist/esm-legacy/index.mjs +8154 -2854
  46. package/dist/esm-legacy/linked-list.mjs +443 -2
  47. package/dist/esm-legacy/matrix.mjs +56 -0
  48. package/dist/esm-legacy/priority-queue.mjs +172 -14
  49. package/dist/esm-legacy/queue.mjs +435 -0
  50. package/dist/esm-legacy/stack.mjs +103 -4
  51. package/dist/esm-legacy/trie.mjs +106 -0
  52. package/dist/types/data-structures/base/iterable-element-base.d.ts +17 -0
  53. package/dist/types/data-structures/base/linear-base.d.ts +6 -0
  54. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +86 -2
  55. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +98 -0
  56. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +191 -15
  57. package/dist/types/data-structures/binary-tree/bst.d.ts +171 -3
  58. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +136 -8
  59. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +42 -0
  60. package/dist/types/data-structures/binary-tree/tree-map.d.ts +1061 -167
  61. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1232 -355
  62. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +916 -194
  63. package/dist/types/data-structures/binary-tree/tree-set.d.ts +1078 -141
  64. package/dist/types/data-structures/graph/directed-graph.d.ts +70 -0
  65. package/dist/types/data-structures/graph/undirected-graph.d.ts +63 -0
  66. package/dist/types/data-structures/hash/hash-map.d.ts +84 -6
  67. package/dist/types/data-structures/heap/heap.d.ts +140 -12
  68. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +150 -2
  69. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +106 -1
  70. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +126 -0
  71. package/dist/types/data-structures/matrix/matrix.d.ts +56 -0
  72. package/dist/types/data-structures/queue/deque.d.ts +171 -0
  73. package/dist/types/data-structures/queue/queue.d.ts +97 -0
  74. package/dist/types/data-structures/stack/stack.d.ts +72 -2
  75. package/dist/types/data-structures/trie/trie.d.ts +84 -0
  76. package/dist/types/interfaces/binary-tree.d.ts +2 -3
  77. package/dist/umd/data-structure-typed.js +7784 -2484
  78. package/dist/umd/data-structure-typed.min.js +4 -4
  79. package/docs-site-docusaurus/docs/api/classes/AVLTree.md +188 -200
  80. package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +11 -11
  81. package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +62 -62
  82. package/docs-site-docusaurus/docs/api/classes/BST.md +183 -195
  83. package/docs-site-docusaurus/docs/api/classes/BSTNode.md +13 -13
  84. package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +15 -15
  85. package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +143 -155
  86. package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
  87. package/docs-site-docusaurus/docs/api/classes/Deque.md +99 -85
  88. package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +73 -73
  89. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +100 -70
  90. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +8 -8
  91. package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +12 -12
  92. package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
  93. package/docs-site-docusaurus/docs/api/classes/HashMap.md +38 -38
  94. package/docs-site-docusaurus/docs/api/classes/Heap.md +96 -85
  95. package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +25 -25
  96. package/docs-site-docusaurus/docs/api/classes/IterableEntryBase.md +23 -23
  97. package/docs-site-docusaurus/docs/api/classes/LinearBase.md +48 -48
  98. package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +52 -52
  99. package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +46 -42
  100. package/docs-site-docusaurus/docs/api/classes/LinkedListNode.md +6 -6
  101. package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +74 -74
  102. package/docs-site-docusaurus/docs/api/classes/MapGraph.md +73 -73
  103. package/docs-site-docusaurus/docs/api/classes/Matrix.md +31 -31
  104. package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +104 -89
  105. package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +104 -89
  106. package/docs-site-docusaurus/docs/api/classes/MinHeap.md +104 -89
  107. package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +104 -89
  108. package/docs-site-docusaurus/docs/api/classes/Navigator.md +5 -5
  109. package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +103 -88
  110. package/docs-site-docusaurus/docs/api/classes/Queue.md +111 -59
  111. package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +200 -212
  112. package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -10
  113. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +75 -75
  114. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +6 -6
  115. package/docs-site-docusaurus/docs/api/classes/SkipList.md +37 -37
  116. package/docs-site-docusaurus/docs/api/classes/Stack.md +42 -42
  117. package/docs-site-docusaurus/docs/api/classes/TreeMap.md +107 -36
  118. package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +43 -43
  119. package/docs-site-docusaurus/docs/api/classes/TreeSet.md +106 -35
  120. package/docs-site-docusaurus/docs/api/classes/Trie.md +43 -43
  121. package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
  122. package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +72 -72
  123. package/docs-site-docusaurus/docs/guide/architecture.md +75 -7
  124. package/docs-site-docusaurus/docs/guide/concepts.md +53 -34
  125. package/docs-site-docusaurus/docs/guide/faq.md +53 -0
  126. package/docs-site-docusaurus/docs/guide/guides.md +8 -9
  127. package/docs-site-docusaurus/docs/guide/integrations.md +74 -177
  128. package/docs-site-docusaurus/docs/guide/overview.md +131 -17
  129. package/docs-site-docusaurus/src/pages/index.tsx +4 -0
  130. package/docs-site-docusaurus/typedoc.json +1 -0
  131. package/jest.integration.config.js +1 -2
  132. package/package.json +10 -7
  133. package/src/data-structures/base/iterable-element-base.ts +32 -0
  134. package/src/data-structures/base/linear-base.ts +11 -0
  135. package/src/data-structures/binary-tree/avl-tree.ts +88 -5
  136. package/src/data-structures/binary-tree/binary-indexed-tree.ts +98 -0
  137. package/src/data-structures/binary-tree/binary-tree.ts +242 -81
  138. package/src/data-structures/binary-tree/bst.ts +173 -7
  139. package/src/data-structures/binary-tree/red-black-tree.ts +139 -15
  140. package/src/data-structures/binary-tree/segment-tree.ts +42 -0
  141. package/src/data-structures/binary-tree/tree-map.ts +948 -36
  142. package/src/data-structures/binary-tree/tree-multi-map.ts +893 -13
  143. package/src/data-structures/binary-tree/tree-multi-set.ts +761 -33
  144. package/src/data-structures/binary-tree/tree-set.ts +1260 -251
  145. package/src/data-structures/graph/directed-graph.ts +71 -1
  146. package/src/data-structures/graph/undirected-graph.ts +64 -1
  147. package/src/data-structures/hash/hash-map.ts +100 -12
  148. package/src/data-structures/heap/heap.ts +149 -19
  149. package/src/data-structures/linked-list/doubly-linked-list.ts +178 -2
  150. package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
  151. package/src/data-structures/linked-list/skip-linked-list.ts +126 -0
  152. package/src/data-structures/matrix/matrix.ts +56 -0
  153. package/src/data-structures/queue/deque.ts +187 -0
  154. package/src/data-structures/queue/queue.ts +109 -0
  155. package/src/data-structures/stack/stack.ts +75 -5
  156. package/src/data-structures/trie/trie.ts +84 -0
  157. package/src/interfaces/binary-tree.ts +1 -9
  158. package/.vitepress/cache/deps_temp_51f5f1b0/chunk-7OIKW5WK.js +0 -12984
  159. package/.vitepress/cache/deps_temp_51f5f1b0/package.json +0 -3
  160. package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vue_devtools-api.js +0 -4505
  161. package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vueuse_core.js +0 -9731
  162. package/.vitepress/cache/deps_temp_51f5f1b0/vue.js +0 -347
@@ -192,6 +192,35 @@ var _IterableElementBase = class _IterableElementBase {
192
192
  for (const ele of this) if (ele === element) return true;
193
193
  return false;
194
194
  }
195
+ /**
196
+ * Check whether a value exists (Array-compatible alias for `has`).
197
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
198
+ * @param element - Element to search for (uses `===`).
199
+ * @returns `true` if found.
200
+ */
201
+ includes(element) {
202
+ return this.has(element);
203
+ }
204
+ /**
205
+ * Return an iterator of `[index, value]` pairs (Array-compatible).
206
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
207
+ */
208
+ *entries() {
209
+ let index = 0;
210
+ for (const value of this) {
211
+ yield [index++, value];
212
+ }
213
+ }
214
+ /**
215
+ * Return an iterator of numeric indices (Array-compatible).
216
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
217
+ */
218
+ *keys() {
219
+ let index = 0;
220
+ for (const _ of this) {
221
+ yield index++;
222
+ }
223
+ }
195
224
  /**
196
225
  * Reduces all elements to a single accumulated value.
197
226
  *
@@ -500,6 +529,16 @@ var _LinearBase = class _LinearBase extends IterableElementBase {
500
529
  }
501
530
  return this;
502
531
  }
532
+ /**
533
+ * Return a new instance of the same type with elements in reverse order (non-mutating).
534
+ * @remarks Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
535
+ * @returns A new reversed instance.
536
+ */
537
+ toReversed() {
538
+ const cloned = this.clone();
539
+ cloned.reverse();
540
+ return cloned;
541
+ }
503
542
  };
504
543
  __name(_LinearBase, "LinearBase");
505
544
  var LinearBase = _LinearBase;
@@ -790,6 +829,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
790
829
 
791
830
 
792
831
 
832
+
833
+
834
+
835
+
836
+
837
+
838
+
793
839
 
794
840
 
795
841
 
@@ -857,6 +903,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
857
903
 
858
904
 
859
905
 
906
+
907
+
908
+
909
+
910
+
911
+
912
+
860
913
 
861
914
 
862
915
 
@@ -930,6 +983,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
930
983
 
931
984
 
932
985
 
986
+
987
+
988
+
989
+
990
+
991
+
992
+
933
993
 
934
994
 
935
995
 
@@ -984,6 +1044,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
984
1044
 
985
1045
 
986
1046
 
1047
+
1048
+
1049
+
1050
+
1051
+
1052
+
1053
+
987
1054
 
988
1055
 
989
1056
 
@@ -1099,6 +1166,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1099
1166
 
1100
1167
 
1101
1168
 
1169
+
1170
+
1171
+
1172
+
1173
+
1174
+
1175
+
1102
1176
 
1103
1177
 
1104
1178
 
@@ -1158,6 +1232,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1158
1232
 
1159
1233
 
1160
1234
 
1235
+
1236
+
1237
+
1238
+
1239
+
1240
+
1241
+
1161
1242
 
1162
1243
 
1163
1244
 
@@ -1206,6 +1287,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1206
1287
 
1207
1288
 
1208
1289
 
1290
+
1291
+
1292
+
1293
+
1294
+
1295
+
1296
+
1209
1297
 
1210
1298
 
1211
1299
 
@@ -1260,6 +1348,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1260
1348
 
1261
1349
 
1262
1350
 
1351
+
1352
+
1353
+
1354
+
1355
+
1356
+
1357
+
1263
1358
 
1264
1359
 
1265
1360
 
@@ -1319,6 +1414,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1319
1414
 
1320
1415
 
1321
1416
 
1417
+
1418
+
1419
+
1420
+
1421
+
1422
+
1423
+
1322
1424
 
1323
1425
 
1324
1426
 
@@ -1386,6 +1488,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1386
1488
 
1387
1489
 
1388
1490
 
1491
+
1492
+
1493
+
1494
+
1495
+
1496
+
1497
+
1389
1498
 
1390
1499
 
1391
1500
 
@@ -1430,6 +1539,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1430
1539
 
1431
1540
 
1432
1541
 
1542
+
1543
+
1544
+
1545
+
1546
+
1547
+
1548
+
1433
1549
 
1434
1550
 
1435
1551
 
@@ -1480,6 +1596,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1480
1596
 
1481
1597
 
1482
1598
 
1599
+
1600
+
1601
+
1602
+
1603
+
1604
+
1605
+
1483
1606
 
1484
1607
 
1485
1608
 
@@ -1696,6 +1819,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1696
1819
 
1697
1820
 
1698
1821
 
1822
+
1823
+
1824
+
1825
+
1826
+
1827
+
1828
+
1699
1829
 
1700
1830
 
1701
1831
 
@@ -1750,6 +1880,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1750
1880
 
1751
1881
 
1752
1882
 
1883
+
1884
+
1885
+
1886
+
1887
+
1888
+
1889
+
1753
1890
 
1754
1891
 
1755
1892
 
@@ -1832,6 +1969,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1832
1969
 
1833
1970
 
1834
1971
 
1972
+
1973
+
1974
+
1975
+
1976
+
1977
+
1978
+
1835
1979
 
1836
1980
 
1837
1981
 
@@ -2152,6 +2296,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2152
2296
 
2153
2297
 
2154
2298
 
2299
+
2300
+
2301
+
2302
+
2303
+
2304
+
2305
+
2155
2306
 
2156
2307
 
2157
2308
 
@@ -2221,6 +2372,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2221
2372
 
2222
2373
 
2223
2374
 
2375
+
2376
+
2377
+
2378
+
2379
+
2380
+
2381
+
2224
2382
 
2225
2383
 
2226
2384
 
@@ -2289,6 +2447,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2289
2447
 
2290
2448
 
2291
2449
 
2450
+
2451
+
2452
+
2453
+
2454
+
2455
+
2456
+
2292
2457
 
2293
2458
 
2294
2459
 
@@ -2348,6 +2513,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2348
2513
 
2349
2514
 
2350
2515
 
2516
+
2517
+
2518
+
2519
+
2520
+
2521
+
2522
+
2351
2523
 
2352
2524
 
2353
2525
 
@@ -2436,6 +2608,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2436
2608
 
2437
2609
 
2438
2610
 
2611
+
2612
+
2613
+
2614
+
2615
+
2616
+
2617
+
2439
2618
 
2440
2619
 
2441
2620
 
@@ -2485,6 +2664,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2485
2664
 
2486
2665
 
2487
2666
 
2667
+
2668
+
2669
+
2670
+
2671
+
2672
+
2673
+
2488
2674
 
2489
2675
 
2490
2676
 
@@ -2565,6 +2751,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2565
2751
 
2566
2752
 
2567
2753
 
2754
+
2755
+
2756
+
2757
+
2758
+
2759
+
2760
+
2568
2761
 
2569
2762
 
2570
2763
 
@@ -2673,6 +2866,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2673
2866
 
2674
2867
 
2675
2868
 
2869
+
2870
+
2871
+
2872
+
2873
+
2874
+
2875
+
2676
2876
 
2677
2877
 
2678
2878
 
@@ -2728,6 +2928,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2728
2928
 
2729
2929
 
2730
2930
 
2931
+
2932
+
2933
+
2934
+
2935
+
2936
+
2937
+
2731
2938
 
2732
2939
 
2733
2940
 
@@ -2785,6 +2992,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2785
2992
 
2786
2993
 
2787
2994
 
2995
+
2996
+
2997
+
2998
+
2999
+
3000
+
3001
+
2788
3002
 
2789
3003
 
2790
3004
 
@@ -2829,6 +3043,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2829
3043
 
2830
3044
 
2831
3045
 
3046
+
3047
+
3048
+
3049
+
3050
+
3051
+
3052
+
2832
3053
 
2833
3054
 
2834
3055
 
@@ -2877,6 +3098,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2877
3098
 
2878
3099
 
2879
3100
 
3101
+
3102
+
3103
+
3104
+
3105
+
3106
+
3107
+
2880
3108
 
2881
3109
 
2882
3110
 
@@ -2932,6 +3160,10 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2932
3160
 
2933
3161
 
2934
3162
 
3163
+
3164
+
3165
+
3166
+
2935
3167
 
2936
3168
 
2937
3169
 
@@ -2940,11 +3172,31 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2940
3172
  * @example
2941
3173
  * // Find value scanning from tail
2942
3174
  * const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
2943
- * // getBackward scans from tail to head, returns first match
2944
- * const found = list.getBackward(node => node.value < 4);
3175
+ * // findLast scans from tail to head, returns first match
3176
+ * const found = list.findLast(node => node.value < 4);
2945
3177
  * console.log(found); // 3;
2946
3178
  */
3179
+ /**
3180
+ * @deprecated Use `findLast` instead. Will be removed in a future major version.
3181
+ */
2947
3182
  getBackward(elementNodeOrPredicate) {
3183
+ return this.findLast(elementNodeOrPredicate);
3184
+ }
3185
+ /**
3186
+ * Find the first value matching a predicate scanning backward (tail → head).
3187
+ * @remarks Time O(N), Space O(1)
3188
+ * @param elementNodeOrPredicate - Element, node, or predicate to match.
3189
+ * @returns Matching value or undefined.
3190
+
3191
+
3192
+ * @example
3193
+ * // Find value scanning from tail
3194
+ * const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
3195
+ * // findLast scans from tail to head, returns first match
3196
+ * const found = list.findLast(node => node.value < 4);
3197
+ * console.log(found); // 3;
3198
+ */
3199
+ findLast(elementNodeOrPredicate) {
2948
3200
  const predicate = this._ensurePredicate(elementNodeOrPredicate);
2949
3201
  let current = this.tail;
2950
3202
  while (current) {
@@ -2953,6 +3205,22 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2953
3205
  }
2954
3206
  return void 0;
2955
3207
  }
3208
+ /**
3209
+ * Find the index of the last value matching a predicate (scans tail → head).
3210
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
3211
+ * @param predicate - Function called with (value, index, list).
3212
+ * @returns Matching index, or -1 if not found.
3213
+ */
3214
+ findLastIndex(predicate) {
3215
+ let current = this.tail;
3216
+ let index = this.length - 1;
3217
+ while (current) {
3218
+ if (predicate(current.value, index, this)) return index;
3219
+ current = current.prev;
3220
+ index--;
3221
+ }
3222
+ return -1;
3223
+ }
2956
3224
  /**
2957
3225
  * Reverse the list in place.
2958
3226
  * @remarks Time O(N), Space O(1)
@@ -2984,6 +3252,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2984
3252
 
2985
3253
 
2986
3254
 
3255
+
3256
+
3257
+
3258
+
3259
+
3260
+
3261
+
2987
3262
 
2988
3263
 
2989
3264
 
@@ -3008,6 +3283,25 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
3008
3283
  }
3009
3284
  return this;
3010
3285
  }
3286
+ /**
3287
+ * Delete the first element that satisfies a predicate.
3288
+ * @remarks Time O(N), Space O(1)
3289
+ * @param predicate - Function (value, index, list) → boolean to decide deletion.
3290
+ * @returns True if a match was removed.
3291
+ */
3292
+ deleteWhere(predicate) {
3293
+ let current = this.head;
3294
+ let index = 0;
3295
+ while (current) {
3296
+ if (predicate(current.value, index, this)) {
3297
+ this.delete(current);
3298
+ return true;
3299
+ }
3300
+ current = current.next;
3301
+ index++;
3302
+ }
3303
+ return false;
3304
+ }
3011
3305
  /**
3012
3306
  * Set the equality comparator used to compare values.
3013
3307
  * @remarks Time O(1), Space O(1)
@@ -3047,6 +3341,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
3047
3341
 
3048
3342
 
3049
3343
 
3344
+
3345
+
3346
+
3347
+
3348
+
3349
+
3350
+
3050
3351
 
3051
3352
 
3052
3353
 
@@ -3100,6 +3401,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
3100
3401
 
3101
3402
 
3102
3403
 
3404
+
3405
+
3406
+
3407
+
3408
+
3409
+
3410
+
3103
3411
 
3104
3412
 
3105
3413
 
@@ -3172,6 +3480,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
3172
3480
 
3173
3481
 
3174
3482
 
3483
+
3484
+
3485
+
3486
+
3487
+
3488
+
3489
+
3175
3490
 
3176
3491
 
3177
3492
 
@@ -3573,6 +3888,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3573
3888
 
3574
3889
 
3575
3890
 
3891
+
3892
+
3893
+
3894
+
3895
+
3896
+
3897
+
3576
3898
 
3577
3899
 
3578
3900
 
@@ -3615,6 +3937,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3615
3937
 
3616
3938
 
3617
3939
 
3940
+
3941
+
3942
+
3943
+
3944
+
3945
+
3946
+
3618
3947
 
3619
3948
 
3620
3949
 
@@ -3660,6 +3989,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3660
3989
 
3661
3990
 
3662
3991
 
3992
+
3993
+
3994
+
3995
+
3996
+
3997
+
3998
+
3663
3999
 
3664
4000
 
3665
4001
 
@@ -3713,6 +4049,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3713
4049
 
3714
4050
 
3715
4051
 
4052
+
4053
+
4054
+
4055
+
4056
+
4057
+
4058
+
3716
4059
 
3717
4060
 
3718
4061
 
@@ -3791,6 +4134,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3791
4134
 
3792
4135
 
3793
4136
 
4137
+
4138
+
4139
+
4140
+
4141
+
4142
+
4143
+
3794
4144
 
3795
4145
 
3796
4146
 
@@ -3854,6 +4204,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3854
4204
 
3855
4205
 
3856
4206
 
4207
+
4208
+
4209
+
4210
+
4211
+
4212
+
4213
+
3857
4214
 
3858
4215
 
3859
4216
 
@@ -3900,6 +4257,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3900
4257
 
3901
4258
 
3902
4259
 
4260
+
4261
+
4262
+
4263
+
4264
+
4265
+
4266
+
3903
4267
 
3904
4268
 
3905
4269
 
@@ -3966,6 +4330,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3966
4330
 
3967
4331
 
3968
4332
 
4333
+
4334
+
4335
+
4336
+
4337
+
4338
+
4339
+
3969
4340
 
3970
4341
 
3971
4342
 
@@ -4012,6 +4383,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4012
4383
 
4013
4384
 
4014
4385
 
4386
+
4387
+
4388
+
4389
+
4390
+
4391
+
4392
+
4015
4393
 
4016
4394
 
4017
4395
 
@@ -4060,6 +4438,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4060
4438
 
4061
4439
 
4062
4440
 
4441
+
4442
+
4443
+
4444
+
4445
+
4446
+
4447
+
4063
4448
 
4064
4449
 
4065
4450
 
@@ -4106,6 +4491,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4106
4491
 
4107
4492
 
4108
4493
 
4494
+
4495
+
4496
+
4497
+
4498
+
4499
+
4500
+
4109
4501
 
4110
4502
 
4111
4503
 
@@ -4155,6 +4547,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4155
4547
 
4156
4548
 
4157
4549
 
4550
+
4551
+
4552
+
4553
+
4554
+
4555
+
4556
+
4158
4557
 
4159
4558
 
4160
4559
 
@@ -4209,6 +4608,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4209
4608
 
4210
4609
 
4211
4610
 
4611
+
4612
+
4613
+
4614
+
4615
+
4616
+
4617
+
4212
4618
 
4213
4619
 
4214
4620
 
@@ -4261,6 +4667,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4261
4667
 
4262
4668
 
4263
4669
 
4670
+
4671
+
4672
+
4673
+
4674
+
4675
+
4676
+
4264
4677
 
4265
4678
 
4266
4679
 
@@ -4312,6 +4725,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4312
4725
 
4313
4726
 
4314
4727
 
4728
+
4729
+
4730
+
4731
+
4732
+
4733
+
4734
+
4315
4735
 
4316
4736
 
4317
4737
 
@@ -4369,6 +4789,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4369
4789
 
4370
4790
 
4371
4791
 
4792
+
4793
+
4794
+
4795
+
4796
+
4797
+
4798
+
4372
4799
 
4373
4800
 
4374
4801
 
@@ -4434,6 +4861,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4434
4861
 
4435
4862
 
4436
4863
 
4864
+
4865
+
4866
+
4867
+
4868
+
4869
+
4870
+
4437
4871
 
4438
4872
 
4439
4873
 
@@ -4483,6 +4917,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4483
4917
 
4484
4918
 
4485
4919
 
4920
+
4921
+
4922
+
4923
+
4924
+
4925
+
4926
+
4486
4927
 
4487
4928
 
4488
4929