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
@@ -190,6 +190,35 @@ var _IterableElementBase = class _IterableElementBase {
190
190
  for (const ele of this) if (ele === element) return true;
191
191
  return false;
192
192
  }
193
+ /**
194
+ * Check whether a value exists (Array-compatible alias for `has`).
195
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
196
+ * @param element - Element to search for (uses `===`).
197
+ * @returns `true` if found.
198
+ */
199
+ includes(element) {
200
+ return this.has(element);
201
+ }
202
+ /**
203
+ * Return an iterator of `[index, value]` pairs (Array-compatible).
204
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
205
+ */
206
+ *entries() {
207
+ let index = 0;
208
+ for (const value of this) {
209
+ yield [index++, value];
210
+ }
211
+ }
212
+ /**
213
+ * Return an iterator of numeric indices (Array-compatible).
214
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
215
+ */
216
+ *keys() {
217
+ let index = 0;
218
+ for (const _ of this) {
219
+ yield index++;
220
+ }
221
+ }
193
222
  /**
194
223
  * Reduces all elements to a single accumulated value.
195
224
  *
@@ -498,6 +527,16 @@ var _LinearBase = class _LinearBase extends IterableElementBase {
498
527
  }
499
528
  return this;
500
529
  }
530
+ /**
531
+ * Return a new instance of the same type with elements in reverse order (non-mutating).
532
+ * @remarks Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
533
+ * @returns A new reversed instance.
534
+ */
535
+ toReversed() {
536
+ const cloned = this.clone();
537
+ cloned.reverse();
538
+ return cloned;
539
+ }
501
540
  };
502
541
  __name(_LinearBase, "LinearBase");
503
542
  var LinearBase = _LinearBase;
@@ -788,6 +827,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
788
827
 
789
828
 
790
829
 
830
+
831
+
832
+
833
+
834
+
835
+
836
+
791
837
 
792
838
 
793
839
 
@@ -855,6 +901,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
855
901
 
856
902
 
857
903
 
904
+
905
+
906
+
907
+
908
+
909
+
910
+
858
911
 
859
912
 
860
913
 
@@ -928,6 +981,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
928
981
 
929
982
 
930
983
 
984
+
985
+
986
+
987
+
988
+
989
+
990
+
931
991
 
932
992
 
933
993
 
@@ -982,6 +1042,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
982
1042
 
983
1043
 
984
1044
 
1045
+
1046
+
1047
+
1048
+
1049
+
1050
+
1051
+
985
1052
 
986
1053
 
987
1054
 
@@ -1097,6 +1164,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1097
1164
 
1098
1165
 
1099
1166
 
1167
+
1168
+
1169
+
1170
+
1171
+
1172
+
1173
+
1100
1174
 
1101
1175
 
1102
1176
 
@@ -1156,6 +1230,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1156
1230
 
1157
1231
 
1158
1232
 
1233
+
1234
+
1235
+
1236
+
1237
+
1238
+
1239
+
1159
1240
 
1160
1241
 
1161
1242
 
@@ -1204,6 +1285,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1204
1285
 
1205
1286
 
1206
1287
 
1288
+
1289
+
1290
+
1291
+
1292
+
1293
+
1294
+
1207
1295
 
1208
1296
 
1209
1297
 
@@ -1258,6 +1346,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1258
1346
 
1259
1347
 
1260
1348
 
1349
+
1350
+
1351
+
1352
+
1353
+
1354
+
1355
+
1261
1356
 
1262
1357
 
1263
1358
 
@@ -1317,6 +1412,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1317
1412
 
1318
1413
 
1319
1414
 
1415
+
1416
+
1417
+
1418
+
1419
+
1420
+
1421
+
1320
1422
 
1321
1423
 
1322
1424
 
@@ -1384,6 +1486,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1384
1486
 
1385
1487
 
1386
1488
 
1489
+
1490
+
1491
+
1492
+
1493
+
1494
+
1495
+
1387
1496
 
1388
1497
 
1389
1498
 
@@ -1428,6 +1537,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1428
1537
 
1429
1538
 
1430
1539
 
1540
+
1541
+
1542
+
1543
+
1544
+
1545
+
1546
+
1431
1547
 
1432
1548
 
1433
1549
 
