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
|
@@ -213,6 +213,35 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
213
213
|
for (const ele of this) if (ele === element) return true;
|
|
214
214
|
return false;
|
|
215
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* Check whether a value exists (Array-compatible alias for `has`).
|
|
218
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
219
|
+
* @param element - Element to search for (uses `===`).
|
|
220
|
+
* @returns `true` if found.
|
|
221
|
+
*/
|
|
222
|
+
includes(element) {
|
|
223
|
+
return this.has(element);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Return an iterator of `[index, value]` pairs (Array-compatible).
|
|
227
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
228
|
+
*/
|
|
229
|
+
*entries() {
|
|
230
|
+
let index = 0;
|
|
231
|
+
for (const value of this) {
|
|
232
|
+
yield [index++, value];
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Return an iterator of numeric indices (Array-compatible).
|
|
237
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1) per step.
|
|
238
|
+
*/
|
|
239
|
+
*keys() {
|
|
240
|
+
let index = 0;
|
|
241
|
+
for (const _ of this) {
|
|
242
|
+
yield index++;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
216
245
|
/**
|
|
217
246
|
* Reduces all elements to a single accumulated value.
|
|
218
247
|
*
|
|
@@ -521,6 +550,16 @@ var _LinearBase = class _LinearBase extends IterableElementBase {
|
|
|
521
550
|
}
|
|
522
551
|
return this;
|
|
523
552
|
}
|
|
553
|
+
/**
|
|
554
|
+
* Return a new instance of the same type with elements in reverse order (non-mutating).
|
|
555
|
+
* @remarks Provided for familiarity when migrating from Array (ES2023 `toReversed`). Time O(n), Space O(n).
|
|
556
|
+
* @returns A new reversed instance.
|
|
557
|
+
*/
|
|
558
|
+
toReversed() {
|
|
559
|
+
const cloned = this.clone();
|
|
560
|
+
cloned.reverse();
|
|
561
|
+
return cloned;
|
|
562
|
+
}
|
|
524
563
|
};
|
|
525
564
|
__name(_LinearBase, "LinearBase");
|
|
526
565
|
var LinearBase = _LinearBase;
|
|
@@ -811,6 +850,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
811
850
|
|
|
812
851
|
|
|
813
852
|
|
|
853
|
+
|
|
854
|
+
|
|
855
|
+
|
|
856
|
+
|
|
857
|
+
|
|
858
|
+
|
|
859
|
+
|
|
814
860
|
|
|
815
861
|
|
|
816
862
|
|
|
@@ -878,6 +924,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
878
924
|
|
|
879
925
|
|
|
880
926
|
|
|
927
|
+
|
|
928
|
+
|
|
929
|
+
|
|
930
|
+
|
|
931
|
+
|
|
932
|
+
|
|
933
|
+
|
|
881
934
|
|
|
882
935
|
|
|
883
936
|
|
|
@@ -951,6 +1004,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
951
1004
|
|
|
952
1005
|
|
|
953
1006
|
|
|
1007
|
+
|
|
1008
|
+
|
|
1009
|
+
|
|
1010
|
+
|
|
1011
|
+
|
|
1012
|
+
|
|
1013
|
+
|
|
954
1014
|
|
|
955
1015
|
|
|
956
1016
|
|
|
@@ -1005,6 +1065,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1005
1065
|
|
|
1006
1066
|
|
|
1007
1067
|
|
|
1068
|
+
|
|
1069
|
+
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
|
|
1073
|
+
|
|
1074
|
+
|
|
1008
1075
|
|
|
1009
1076
|
|
|
1010
1077
|
|
|
@@ -1120,6 +1187,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1120
1187
|
|
|
1121
1188
|
|
|
1122
1189
|
|
|
1190
|
+
|
|
1191
|
+
|
|
1192
|
+
|
|
1193
|
+
|
|
1194
|
+
|
|
1195
|
+
|
|
1196
|
+
|
|
1123
1197
|
|
|
1124
1198
|
|
|
1125
1199
|
|
|
@@ -1179,6 +1253,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1179
1253
|
|
|
1180
1254
|
|
|
1181
1255
|
|
|
1256
|
+
|
|
1257
|
+
|
|
1258
|
+
|
|
1259
|
+
|
|
1260
|
+
|
|
1261
|
+
|
|
1262
|
+
|
|
1182
1263
|
|
|
1183
1264
|
|
|
1184
1265
|
|
|
@@ -1227,6 +1308,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1227
1308
|
|
|
1228
1309
|
|
|
1229
1310
|
|
|
1311
|
+
|
|
1312
|
+
|
|
1313
|
+
|
|
1314
|
+
|
|
1315
|
+
|
|
1316
|
+
|
|
1317
|
+
|
|
1230
1318
|
|
|
1231
1319
|
|
|
1232
1320
|
|
|
@@ -1281,6 +1369,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1281
1369
|
|
|
1282
1370
|
|
|
1283
1371
|
|
|
1372
|
+
|
|
1373
|
+
|
|
1374
|
+
|
|
1375
|
+
|
|
1376
|
+
|
|
1377
|
+
|
|
1378
|
+
|
|
1284
1379
|
|
|
1285
1380
|
|
|
1286
1381
|
|
|
@@ -1340,6 +1435,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1340
1435
|
|
|
1341
1436
|
|
|
1342
1437
|
|
|
1438
|
+
|
|
1439
|
+
|
|
1440
|
+
|
|
1441
|
+
|
|
1442
|
+
|
|
1443
|
+
|
|
1444
|
+
|
|
1343
1445
|
|
|
1344
1446
|
|
|
1345
1447
|
|
|
@@ -1407,6 +1509,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1407
1509
|
|
|
1408
1510
|
|
|
1409
1511
|
|
|
1512
|
+
|
|
1513
|
+
|
|
1514
|
+
|
|
1515
|
+
|
|
1516
|
+
|
|
1517
|
+
|
|
1518
|
+
|
|
1410
1519
|
|
|
1411
1520
|
|
|
1412
1521
|
|
|
@@ -1451,6 +1560,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1451
1560
|
|
|
1452
1561
|
|
|
1453
1562
|
|
|
1563
|
+
|
|
1564
|
+
|
|
1565
|
+
|
|
1566
|
+
|
|
1567
|
+
|
|
1568
|
+
|
|
1569
|
+
|
|
1454
1570
|
|
|
1455
1571
|
|
|
1456
1572
|
|
|
@@ -1501,6 +1617,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1501
1617
|
|
|
1502
1618
|
|
|
1503
1619
|
|
|
1620
|
+
|
|
1621
|
+
|
|
1622
|
+
|
|
1623
|
+
|
|
1624
|
+
|
|
1625
|
+
|
|
1626
|
+
|
|
1504
1627
|
|
|
1505
1628
|
|
|
1506
1629
|
|
|
@@ -1717,6 +1840,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1717
1840
|
|
|
1718
1841
|
|
|
1719
1842
|
|
|
1843
|
+
|
|
1844
|
+
|
|
1845
|
+
|
|
1846
|
+
|
|
1847
|
+
|
|
1848
|
+
|
|
1849
|
+
|
|
1720
1850
|
|
|
1721
1851
|
|
|
1722
1852
|
|
|
@@ -1771,6 +1901,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1771
1901
|
|
|
1772
1902
|
|
|
1773
1903
|
|
|
1904
|
+
|
|
1905
|
+
|
|
1906
|
+
|
|
1907
|
+
|
|
1908
|
+
|
|
1909
|
+
|
|
1910
|
+
|
|
1774
1911
|
|
|
1775
1912
|
|
|
1776
1913
|
|
|
@@ -1853,6 +1990,13 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1853
1990
|
|
|
1854
1991
|
|
|
1855
1992
|
|
|
1993
|
+
|
|
1994
|
+
|
|
1995
|
+
|
|
1996
|
+
|
|
1997
|
+
|
|
1998
|
+
|
|
1999
|
+
|
|
1856
2000
|
|
|
1857
2001
|
|
|
1858
2002
|
|
|
@@ -2173,6 +2317,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2173
2317
|
|
|
2174
2318
|
|
|
2175
2319
|
|
|
2320
|
+
|
|
2321
|
+
|
|
2322
|
+
|
|
2323
|
+
|
|
2324
|
+
|
|
2325
|
+
|
|
2326
|
+
|
|
2176
2327
|
|
|
2177
2328
|
|
|
2178
2329
|
|
|
@@ -2242,6 +2393,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2242
2393
|
|
|
2243
2394
|
|
|
2244
2395
|
|
|
2396
|
+
|
|
2397
|
+
|
|
2398
|
+
|
|
2399
|
+
|
|
2400
|
+
|
|
2401
|
+
|
|
2402
|
+
|
|
2245
2403
|
|
|
2246
2404
|
|
|
2247
2405
|
|
|
@@ -2310,6 +2468,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2310
2468
|
|
|
2311
2469
|
|
|
2312
2470
|
|
|
2471
|
+
|
|
2472
|
+
|
|
2473
|
+
|
|
2474
|
+
|
|
2475
|
+
|
|
2476
|
+
|
|
2477
|
+
|
|
2313
2478
|
|
|
2314
2479
|
|
|
2315
2480
|
|
|
@@ -2369,6 +2534,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2369
2534
|
|
|
2370
2535
|
|
|
2371
2536
|
|
|
2537
|
+
|
|
2538
|
+
|
|
2539
|
+
|
|
2540
|
+
|
|
2541
|
+
|
|
2542
|
+
|
|
2543
|
+
|
|
2372
2544
|
|
|
2373
2545
|
|
|
2374
2546
|
|
|
@@ -2457,6 +2629,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2457
2629
|
|
|
2458
2630
|
|
|
2459
2631
|
|
|
2632
|
+
|
|
2633
|
+
|
|
2634
|
+
|
|
2635
|
+
|
|
2636
|
+
|
|
2637
|
+
|
|
2638
|
+
|
|
2460
2639
|
|
|
2461
2640
|
|
|
2462
2641
|
|
|
@@ -2506,6 +2685,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2506
2685
|
|
|
2507
2686
|
|
|
2508
2687
|
|
|
2688
|
+
|
|
2689
|
+
|
|
2690
|
+
|
|
2691
|
+
|
|
2692
|
+
|
|
2693
|
+
|
|
2694
|
+
|
|
2509
2695
|
|
|
2510
2696
|
|
|
2511
2697
|
|
|
@@ -2586,6 +2772,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2586
2772
|
|
|
2587
2773
|
|
|
2588
2774
|
|
|
2775
|
+
|
|
2776
|
+
|
|
2777
|
+
|
|
2778
|
+
|
|
2779
|
+
|
|
2780
|
+
|
|
2781
|
+
|
|
2589
2782
|
|
|
2590
2783
|
|
|
2591
2784
|
|
|
@@ -2694,6 +2887,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2694
2887
|
|
|
2695
2888
|
|
|
2696
2889
|
|
|
2890
|
+
|
|
2891
|
+
|
|
2892
|
+
|
|
2893
|
+
|
|
2894
|
+
|
|
2895
|
+
|
|
2896
|
+
|
|
2697
2897
|
|
|
2698
2898
|
|
|
2699
2899
|
|
|
@@ -2749,6 +2949,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2749
2949
|
|
|
2750
2950
|
|
|
2751
2951
|
|
|
2952
|
+
|
|
2953
|
+
|
|
2954
|
+
|
|
2955
|
+
|
|
2956
|
+
|
|
2957
|
+
|
|
2958
|
+
|
|
2752
2959
|
|
|
2753
2960
|
|
|
2754
2961
|
|
|
@@ -2806,6 +3013,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2806
3013
|
|
|
2807
3014
|
|
|
2808
3015
|
|
|
3016
|
+
|
|
3017
|
+
|
|
3018
|
+
|
|
3019
|
+
|
|
3020
|
+
|
|
3021
|
+
|
|
3022
|
+
|
|
2809
3023
|
|
|
2810
3024
|
|
|
2811
3025
|
|
|
@@ -2850,6 +3064,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2850
3064
|
|
|
2851
3065
|
|
|
2852
3066
|
|
|
3067
|
+
|
|
3068
|
+
|
|
3069
|
+
|
|
3070
|
+
|
|
3071
|
+
|
|
3072
|
+
|
|
3073
|
+
|
|
2853
3074
|
|
|
2854
3075
|
|
|
2855
3076
|
|
|
@@ -2898,6 +3119,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2898
3119
|
|
|
2899
3120
|
|
|
2900
3121
|
|
|
3122
|
+
|
|
3123
|
+
|
|
3124
|
+
|
|
3125
|
+
|
|
3126
|
+
|
|
3127
|
+
|
|
3128
|
+
|
|
2901
3129
|
|
|
2902
3130
|
|
|
2903
3131
|
|
|
@@ -2953,6 +3181,10 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2953
3181
|
|
|
2954
3182
|
|
|
2955
3183
|
|
|
3184
|
+
|
|
3185
|
+
|
|
3186
|
+
|
|
3187
|
+
|
|
2956
3188
|
|
|
2957
3189
|
|
|
2958
3190
|
|
|
@@ -2961,11 +3193,31 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2961
3193
|
* @example
|
|
2962
3194
|
* // Find value scanning from tail
|
|
2963
3195
|
* const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
|
|
2964
|
-
* //
|
|
2965
|
-
* const found = list.
|
|
3196
|
+
* // findLast scans from tail to head, returns first match
|
|
3197
|
+
* const found = list.findLast(node => node.value < 4);
|
|
2966
3198
|
* console.log(found); // 3;
|
|
2967
3199
|
*/
|
|
3200
|
+
/**
|
|
3201
|
+
* @deprecated Use `findLast` instead. Will be removed in a future major version.
|
|
3202
|
+
*/
|
|
2968
3203
|
getBackward(elementNodeOrPredicate) {
|
|
3204
|
+
return this.findLast(elementNodeOrPredicate);
|
|
3205
|
+
}
|
|
3206
|
+
/**
|
|
3207
|
+
* Find the first value matching a predicate scanning backward (tail → head).
|
|
3208
|
+
* @remarks Time O(N), Space O(1)
|
|
3209
|
+
* @param elementNodeOrPredicate - Element, node, or predicate to match.
|
|
3210
|
+
* @returns Matching value or undefined.
|
|
3211
|
+
|
|
3212
|
+
|
|
3213
|
+
* @example
|
|
3214
|
+
* // Find value scanning from tail
|
|
3215
|
+
* const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
|
|
3216
|
+
* // findLast scans from tail to head, returns first match
|
|
3217
|
+
* const found = list.findLast(node => node.value < 4);
|
|
3218
|
+
* console.log(found); // 3;
|
|
3219
|
+
*/
|
|
3220
|
+
findLast(elementNodeOrPredicate) {
|
|
2969
3221
|
const predicate = this._ensurePredicate(elementNodeOrPredicate);
|
|
2970
3222
|
let current = this.tail;
|
|
2971
3223
|
while (current) {
|
|
@@ -2974,6 +3226,22 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
2974
3226
|
}
|
|
2975
3227
|
return void 0;
|
|
2976
3228
|
}
|
|
3229
|
+
/**
|
|
3230
|
+
* Find the index of the last value matching a predicate (scans tail → head).
|
|
3231
|
+
* @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
|
|
3232
|
+
* @param predicate - Function called with (value, index, list).
|
|
3233
|
+
* @returns Matching index, or -1 if not found.
|
|
3234
|
+
*/
|
|
3235
|
+
findLastIndex(predicate) {
|
|
3236
|
+
let current = this.tail;
|
|
3237
|
+
let index = this.length - 1;
|
|
3238
|
+
while (current) {
|
|
3239
|
+
if (predicate(current.value, index, this)) return index;
|
|
3240
|
+
current = current.prev;
|
|
3241
|
+
index--;
|
|
3242
|
+
}
|
|
3243
|
+
return -1;
|
|
3244
|
+
}
|
|
2977
3245
|
/**
|
|
2978
3246
|
* Reverse the list in place.
|
|
2979
3247
|
* @remarks Time O(N), Space O(1)
|
|
@@ -3005,6 +3273,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
3005
3273
|
|
|
3006
3274
|
|
|
3007
3275
|
|
|
3276
|
+
|
|
3277
|
+
|
|
3278
|
+
|
|
3279
|
+
|
|
3280
|
+
|
|
3281
|
+
|
|
3282
|
+
|
|
3008
3283
|
|
|
3009
3284
|
|
|
3010
3285
|
|
|
@@ -3029,6 +3304,25 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
3029
3304
|
}
|
|
3030
3305
|
return this;
|
|
3031
3306
|
}
|
|
3307
|
+
/**
|
|
3308
|
+
* Delete the first element that satisfies a predicate.
|
|
3309
|
+
* @remarks Time O(N), Space O(1)
|
|
3310
|
+
* @param predicate - Function (value, index, list) → boolean to decide deletion.
|
|
3311
|
+
* @returns True if a match was removed.
|
|
3312
|
+
*/
|
|
3313
|
+
deleteWhere(predicate) {
|
|
3314
|
+
let current = this.head;
|
|
3315
|
+
let index = 0;
|
|
3316
|
+
while (current) {
|
|
3317
|
+
if (predicate(current.value, index, this)) {
|
|
3318
|
+
this.delete(current);
|
|
3319
|
+
return true;
|
|
3320
|
+
}
|
|
3321
|
+
current = current.next;
|
|
3322
|
+
index++;
|
|
3323
|
+
}
|
|
3324
|
+
return false;
|
|
3325
|
+
}
|
|
3032
3326
|
/**
|
|
3033
3327
|
* Set the equality comparator used to compare values.
|
|
3034
3328
|
* @remarks Time O(1), Space O(1)
|
|
@@ -3068,6 +3362,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
3068
3362
|
|
|
3069
3363
|
|
|
3070
3364
|
|
|
3365
|
+
|
|
3366
|
+
|
|
3367
|
+
|
|
3368
|
+
|
|
3369
|
+
|
|
3370
|
+
|
|
3371
|
+
|
|
3071
3372
|
|
|
3072
3373
|
|
|
3073
3374
|
|
|
@@ -3121,6 +3422,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
3121
3422
|
|
|
3122
3423
|
|
|
3123
3424
|
|
|
3425
|
+
|
|
3426
|
+
|
|
3427
|
+
|
|
3428
|
+
|
|
3429
|
+
|
|
3430
|
+
|
|
3431
|
+
|
|
3124
3432
|
|
|
3125
3433
|
|
|
3126
3434
|
|
|
@@ -3193,6 +3501,13 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
3193
3501
|
|
|
3194
3502
|
|
|
3195
3503
|
|
|
3504
|
+
|
|
3505
|
+
|
|
3506
|
+
|
|
3507
|
+
|
|
3508
|
+
|
|
3509
|
+
|
|
3510
|
+
|
|
3196
3511
|
|
|
3197
3512
|
|
|
3198
3513
|
|
|
@@ -3594,6 +3909,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3594
3909
|
|
|
3595
3910
|
|
|
3596
3911
|
|
|
3912
|
+
|
|
3913
|
+
|
|
3914
|
+
|
|
3915
|
+
|
|
3916
|
+
|
|
3917
|
+
|
|
3918
|
+
|
|
3597
3919
|
|
|
3598
3920
|
|
|
3599
3921
|
|
|
@@ -3636,6 +3958,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3636
3958
|
|
|
3637
3959
|
|
|
3638
3960
|
|
|
3961
|
+
|
|
3962
|
+
|
|
3963
|
+
|
|
3964
|
+
|
|
3965
|
+
|
|
3966
|
+
|
|
3967
|
+
|
|
3639
3968
|
|
|
3640
3969
|
|
|
3641
3970
|
|
|
@@ -3681,6 +4010,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3681
4010
|
|
|
3682
4011
|
|
|
3683
4012
|
|
|
4013
|
+
|
|
4014
|
+
|
|
4015
|
+
|
|
4016
|
+
|
|
4017
|
+
|
|
4018
|
+
|
|
4019
|
+
|
|
3684
4020
|
|
|
3685
4021
|
|
|
3686
4022
|
|
|
@@ -3734,6 +4070,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3734
4070
|
|
|
3735
4071
|
|
|
3736
4072
|
|
|
4073
|
+
|
|
4074
|
+
|
|
4075
|
+
|
|
4076
|
+
|
|
4077
|
+
|
|
4078
|
+
|
|
4079
|
+
|
|
3737
4080
|
|
|
3738
4081
|
|
|
3739
4082
|
|
|
@@ -3812,6 +4155,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3812
4155
|
|
|
3813
4156
|
|
|
3814
4157
|
|
|
4158
|
+
|
|
4159
|
+
|
|
4160
|
+
|
|
4161
|
+
|
|
4162
|
+
|
|
4163
|
+
|
|
4164
|
+
|
|
3815
4165
|
|
|
3816
4166
|
|
|
3817
4167
|
|
|
@@ -3875,6 +4225,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3875
4225
|
|
|
3876
4226
|
|
|
3877
4227
|
|
|
4228
|
+
|
|
4229
|
+
|
|
4230
|
+
|
|
4231
|
+
|
|
4232
|
+
|
|
4233
|
+
|
|
4234
|
+
|
|
3878
4235
|
|
|
3879
4236
|
|
|
3880
4237
|
|
|
@@ -3921,6 +4278,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3921
4278
|
|
|
3922
4279
|
|
|
3923
4280
|
|
|
4281
|
+
|
|
4282
|
+
|
|
4283
|
+
|
|
4284
|
+
|
|
4285
|
+
|
|
4286
|
+
|
|
4287
|
+
|
|
3924
4288
|
|
|
3925
4289
|
|
|
3926
4290
|
|
|
@@ -3987,6 +4351,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
3987
4351
|
|
|
3988
4352
|
|
|
3989
4353
|
|
|
4354
|
+
|
|
4355
|
+
|
|
4356
|
+
|
|
4357
|
+
|
|
4358
|
+
|
|
4359
|
+
|
|
4360
|
+
|
|
3990
4361
|
|
|
3991
4362
|
|
|
3992
4363
|
|
|
@@ -4033,6 +4404,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4033
4404
|
|
|
4034
4405
|
|
|
4035
4406
|
|
|
4407
|
+
|
|
4408
|
+
|
|
4409
|
+
|
|
4410
|
+
|
|
4411
|
+
|
|
4412
|
+
|
|
4413
|
+
|
|
4036
4414
|
|
|
4037
4415
|
|
|
4038
4416
|
|
|
@@ -4081,6 +4459,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4081
4459
|
|
|
4082
4460
|
|
|
4083
4461
|
|
|
4462
|
+
|
|
4463
|
+
|
|
4464
|
+
|
|
4465
|
+
|
|
4466
|
+
|
|
4467
|
+
|
|
4468
|
+
|
|
4084
4469
|
|
|
4085
4470
|
|
|
4086
4471
|
|
|
@@ -4127,6 +4512,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4127
4512
|
|
|
4128
4513
|
|
|
4129
4514
|
|
|
4515
|
+
|
|
4516
|
+
|
|
4517
|
+
|
|
4518
|
+
|
|
4519
|
+
|
|
4520
|
+
|
|
4521
|
+
|
|
4130
4522
|
|
|
4131
4523
|
|
|
4132
4524
|
|
|
@@ -4176,6 +4568,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4176
4568
|
|
|
4177
4569
|
|
|
4178
4570
|
|
|
4571
|
+
|
|
4572
|
+
|
|
4573
|
+
|
|
4574
|
+
|
|
4575
|
+
|
|
4576
|
+
|
|
4577
|
+
|
|
4179
4578
|
|
|
4180
4579
|
|
|
4181
4580
|
|
|
@@ -4230,6 +4629,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4230
4629
|
|
|
4231
4630
|
|
|
4232
4631
|
|
|
4632
|
+
|
|
4633
|
+
|
|
4634
|
+
|
|
4635
|
+
|
|
4636
|
+
|
|
4637
|
+
|
|
4638
|
+
|
|
4233
4639
|
|
|
4234
4640
|
|
|
4235
4641
|
|
|
@@ -4282,6 +4688,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4282
4688
|
|
|
4283
4689
|
|
|
4284
4690
|
|
|
4691
|
+
|
|
4692
|
+
|
|
4693
|
+
|
|
4694
|
+
|
|
4695
|
+
|
|
4696
|
+
|
|
4697
|
+
|
|
4285
4698
|
|
|
4286
4699
|
|
|
4287
4700
|
|
|
@@ -4333,6 +4746,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4333
4746
|
|
|
4334
4747
|
|
|
4335
4748
|
|
|
4749
|
+
|
|
4750
|
+
|
|
4751
|
+
|
|
4752
|
+
|
|
4753
|
+
|
|
4754
|
+
|
|
4755
|
+
|
|
4336
4756
|
|
|
4337
4757
|
|
|
4338
4758
|
|
|
@@ -4390,6 +4810,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4390
4810
|
|
|
4391
4811
|
|
|
4392
4812
|
|
|
4813
|
+
|
|
4814
|
+
|
|
4815
|
+
|
|
4816
|
+
|
|
4817
|
+
|
|
4818
|
+
|
|
4819
|
+
|
|
4393
4820
|
|
|
4394
4821
|
|
|
4395
4822
|
|
|
@@ -4455,6 +4882,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4455
4882
|
|
|
4456
4883
|
|
|
4457
4884
|
|
|
4885
|
+
|
|
4886
|
+
|
|
4887
|
+
|
|
4888
|
+
|
|
4889
|
+
|
|
4890
|
+
|
|
4891
|
+
|
|
4458
4892
|
|
|
4459
4893
|
|
|
4460
4894
|
|
|
@@ -4504,6 +4938,13 @@ var _SkipList = class _SkipList extends IterableEntryBase {
|
|
|
4504
4938
|
|
|
4505
4939
|
|
|
4506
4940
|
|
|
4941
|
+
|
|
4942
|
+
|
|
4943
|
+
|
|
4944
|
+
|
|
4945
|
+
|
|
4946
|
+
|
|
4947
|
+
|
|
4507
4948
|
|
|
4508
4949
|
|
|
4509
4950
|
|