linked-list-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.
- package/dist/cjs/index.cjs +443 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +443 -2
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +443 -2
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +443 -2
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/data-structures/base/iterable-element-base.d.ts +17 -0
- package/dist/types/data-structures/base/linear-base.d.ts +6 -0
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +86 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +98 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +191 -15
- package/dist/types/data-structures/binary-tree/bst.d.ts +171 -3
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +136 -8
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +42 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +1061 -167
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1232 -355
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +916 -194
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +1078 -141
- package/dist/types/data-structures/graph/directed-graph.d.ts +70 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +63 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +84 -6
- package/dist/types/data-structures/heap/heap.d.ts +140 -12
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +150 -2
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +106 -1
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +126 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +56 -0
- package/dist/types/data-structures/queue/deque.d.ts +171 -0
- package/dist/types/data-structures/queue/queue.d.ts +97 -0
- package/dist/types/data-structures/stack/stack.d.ts +72 -2
- package/dist/types/data-structures/trie/trie.d.ts +84 -0
- package/dist/types/interfaces/binary-tree.d.ts +2 -3
- package/dist/umd/linked-list-typed.js +443 -2
- package/dist/umd/linked-list-typed.js.map +1 -1
- package/dist/umd/linked-list-typed.min.js +1 -1
- package/dist/umd/linked-list-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/data-structures/base/iterable-element-base.ts +32 -0
- package/src/data-structures/base/linear-base.ts +11 -0
- package/src/data-structures/binary-tree/avl-tree.ts +88 -5
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +98 -0
- package/src/data-structures/binary-tree/binary-tree.ts +242 -81
- package/src/data-structures/binary-tree/bst.ts +173 -7
- package/src/data-structures/binary-tree/red-black-tree.ts +139 -15
- package/src/data-structures/binary-tree/segment-tree.ts +42 -0
- package/src/data-structures/binary-tree/tree-map.ts +948 -36
- package/src/data-structures/binary-tree/tree-multi-map.ts +893 -13
- package/src/data-structures/binary-tree/tree-multi-set.ts +761 -33
- package/src/data-structures/binary-tree/tree-set.ts +1260 -251
- package/src/data-structures/graph/directed-graph.ts +71 -1
- package/src/data-structures/graph/undirected-graph.ts +64 -1
- package/src/data-structures/hash/hash-map.ts +100 -12
- package/src/data-structures/heap/heap.ts +149 -19
- package/src/data-structures/linked-list/doubly-linked-list.ts +178 -2
- package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
- package/src/data-structures/linked-list/skip-linked-list.ts +126 -0
- package/src/data-structures/matrix/matrix.ts +56 -0
- package/src/data-structures/queue/deque.ts +187 -0
- package/src/data-structures/queue/queue.ts +109 -0
- package/src/data-structures/stack/stack.ts +75 -5
- package/src/data-structures/trie/trie.ts +84 -0
- package/src/interfaces/binary-tree.ts +1 -9
|
@@ -215,6 +215,35 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
215
215
|
for (const ele of this) if (ele === element) return true;
|
|
216
216
|
return false;
|
|
217
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Check whether a value exists (Array-compatible alias for `has`).
|
|
220
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
221
|
+
* @param element - Element to search for (uses `===`).
|
|
222
|
+
* @returns `true` if found.
|
|
223
|
+
*/
|
|
224
|
+
includes(element) {
|
|
225
|
+
return this.has(element);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
229
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
230
|
+
*/
|
|
231
|
+
*entries() {
|
|
232
|
+
let index = 0;
|
|
233
|
+
for (const value of this) {
|
|
234
|
+
yield [index++, value];
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Return an iterator of numeric indices (Array-compatible).
|
|
239
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
240
|
+
*/
|
|
241
|
+
*keys() {
|
|
242
|
+
let index = 0;
|
|
243
|
+
for (const _ of this) {
|
|
244
|
+
yield index++;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
218
247
|
/**
|
|
219
248
|
* Reduces all elements to a single accumulated value.
|
|
220
249
|
*
|
|
@@ -523,6 +552,16 @@ var _LinearBase = class _LinearBase extends IterableElementBase {
|
|
|
523
552
|
}
|
|
524
553
|
return this;
|
|
525
554
|
}
|
|
555
|
+
/**
|
|
556
|
+
* Return a new instance of the same type with elements in reverse order (non-mutating).
|
|
557
|
+
* @remarks Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
|
|
558
|
+
* @returns A new reversed instance.
|
|
559
|
+
*/
|
|
560
|
+
toReversed() {
|
|
561
|
+
const cloned = this.clone();
|
|
562
|
+
cloned.reverse();
|
|
563
|
+
return cloned;
|
|
564
|
+
}
|
|
526
565
|
};
|
|
527
566
|
__name(_LinearBase, "LinearBase");
|
|
528
567
|
var LinearBase = _LinearBase;
|
|
@@ -813,6 +852,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
813
852
|
|
|
814
853
|
|
|
815
854
|
|
|
855
|
+
|
|
856
|
+
|
|
857
|
+
|
|
858
|
+
|
|
859
|
+
|
|
860
|
+
|
|
861
|
+
|
|
816
862
|
|
|
817
863
|
|
|
818
864
|
|
|
@@ -880,6 +926,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
880
926
|
|
|
881
927
|
|
|
882
928
|
|
|
929
|
+
|
|
930
|
+
|
|
931
|
+
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
|
|
935
|
+
|
|
883
936
|
|
|
884
937
|
|
|
885
938
|
|
|
@@ -953,6 +1006,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
953
1006
|
|
|
954
1007
|
|
|
955
1008
|
|
|
1009
|
+
|
|
1010
|
+
|
|
1011
|
+
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
|
|
1015
|
+
|
|
956
1016
|
|
|
957
1017
|
|
|
958
1018
|
|
|
@@ -1007,6 +1067,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1007
1067
|
|
|
1008
1068
|
|
|
1009
1069
|
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
|
|
1073
|
+
|
|
1074
|
+
|
|
1075
|
+
|
|
1076
|
+
|
|
1010
1077
|
|
|
1011
1078
|
|
|
1012
1079
|
|
|
@@ -1122,6 +1189,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1122
1189
|
|
|
1123
1190
|
|
|
1124
1191
|
|
|
1192
|
+
|
|
1193
|
+
|
|
1194
|
+
|
|
1195
|
+
|
|
1196
|
+
|
|
1197
|
+
|
|
1198
|
+
|
|
1125
1199
|
|
|
1126
1200
|
|
|
1127
1201
|
|
|
@@ -1181,6 +1255,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1181
1255
|
|
|
1182
1256
|
|
|
1183
1257
|
|
|
1258
|
+
|
|
1259
|
+
|
|
1260
|
+
|
|
1261
|
+
|
|
1262
|
+
|
|
1263
|
+
|
|
1264
|
+
|
|
1184
1265
|
|
|
1185
1266
|
|
|
1186
1267
|
|
|
@@ -1229,6 +1310,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1229
1310
|
|
|
1230
1311
|
|
|
1231
1312
|
|
|
1313
|
+
|
|
1314
|
+
|
|
1315
|
+
|
|
1316
|
+
|
|
1317
|
+
|
|
1318
|
+
|
|
1319
|
+
|
|
1232
1320
|
|
|
1233
1321
|
|
|
1234
1322
|
|
|
@@ -1283,6 +1371,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1283
1371
|
|
|
1284
1372
|
|
|
1285
1373
|
|
|
1374
|
+
|
|
1375
|
+
|
|
1376
|
+
|
|
1377
|
+
|
|
1378
|
+
|
|
1379
|
+
|
|
1380
|
+
|
|
1286
1381
|
|
|
1287
1382
|
|
|
1288
1383
|
|
|
@@ -1342,6 +1437,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1342
1437
|
|
|
1343
1438
|
|
|
1344
1439
|
|
|
1440
|
+
|
|
1441
|
+
|
|
1442
|
+
|
|
1443
|
+
|
|
1444
|
+
|
|
1445
|
+
|
|
1446
|
+
|
|
1345
1447
|
|
|
1346
1448
|
|
|
1347
1449
|
|
|
@@ -1409,6 +1511,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1409
1511
|
|
|
1410
1512
|
|
|
1411
1513
|
|
|
1514
|
+
|
|
1515
|
+
|
|
1516
|
+
|
|
1517
|
+
|
|
1518
|
+
|
|
1519
|
+
|
|
1520
|
+
|
|
1412
1521
|
|
|
1413
1522
|
|
|
1414
1523
|
|
|
@@ -1453,6 +1562,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1453
1562
|
|
|
1454
1563
|
|
|
1455
1564
|
|
|
1565
|
+
|
|
1566
|
+
|
|
1567
|
+
|
|
1568
|
+
|
|
1569
|
+
|
|
1570
|
+
|
|
1571
|
+
|
|
1456
1572
|
|
|
1457
1573
|
|
|
1458
1574
|
|
|
@@ -1503,6 +1619,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1503
1619
|
|
|
1504
1620
|
|
|
1505
1621
|
|
|
1622
|
+
|
|
1623
|
+
|
|
1624
|
+
|
|
1625
|
+
|
|
1626
|
+
|
|
1627
|
+
|
|
1628
|
+
|
|
1506
1629
|
|
|
1507
1630
|
|
|
1508
1631
|
|
|
@@ -1719,6 +1842,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1719
1842
|
|
|
1720
1843
|
|
|
1721
1844
|
|
|
1845
|
+
|
|
1846
|
+
|
|
1847
|
+
|
|
1848
|
+
|
|
1849
|
+
|
|
1850
|
+
|
|
1851
|
+
|
|
1722
1852
|
|
|
1723
1853
|
|
|
1724
1854
|
|
|
@@ -1773,6 +1903,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1773
1903
|
|
|
1774
1904
|
|
|
1775
1905
|
|
|
1906
|
+
|
|
1907
|
+
|
|
1908
|
+
|
|
1909
|
+
|
|
1910
|
+
|
|
1911
|
+
|
|
1912
|
+
|
|
1776
1913
|
|
|
1777
1914
|
|
|
1778
1915
|
|
|
@@ -1855,6 +1992,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1855
1992
|
|
|
1856
1993
|
|
|
1857
1994
|
|
|
1995
|
+
|
|
1996
|
+
|
|
1997
|
+
|
|
1998
|
+
|
|
1999
|
+
|
|
2000
|
+
|
|
2001
|
+
|
|
1858
2002
|
|
|
1859
2003
|
|
|
1860
2004
|
|
|
@@ -2175,6 +2319,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2175
2319
|
|
|
2176
2320
|
|
|
2177
2321
|
|
|
2322
|
+
|
|
2323
|
+
|
|
2324
|
+
|
|
2325
|
+
|
|
2326
|
+
|
|
2327
|
+
|
|
2328
|
+
|
|
2178
2329
|
|
|
2179
2330
|
|
|
2180
2331
|
|
|
@@ -2244,6 +2395,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2244
2395
|
|
|
2245
2396
|
|
|
2246
2397
|
|
|
2398
|
+
|
|
2399
|
+
|
|
2400
|
+
|
|
2401
|
+
|
|
2402
|
+
|
|
2403
|
+
|
|
2404
|
+
|
|
2247
2405
|
|
|
2248
2406
|
|
|
2249
2407
|
|
|
@@ -2312,6 +2470,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2312
2470
|
|
|
2313
2471
|
|
|
2314
2472
|
|
|
2473
|
+
|
|
2474
|
+
|
|
2475
|
+
|
|
2476
|
+
|
|
2477
|
+
|
|
2478
|
+
|
|
2479
|
+
|
|
2315
2480
|
|
|
2316
2481
|
|
|
2317
2482
|
|
|
@@ -2371,6 +2536,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2371
2536
|
|
|
2372
2537
|
|
|
2373
2538
|
|
|
2539
|
+
|
|
2540
|
+
|
|
2541
|
+
|
|
2542
|
+
|
|
2543
|
+
|
|
2544
|
+
|
|
2545
|
+
|
|
2374
2546
|
|
|
2375
2547
|
|
|
2376
2548
|
|
|
@@ -2459,6 +2631,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2459
2631
|
|
|
2460
2632
|
|
|
2461
2633
|
|
|
2634
|
+
|
|
2635
|
+
|
|
2636
|
+
|
|
2637
|
+
|
|
2638
|
+
|
|
2639
|
+
|
|
2640
|
+
|
|
2462
2641
|
|
|
2463
2642
|
|
|
2464
2643
|
|
|
@@ -2508,6 +2687,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2508
2687
|
|
|
2509
2688
|
|
|
2510
2689
|
|
|
2690
|
+
|
|
2691
|
+
|
|
2692
|
+
|
|
2693
|
+
|
|
2694
|
+
|
|
2695
|
+
|
|
2696
|
+
|
|
2511
2697
|
|
|
2512
2698
|
|
|
2513
2699
|
|
|
@@ -2588,6 +2774,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2588
2774
|
|
|
2589
2775
|
|
|
2590
2776
|
|
|
2777
|
+
|
|
2778
|
+
|
|
2779
|
+
|
|
2780
|
+
|
|
2781
|
+
|
|
2782
|
+
|
|
2783
|
+
|
|
2591
2784
|
|
|
2592
2785
|
|
|
2593
2786
|
|
|
@@ -2696,6 +2889,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2696
2889
|
|
|
2697
2890
|
|
|
2698
2891
|
|
|
2892
|
+
|
|
2893
|
+
|
|
2894
|
+
|
|
2895
|
+
|
|
2896
|
+
|
|
2897
|
+
|
|
2898
|
+
|
|
2699
2899
|
|
|
2700
2900
|
|
|
2701
2901
|
|
|
@@ -2751,6 +2951,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2751
2951
|
|
|
2752
2952
|
|
|
2753
2953
|
|
|
2954
|
+
|
|
2955
|
+
|
|
2956
|
+
|
|
2957
|
+
|
|
2958
|
+
|
|
2959
|
+
|
|
2960
|
+
|
|
2754
2961
|
|
|
2755
2962
|
|
|
2756
2963
|
|
|
@@ -2808,6 +3015,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2808
3015
|
|
|
2809
3016
|
|
|
2810
3017
|
|
|
3018
|
+
|
|
3019
|
+
|
|
3020
|
+
|
|
3021
|
+
|
|
3022
|
+
|
|
3023
|
+
|
|
3024
|
+
|
|
2811
3025
|
|
|
2812
3026
|
|
|
2813
3027
|
|
|
@@ -2852,6 +3066,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2852
3066
|
|
|
2853
3067
|
|
|
2854
3068
|
|
|
3069
|
+
|
|
3070
|
+
|
|
3071
|
+
|
|
3072
|
+
|
|
3073
|
+
|
|
3074
|
+
|
|
3075
|
+
|
|
2855
3076
|
|
|
2856
3077
|
|
|
2857
3078
|
|
|
@@ -2900,6 +3121,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2900
3121
|
|
|
2901
3122
|
|
|
2902
3123
|
|
|
3124
|
+
|
|
3125
|
+
|
|
3126
|
+
|
|
3127
|
+
|
|
3128
|
+
|
|
3129
|
+
|
|
3130
|
+
|
|
2903
3131
|
|
|
2904
3132
|
|
|
2905
3133
|
|
|
@@ -2955,6 +3183,10 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2955
3183
|
|
|
2956
3184
|
|
|
2957
3185
|
|
|
3186
|
+
|
|
3187
|
+
|
|
3188
|
+
|
|
3189
|
+
|
|
2958
3190
|
|
|
2959
3191
|
|
|
2960
3192
|
|
|
@@ -2963,11 +3195,31 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2963
3195
|
* @example
|
|
2964
3196
|
* // Find value scanning from tail
|
|
2965
3197
|
* const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
|
|
2966
|
-
* //
|
|
2967
|
-
* const found = list.
|
|
3198
|
+
* // findLast scans from tail to head, returns first match
|
|
3199
|
+
* const found = list.findLast(node => node.value < 4);
|
|
2968
3200
|
* console.log(found); // 3;
|
|
2969
3201
|
*/
|
|
3202
|
+
/**
|
|
3203
|
+
* @deprecated Use `findLast` instead. Will be removed in a future major version.
|
|
3204
|
+
*/
|
|
2970
3205
|
getBackward(elementNodeOrPredicate) {
|
|
3206
|
+
return this.findLast(elementNodeOrPredicate);
|
|
3207
|
+
}
|
|
3208
|
+
/**
|
|
3209
|
+
* Find the first value matching a predicate scanning backward (tail → head).
|
|
3210
|
+
* @remarks Time O(N), Space O(1)
|
|
3211
|
+
* @param elementNodeOrPredicate - Element, node, or predicate to match.
|
|
3212
|
+
* @returns Matching value or undefined.
|
|
3213
|
+
|
|
3214
|
+
|
|
3215
|
+
* @example
|
|
3216
|
+
* // Find value scanning from tail
|
|
3217
|
+
* const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
|
|
3218
|
+
* // findLast scans from tail to head, returns first match
|
|
3219
|
+
* const found = list.findLast(node => node.value < 4);
|
|
3220
|
+
* console.log(found); // 3;
|
|
3221
|
+
*/
|
|
3222
|
+
findLast(elementNodeOrPredicate) {
|
|
2971
3223
|
const predicate = this._ensurePredicate(elementNodeOrPredicate);
|
|
2972
3224
|
let current = this.tail;
|
|
2973
3225
|
while (current) {
|
|
@@ -2976,6 +3228,22 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2976
3228
|
}
|
|
2977
3229
|
return void 0;
|
|
2978
3230
|
}
|
|
3231
|
+
/**
|
|
3232
|
+
* Find the index of the last value matching a predicate (scans tail → head).
|
|
3233
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
3234
|
+
* @param predicate - Function called with (value, index, list).
|
|
3235
|
+
* @returns Matching index, or -1 if not found.
|
|
3236
|
+
*/
|
|
3237
|
+
findLastIndex(predicate) {
|
|
3238
|
+
let current = this.tail;
|
|
3239
|
+
let index = this.length - 1;
|
|
3240
|
+
while (current) {
|
|
3241
|
+
if (predicate(current.value, index, this)) return index;
|
|
3242
|
+
current = current.prev;
|
|
3243
|
+
index--;
|
|
3244
|
+
}
|
|
3245
|
+
return -1;
|
|
3246
|
+
}
|
|
2979
3247
|
/**
|
|
2980
3248
|
* Reverse the list in place.
|
|
2981
3249
|
* @remarks Time O(N), Space O(1)
|
|
@@ -3007,6 +3275,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
3007
3275
|
|
|
3008
3276
|
|
|
3009
3277
|
|
|
3278
|
+
|
|
3279
|
+
|
|
3280
|
+
|
|
3281
|
+
|
|
3282
|
+
|
|
3283
|
+
|
|
3284
|
+
|
|
3010
3285
|
|
|
3011
3286
|
|
|
3012
3287
|
|
|
@@ -3031,6 +3306,25 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
3031
3306
|
}
|
|
3032
3307
|
return this;
|
|
3033
3308
|
}
|
|
3309
|
+
/**
|
|
3310
|
+
* Delete the first element that satisfies a predicate.
|
|
3311
|
+
* @remarks Time O(N), Space O(1)
|
|
3312
|
+
* @param predicate - Function (value, index, list) → boolean to decide deletion.
|
|
3313
|
+
* @returns True if a match was removed.
|
|
3314
|
+
*/
|
|
3315
|
+
deleteWhere(predicate) {
|
|
3316
|
+
let current = this.head;
|
|
3317
|
+
let index = 0;
|
|
3318
|
+
while (current) {
|
|
3319
|
+
if (predicate(current.value, index, this)) {
|
|
3320
|
+
this.delete(current);
|
|
3321
|
+
return true;
|
|
3322
|
+
}
|
|
3323
|
+
current = current.next;
|
|
3324
|
+
index++;
|
|
3325
|
+
}
|
|
3326
|
+
return false;
|
|
3327
|
+
}
|
|
3034
3328
|
/**
|
|
3035
3329
|
* Set the equality comparator used to compare values.
|
|
3036
3330
|
* @remarks Time O(1), Space O(1)
|
|
@@ -3070,6 +3364,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
3070
3364
|
|
|
3071
3365
|
|
|
3072
3366
|
|
|
3367
|
+
|
|
3368
|
+
|
|
3369
|
+
|
|
3370
|
+
|
|
3371
|
+
|
|
3372
|
+
|
|
3373
|
+
|
|
3073
3374
|
|
|
3074
3375
|
|
|
3075
3376
|
|
|
@@ -3123,6 +3424,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
3123
3424
|
|
|
3124
3425
|
|
|
3125
3426
|
|
|
3427
|
+
|
|
3428
|
+
|
|
3429
|
+
|
|
3430
|
+
|
|
3431
|
+
|
|
3432
|
+
|
|
3433
|
+
|
|
3126
3434
|
|
|
3127
3435
|
|
|
3128
3436
|
|
|
@@ -3195,6 +3503,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
3195
3503
|
|
|
3196
3504
|
|
|
3197
3505
|
|
|
3506
|
+
|
|
3507
|
+
|
|
3508
|
+
|
|
3509
|
+
|
|
3510
|
+
|
|
3511
|
+
|
|
3512
|
+
|
|
3198
3513
|
|
|
3199
3514
|
|
|
3200
3515
|
|
|
@@ -3596,6 +3911,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3596
3911
|
|
|
3597
3912
|
|
|
3598
3913
|
|
|
3914
|
+
|
|
3915
|
+
|
|
3916
|
+
|
|
3917
|
+
|
|
3918
|
+
|
|
3919
|
+
|
|
3920
|
+
|
|
3599
3921
|
|
|
3600
3922
|
|
|
3601
3923
|
|
|
@@ -3638,6 +3960,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3638
3960
|
|
|
3639
3961
|
|
|
3640
3962
|
|
|
3963
|
+
|
|
3964
|
+
|
|
3965
|
+
|
|
3966
|
+
|
|
3967
|
+
|
|
3968
|
+
|
|
3969
|
+
|
|
3641
3970
|
|
|
3642
3971
|
|
|
3643
3972
|
|
|
@@ -3683,6 +4012,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3683
4012
|
|
|
3684
4013
|
|
|
3685
4014
|
|
|
4015
|
+
|
|
4016
|
+
|
|
4017
|
+
|
|
4018
|
+
|
|
4019
|
+
|
|
4020
|
+
|
|
4021
|
+
|
|
3686
4022
|
|
|
3687
4023
|
|
|
3688
4024
|
|
|
@@ -3736,6 +4072,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3736
4072
|
|
|
3737
4073
|
|
|
3738
4074
|
|
|
4075
|
+
|
|
4076
|
+
|
|
4077
|
+
|
|
4078
|
+
|
|
4079
|
+
|
|
4080
|
+
|
|
4081
|
+
|
|
3739
4082
|
|
|
3740
4083
|
|
|
3741
4084
|
|
|
@@ -3814,6 +4157,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3814
4157
|
|
|
3815
4158
|
|
|
3816
4159
|
|
|
4160
|
+
|
|
4161
|
+
|
|
4162
|
+
|
|
4163
|
+
|
|
4164
|
+
|
|
4165
|
+
|
|
4166
|
+
|
|
3817
4167
|
|
|
3818
4168
|
|
|
3819
4169
|
|
|
@@ -3877,6 +4227,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3877
4227
|
|
|
3878
4228
|
|
|
3879
4229
|
|
|
4230
|
+
|
|
4231
|
+
|
|
4232
|
+
|
|
4233
|
+
|
|
4234
|
+
|
|
4235
|
+
|
|
4236
|
+
|
|
3880
4237
|
|
|
3881
4238
|
|
|
3882
4239
|
|
|
@@ -3923,6 +4280,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3923
4280
|
|
|
3924
4281
|
|
|
3925
4282
|
|
|
4283
|
+
|
|
4284
|
+
|
|
4285
|
+
|
|
4286
|
+
|
|
4287
|
+
|
|
4288
|
+
|
|
4289
|
+
|
|
3926
4290
|
|
|
3927
4291
|
|
|
3928
4292
|
|
|
@@ -3989,6 +4353,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3989
4353
|
|
|
3990
4354
|
|
|
3991
4355
|
|
|
4356
|
+
|
|
4357
|
+
|
|
4358
|
+
|
|
4359
|
+
|
|
4360
|
+
|
|
4361
|
+
|
|
4362
|
+
|
|
3992
4363
|
|
|
3993
4364
|
|
|
3994
4365
|
|
|
@@ -4035,6 +4406,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4035
4406
|
|
|
4036
4407
|
|
|
4037
4408
|
|
|
4409
|
+
|
|
4410
|
+
|
|
4411
|
+
|
|
4412
|
+
|
|
4413
|
+
|
|
4414
|
+
|
|
4415
|
+
|
|
4038
4416
|
|
|
4039
4417
|
|
|
4040
4418
|
|
|
@@ -4083,6 +4461,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4083
4461
|
|
|
4084
4462
|
|
|
4085
4463
|
|
|
4464
|
+
|
|
4465
|
+
|
|
4466
|
+
|
|
4467
|
+
|
|
4468
|
+
|
|
4469
|
+
|
|
4470
|
+
|
|
4086
4471
|
|
|
4087
4472
|
|
|
4088
4473
|
|
|
@@ -4129,6 +4514,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4129
4514
|
|
|
4130
4515
|
|
|
4131
4516
|
|
|
4517
|
+
|
|
4518
|
+
|
|
4519
|
+
|
|
4520
|
+
|
|
4521
|
+
|
|
4522
|
+
|
|
4523
|
+
|
|
4132
4524
|
|
|
4133
4525
|
|
|
4134
4526
|
|
|
@@ -4178,6 +4570,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4178
4570
|
|
|
4179
4571
|
|
|
4180
4572
|
|
|
4573
|
+
|
|
4574
|
+
|
|
4575
|
+
|
|
4576
|
+
|
|
4577
|
+
|
|
4578
|
+
|
|
4579
|
+
|
|
4181
4580
|
|
|
4182
4581
|
|
|
4183
4582
|
|
|
@@ -4232,6 +4631,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4232
4631
|
|
|
4233
4632
|
|
|
4234
4633
|
|
|
4634
|
+
|
|
4635
|
+
|
|
4636
|
+
|
|
4637
|
+
|
|
4638
|
+
|
|
4639
|
+
|
|
4640
|
+
|
|
4235
4641
|
|
|
4236
4642
|
|
|
4237
4643
|
|
|
@@ -4284,6 +4690,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4284
4690
|
|
|
4285
4691
|
|
|
4286
4692
|
|
|
4693
|
+
|
|
4694
|
+
|
|
4695
|
+
|
|
4696
|
+
|
|
4697
|
+
|
|
4698
|
+
|
|
4699
|
+
|
|
4287
4700
|
|
|
4288
4701
|
|
|
4289
4702
|
|
|
@@ -4335,6 +4748,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4335
4748
|
|
|
4336
4749
|
|
|
4337
4750
|
|
|
4751
|
+
|
|
4752
|
+
|
|
4753
|
+
|
|
4754
|
+
|
|
4755
|
+
|
|
4756
|
+
|
|
4757
|
+
|
|
4338
4758
|
|
|
4339
4759
|
|
|
4340
4760
|
|
|
@@ -4392,6 +4812,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4392
4812
|
|
|
4393
4813
|
|
|
4394
4814
|
|
|
4815
|
+
|
|
4816
|
+
|
|
4817
|
+
|
|
4818
|
+
|
|
4819
|
+
|
|
4820
|
+
|
|
4821
|
+
|
|
4395
4822
|
|
|
4396
4823
|
|
|
4397
4824
|
|
|
@@ -4457,6 +4884,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4457
4884
|
|
|
4458
4885
|
|
|
4459
4886
|
|
|
4887
|
+
|
|
4888
|
+
|
|
4889
|
+
|
|
4890
|
+
|
|
4891
|
+
|
|
4892
|
+
|
|
4893
|
+
|
|
4460
4894
|
|
|
4461
4895
|
|
|
4462
4896
|
|
|
@@ -4506,6 +4940,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4506
4940
|
|
|
4507
4941
|
|
|
4508
4942
|
|
|
4943
|
+
|
|
4944
|
+
|
|
4945
|
+
|
|
4946
|
+
|
|
4947
|
+
|
|
4948
|
+
|
|
4949
|
+
|
|
4509
4950
|
|
|
4510
4951
|
|
|
4511
4952
|
|