@@ -1478,6 +1594,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1478
1594
 
1479
1595
 
1480
1596
 
1597
+
1598
+
1599
+
1600
+
1601
+
1602
+
1603
+
1481
1604
 
1482
1605
 
1483
1606
 
@@ -1694,6 +1817,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1694
1817
 
1695
1818
 
1696
1819
 
1820
+
1821
+
1822
+
1823
+
1824
+
1825
+
1826
+
1697
1827
 
1698
1828
 
1699
1829
 
@@ -1748,6 +1878,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1748
1878
 
1749
1879
 
1750
1880
 
1881
+
1882
+
1883
+
1884
+
1885
+
1886
+
1887
+
1751
1888
 
1752
1889
 
1753
1890
 
@@ -1830,6 +1967,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1830
1967
 
1831
1968
 
1832
1969
 
1970
+
1971
+
1972
+
1973
+
1974
+
1975
+
1976
+
1833
1977
 
1834
1978
 
1835
1979
 
@@ -2150,6 +2294,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2150
2294
 
2151
2295
 
2152
2296
 
2297
+
2298
+
2299
+
2300
+
2301
+
2302
+
2303
+
2153
2304
 
2154
2305
 
2155
2306
 
@@ -2219,6 +2370,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2219
2370
 
2220
2371
 
2221
2372
 
2373
+
2374
+
2375
+
2376
+
2377
+
2378
+
2379
+
2222
2380
 
2223
2381
 
2224
2382
 
@@ -2287,6 +2445,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2287
2445
 
2288
2446
 
2289
2447
 
2448
+
2449
+
2450
+
2451
+
2452
+
2453
+
2454
+
2290
2455
 
2291
2456
 
2292
2457
 
@@ -2346,6 +2511,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2346
2511
 
2347
2512
 
2348
2513
 
2514
+
2515
+
2516
+
2517
+
2518
+
2519
+
2520
+
2349
2521
 
2350
2522
 
2351
2523
 
@@ -2434,6 +2606,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2434
2606
 
2435
2607
 
2436
2608
 
2609
+
2610
+
2611
+
2612
+
2613
+
2614
+
2615
+
2437
2616
 
2438
2617
 
2439
2618
 
@@ -2483,6 +2662,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2483
2662
 
2484
2663
 
2485
2664
 
2665
+
2666
+
2667
+
2668
+
2669
+
2670
+
2671
+
2486
2672
 
2487
2673
 
2488
2674
 
@@ -2563,6 +2749,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2563
2749
 
2564
2750
 
2565
2751
 
2752
+
2753
+
2754
+
2755
+
2756
+
2757
+
2758
+
2566
2759
 
2567
2760
 
2568
2761
 
@@ -2671,6 +2864,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2671
2864
 
2672
2865
 
2673
2866
 
2867
+
2868
+
2869
+
2870
+
2871
+
2872
+
2873
+
2674
2874
 
2675
2875
 
2676
2876
 
@@ -2726,6 +2926,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2726
2926
 
2727
2927
 
2728
2928
 
2929
+
2930
+
2931
+
2932
+
2933
+
2934
+
2935
+
2729
2936
 
2730
2937
 
2731
2938
 
@@ -2783,6 +2990,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2783
2990
 
2784
2991
 
2785
2992
 
2993
+
2994
+
2995
+
2996
+
2997
+
2998
+
2999
+
2786
3000
 
2787
3001
 
2788
3002
 
@@ -2827,6 +3041,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2827
3041
 
2828
3042
 
2829
3043
 
3044
+
3045
+
3046
+
3047
+
3048
+
3049
+
3050
+
2830
3051
 
2831
3052
 
2832
3053
 
@@ -2875,6 +3096,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2875
3096
 
2876
3097
 
2877
3098
 
3099
+
3100
+
3101
+
3102
+
3103
+
3104
+
3105
+
2878
3106
 
2879
3107
 
2880
3108
 
@@ -2930,6 +3158,10 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2930
3158
 
2931
3159
 
2932
3160
 
3161
+
3162
+
3163
+
3164
+
2933
3165
 
2934
3166
 
2935
3167
 
@@ -2938,11 +3170,31 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2938
3170
  * @example
2939
3171
  * // Find value scanning from tail
2940
3172
  * const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
2941
- * // getBackward scans from tail to head, returns first match
2942
- * const found = list.getBackward(node => node.value < 4);
3173
+ * // findLast scans from tail to head, returns first match
3174
+ * const found = list.findLast(node => node.value < 4);
2943
3175
  * console.log(found); // 3;
2944
3176
  */
3177
+ /**
3178
+ * @deprecated Use `findLast` instead. Will be removed in a future major version.
3179
+ */
2945
3180
  getBackward(elementNodeOrPredicate) {
3181
+ return this.findLast(elementNodeOrPredicate);
3182
+ }
3183
+ /**
3184
+ * Find the first value matching a predicate scanning backward (tail → head).
3185
+ * @remarks Time O(N), Space O(1)
3186
+ * @param elementNodeOrPredicate - Element, node, or predicate to match.
3187
+ * @returns Matching value or undefined.
3188
+
3189
+
3190
+ * @example
3191
+ * // Find value scanning from tail
3192
+ * const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
3193
+ * // findLast scans from tail to head, returns first match
3194
+ * const found = list.findLast(node => node.value < 4);
3195
+ * console.log(found); // 3;
3196
+ */
3197
+ findLast(elementNodeOrPredicate) {
2946
3198
  const predicate = this._ensurePredicate(elementNodeOrPredicate);
2947
3199
  let current = this.tail;
2948
3200
  while (current) {
@@ -2951,6 +3203,22 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2951
3203
  }
2952
3204
  return void 0;
2953
3205
  }
3206
+ /**
3207
+ * Find the index of the last value matching a predicate (scans tail → head).
3208
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
3209
+ * @param predicate - Function called with (value, index, list).
3210
+ * @returns Matching index, or -1 if not found.
3211
+ */
3212
+ findLastIndex(predicate) {
3213
+ let current = this.tail;
3214
+ let index = this.length - 1;
3215
+ while (current) {
3216
+ if (predicate(current.value, index, this)) return index;
3217
+ current = current.prev;
3218
+ index--;
3219
+ }
3220
+ return -1;
3221
+ }
2954
3222
  /**
2955
3223
  * Reverse the list in place.
2956
3224
  * @remarks Time O(N), Space O(1)
@@ -2982,6 +3250,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2982
3250
 
2983
3251
 
2984
3252
 
3253
+
3254
+
3255
+
3256
+
3257
+
3258
+
3259
+
2985
3260
 
2986
3261
 
2987
3262
 
@@ -3006,6 +3281,25 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
3006
3281
  }
3007
3282
  return this;
3008
3283
  }
3284
+ /**
3285
+ * Delete the first element that satisfies a predicate.
3286
+ * @remarks Time O(N), Space O(1)
3287
+ * @param predicate - Function (value, index, list) → boolean to decide deletion.
3288
+ * @returns True if a match was removed.
3289
+ */
3290
+ deleteWhere(predicate) {
3291
+ let current = this.head;
3292
+ let index = 0;
3293
+ while (current) {
3294
+ if (predicate(current.value, index, this)) {
3295
+ this.delete(current);
3296
+ return true;
3297
+ }
3298
+ current = current.next;
3299
+ index++;
3300
+ }
3301
+ return false;
3302
+ }
3009
3303
  /**
3010
3304
  * Set the equality comparator used to compare values.
3011
3305
  * @remarks Time O(1), Space O(1)
@@ -3045,6 +3339,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
3045
3339
 
3046
3340
 
3047
3341
 
3342
+
3343
+
3344
+
3345
+
3346
+
3347
+
3348
+
3048
3349
 
3049
3350
 
3050
3351
 
@@ -3098,6 +3399,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
3098
3399
 
3099
3400
 
3100
3401
 
3402
+
3403
+
3404
+
3405
+
3406
+
3407
+
3408
+
3101
3409
 
3102
3410
 
3103
3411
 
@@ -3170,6 +3478,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
3170
3478
 
3171
3479
 
3172
3480
 
3481
+
3482
+
3483
+
3484
+
3485
+
3486
+
3487
+
3173
3488
 
3174
3489
 
3175
3490
 
@@ -3571,6 +3886,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3571
3886
 
3572
3887
 
3573
3888
 
3889
+
3890
+
3891
+
3892
+
3893
+
3894
+
3895
+
3574
3896
 
3575
3897
 
3576
3898
 
@@ -3613,6 +3935,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3613
3935
 
3614
3936
 
3615
3937
 
3938
+
3939
+
3940
+
3941
+
3942
+
3943
+
3944
+
3616
3945
 
3617
3946
 
3618
3947
 
@@ -3658,6 +3987,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3658
3987
 
3659
3988
 
3660
3989
 
3990
+
3991
+
3992
+
3993
+
3994
+
3995
+
3996
+
3661
3997
 
3662
3998
 
3663
3999
 
@@ -3711,6 +4047,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3711
4047
 
3712
4048
 
3713
4049
 
4050
+
4051
+
4052
+
4053
+
4054
+
4055
+
4056
+
3714
4057
 
3715
4058
 
3716
4059
 
@@ -3789,6 +4132,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3789
4132
 
3790
4133
 
3791
4134
 
4135
+
4136
+
4137
+
4138
+
4139
+
4140
+
4141
+
3792
4142
 
3793
4143
 
3794
4144
 
@@ -3852,6 +4202,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3852
4202
 
3853
4203
 
3854
4204
 
4205
+
4206
+
4207
+
4208
+
4209
+
4210
+
4211
+
3855
4212
 
3856
4213
 
3857
4214
 
@@ -3898,6 +4255,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3898
4255
 
3899
4256
 
3900
4257
 
4258
+
4259
+
4260
+
4261
+
4262
+
4263
+
4264
+
3901
4265
 
3902
4266
 
3903
4267
 
@@ -3964,6 +4328,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
3964
4328
 
3965
4329
 
3966
4330
 
4331
+
4332
+
4333
+
4334
+
4335
+
4336
+
4337
+
3967
4338
 
3968
4339
 
3969
4340
 
@@ -4010,6 +4381,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4010
4381
 
4011
4382
 
4012
4383
 
4384
+
4385
+
4386
+
4387
+
4388
+
4389
+
4390
+
4013
4391
 
4014
4392
 
4015
4393
 
@@ -4058,6 +4436,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4058
4436
 
4059
4437
 
4060
4438
 
4439
+
4440
+
4441
+
4442
+
4443
+
4444
+
4445
+
4061
4446
 
4062
4447
 
4063
4448
 
@@ -4104,6 +4489,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4104
4489
 
4105
4490
 
4106
4491
 
4492
+
4493
+
4494
+
4495
+
4496
+
4497
+
4498
+
4107
4499
 
4108
4500
 
4109
4501
 
@@ -4153,6 +4545,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4153
4545
 
4154
4546
 
4155
4547
 
4548
+
4549
+
4550
+
4551
+
4552
+
4553
+
4554
+
4156
4555
 
4157
4556
 
4158
4557
 
@@ -4207,6 +4606,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4207
4606
 
4208
4607
 
4209
4608
 
4609
+
4610
+
4611
+
4612
+
4613
+
4614
+
4615
+
4210
4616
 
4211
4617
 
4212
4618
 
@@ -4259,6 +4665,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4259
4665
 
4260
4666
 
4261
4667
 
4668
+
4669
+
4670
+
4671
+
4672
+
4673
+
4674
+
4262
4675
 
4263
4676
 
4264
4677
 
@@ -4310,6 +4723,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4310
4723
 
4311
4724
 
4312
4725
 
4726
+
4727
+
4728
+
4729
+
4730
+
4731
+
4732
+
4313
4733
 
4314
4734
 
4315
4735
 
@@ -4367,6 +4787,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4367
4787
 
4368
4788
 
4369
4789
 
4790
+
4791
+
4792
+
4793
+
4794
+
4795
+
4796
+
4370
4797
 
4371
4798
 
4372
4799
 
@@ -4432,6 +4859,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4432
4859
 
4433
4860
 
4434
4861
 
4862
+
4863
+
4864
+
4865
+
4866
+
4867
+
4868
+
4435
4869
 
4436
4870
 
4437
4871
 
@@ -4481,6 +4915,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
4481
4915
 
4482
4916
 
4483
4917
 
4918
+
4919
+
4920
+
4921
+
4922
+
4923
+
4924
+
4484
4925
 
4485
4926
 
4486
4927