queue-typed 2.5.2 → 2.5.3

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 (59) hide show
  1. package/dist/cjs/index.cjs +215 -0
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +215 -0
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +215 -0
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +215 -0
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +50 -2
  10. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +56 -0
  11. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +116 -15
  12. package/dist/types/data-structures/binary-tree/bst.d.ts +99 -3
  13. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +79 -8
  14. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +24 -0
  15. package/dist/types/data-structures/binary-tree/tree-map.d.ts +520 -1
  16. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +489 -1
  17. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +393 -1
  18. package/dist/types/data-structures/binary-tree/tree-set.d.ts +500 -1
  19. package/dist/types/data-structures/graph/directed-graph.d.ts +40 -0
  20. package/dist/types/data-structures/graph/undirected-graph.d.ts +36 -0
  21. package/dist/types/data-structures/hash/hash-map.d.ts +51 -6
  22. package/dist/types/data-structures/heap/heap.d.ts +98 -12
  23. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +75 -0
  24. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +61 -1
  25. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +72 -0
  26. package/dist/types/data-structures/matrix/matrix.d.ts +32 -0
  27. package/dist/types/data-structures/queue/deque.d.ts +82 -0
  28. package/dist/types/data-structures/queue/queue.d.ts +61 -0
  29. package/dist/types/data-structures/stack/stack.d.ts +42 -2
  30. package/dist/types/data-structures/trie/trie.d.ts +48 -0
  31. package/dist/types/interfaces/binary-tree.d.ts +2 -3
  32. package/dist/umd/queue-typed.js +215 -0
  33. package/dist/umd/queue-typed.js.map +1 -1
  34. package/dist/umd/queue-typed.min.js +1 -1
  35. package/dist/umd/queue-typed.min.js.map +1 -1
  36. package/package.json +2 -2
  37. package/src/data-structures/binary-tree/avl-tree.ts +52 -5
  38. package/src/data-structures/binary-tree/binary-indexed-tree.ts +56 -0
  39. package/src/data-structures/binary-tree/binary-tree.ts +167 -81
  40. package/src/data-structures/binary-tree/bst.ts +101 -7
  41. package/src/data-structures/binary-tree/red-black-tree.ts +82 -15
  42. package/src/data-structures/binary-tree/segment-tree.ts +24 -0
  43. package/src/data-structures/binary-tree/tree-map.ts +540 -3
  44. package/src/data-structures/binary-tree/tree-multi-map.ts +490 -2
  45. package/src/data-structures/binary-tree/tree-multi-set.ts +393 -1
  46. package/src/data-structures/binary-tree/tree-set.ts +520 -3
  47. package/src/data-structures/graph/directed-graph.ts +41 -1
  48. package/src/data-structures/graph/undirected-graph.ts +37 -1
  49. package/src/data-structures/hash/hash-map.ts +67 -12
  50. package/src/data-structures/heap/heap.ts +107 -19
  51. package/src/data-structures/linked-list/doubly-linked-list.ts +88 -0
  52. package/src/data-structures/linked-list/singly-linked-list.ts +61 -1
  53. package/src/data-structures/linked-list/skip-linked-list.ts +72 -0
  54. package/src/data-structures/matrix/matrix.ts +32 -0
  55. package/src/data-structures/queue/deque.ts +85 -0
  56. package/src/data-structures/queue/queue.ts +73 -0
  57. package/src/data-structures/stack/stack.ts +45 -5
  58. package/src/data-structures/trie/trie.ts +48 -0
  59. package/src/interfaces/binary-tree.ts +1 -9
@@ -812,6 +812,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
812
812
 
813
813
 
814
814
 
815
+
816
+
817
+
818
+
815
819
 
816
820
 
817
821
 
@@ -879,6 +883,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
879
883
 
880
884
 
881
885
 
886
+
887
+
888
+
889
+
882
890
 
883
891
 
884
892
 
@@ -951,6 +959,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
951
959
 
952
960
 
953
961
 
962
+
963
+
964
+
965
+
954
966
 
955
967
 
956
968
 
@@ -1005,6 +1017,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1005
1017
 
1006
1018
 
1007
1019
 
1020
+
1021
+
1022
+
1023
+
1008
1024
 
1009
1025
 
1010
1026
 
@@ -1120,6 +1136,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1120
1136
 
1121
1137
 
1122
1138
 
1139
+
1140
+
1141
+
1142
+
1123
1143
 
1124
1144
 
1125
1145
 
@@ -1179,6 +1199,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1179
1199
 
1180
1200
 
1181
1201
 
1202
+
1203
+
1204
+
1205
+
1182
1206
 
1183
1207
 
1184
1208
 
@@ -1227,6 +1251,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1227
1251
 
1228
1252
 
1229
1253
 
1254
+
1255
+
1256
+
1257
+
1230
1258
 
1231
1259
 
1232
1260
 
@@ -1281,6 +1309,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1281
1309
 
1282
1310
 
1283
1311
 
1312
+
1313
+
1314
+
1315
+
1284
1316
 
1285
1317
 
1286
1318
 
@@ -1340,6 +1372,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1340
1372
 
1341
1373
 
1342
1374
 
1375
+
1376
+
1377
+
1378
+
1343
1379
 
1344
1380
 
1345
1381
 
@@ -1407,6 +1443,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1407
1443
 
1408
1444
 
1409
1445
 
1446
+
1447
+
1448
+
1449
+
1410
1450
 
1411
1451
 
1412
1452
 
@@ -1451,6 +1491,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1451
1491
 
1452
1492
 
1453
1493
 
1494
+
1495
+
1496
+
1497
+
1454
1498
 
1455
1499
 
1456
1500
 
@@ -1501,6 +1545,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1501
1545
 
1502
1546
 
1503
1547
 
1548
+
1549
+
1550
+
1551
+
1504
1552
 
1505
1553
 
1506
1554
 
@@ -1717,6 +1765,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1717
1765
 
1718
1766
 
1719
1767
 
1768
+
1769
+
1770
+
1771
+
1720
1772
 
1721
1773
 
1722
1774
 
@@ -1771,6 +1823,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1771
1823
 
1772
1824
 
1773
1825
 
1826
+
1827
+
1828
+
1829
+
1774
1830
 
1775
1831
 
1776
1832
 
@@ -1853,6 +1909,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1853
1909
 
1854
1910
 
1855
1911
 
1912
+
1913
+
1914
+
1915
+
1856
1916
 
1857
1917
 
1858
1918
 
@@ -2088,6 +2148,10 @@ var Queue = class _Queue extends LinearBase {
2088
2148
 
2089
2149
 
2090
2150
 
2151
+
2152
+
2153
+
2154
+
2091
2155
 
2092
2156
 
2093
2157
 
@@ -2138,6 +2202,10 @@ var Queue = class _Queue extends LinearBase {
2138
2202
 
2139
2203
 
2140
2204
 
2205
+
2206
+
2207
+
2208
+
2141
2209
 
2142
2210
 
2143
2211
 
@@ -2152,6 +2220,14 @@ var Queue = class _Queue extends LinearBase {
2152
2220
  get first() {
2153
2221
  return this.length > 0 ? this.elements[this._offset] : void 0;
2154
2222
  }
2223
+ /**
2224
+ * Peek at the front element without removing it (alias for `first`).
2225
+ * @remarks Time O(1), Space O(1)
2226
+ * @returns Front element or undefined.
2227
+ */
2228
+ peek() {
2229
+ return this.first;
2230
+ }
2155
2231
  /**
2156
2232
  * Get the last element (back) without removing it.
2157
2233
  * @remarks Time O(1), Space O(1)
@@ -2204,6 +2280,10 @@ var Queue = class _Queue extends LinearBase {
2204
2280
 
2205
2281
 
2206
2282
 
2283
+
2284
+
2285
+
2286
+
2207
2287
 
2208
2288
 
2209
2289
 
@@ -2266,6 +2346,10 @@ var Queue = class _Queue extends LinearBase {
2266
2346
 
2267
2347
 
2268
2348
 
2349
+
2350
+
2351
+
2352
+
2269
2353
 
2270
2354
 
2271
2355
 
@@ -2335,6 +2419,10 @@ var Queue = class _Queue extends LinearBase {
2335
2419
 
2336
2420
 
2337
2421
 
2422
+
2423
+
2424
+
2425
+
2338
2426
 
2339
2427
 
2340
2428
 
@@ -2394,6 +2482,10 @@ var Queue = class _Queue extends LinearBase {
2394
2482
 
2395
2483
 
2396
2484
 
2485
+
2486
+
2487
+
2488
+
2397
2489
 
2398
2490
 
2399
2491
 
@@ -2446,6 +2538,10 @@ var Queue = class _Queue extends LinearBase {
2446
2538
 
2447
2539
 
2448
2540
 
2541
+
2542
+
2543
+
2544
+
2449
2545
 
2450
2546
 
2451
2547
 
@@ -2497,6 +2593,21 @@ var Queue = class _Queue extends LinearBase {
2497
2593
  this._elements[this._offset + index] = newElement;
2498
2594
  return true;
2499
2595
  }
2596
+ /**
2597
+ * Delete the first element that satisfies a predicate.
2598
+ * @remarks Time O(N), Space O(N)
2599
+ * @param predicate - Function (value, index, queue) → boolean to decide deletion.
2600
+ * @returns True if a match was removed.
2601
+ */
2602
+ deleteWhere(predicate) {
2603
+ for (let i = 0; i < this.length; i++) {
2604
+ if (predicate(this._elements[this._offset + i], i, this)) {
2605
+ this.deleteAt(i);
2606
+ return true;
2607
+ }
2608
+ }
2609
+ return false;
2610
+ }
2500
2611
  /**
2501
2612
  * Reverse the queue in-place by compacting then reversing.
2502
2613
  * @remarks Time O(N), Space O(N)
@@ -2539,6 +2650,10 @@ var Queue = class _Queue extends LinearBase {
2539
2650
 
2540
2651
 
2541
2652
 
2653
+
2654
+
2655
+
2656
+
2542
2657
 
2543
2658
 
2544
2659
 
@@ -2585,6 +2700,10 @@ var Queue = class _Queue extends LinearBase {
2585
2700
 
2586
2701
 
2587
2702
 
2703
+
2704
+
2705
+
2706
+
2588
2707
 
2589
2708
 
2590
2709
 
@@ -2654,6 +2773,10 @@ var Queue = class _Queue extends LinearBase {
2654
2773
 
2655
2774
 
2656
2775
 
2776
+
2777
+
2778
+
2779
+
2657
2780
 
2658
2781
 
2659
2782
 
@@ -2707,6 +2830,10 @@ var Queue = class _Queue extends LinearBase {
2707
2830
 
2708
2831
 
2709
2832
 
2833
+
2834
+
2835
+
2836
+
2710
2837
 
2711
2838
 
2712
2839
 
@@ -2764,6 +2891,10 @@ var Queue = class _Queue extends LinearBase {
2764
2891
 
2765
2892
 
2766
2893
 
2894
+
2895
+
2896
+
2897
+
2767
2898
 
2768
2899
 
2769
2900
 
@@ -3043,6 +3174,9 @@ var Deque = class extends LinearBase {
3043
3174
 
3044
3175
 
3045
3176
 
3177
+
3178
+
3179
+
3046
3180
 
3047
3181
 
3048
3182
 
@@ -3060,6 +3194,31 @@ var Deque = class extends LinearBase {
3060
3194
  * console.log(last); // 50;
3061
3195
  *
3062
3196
  * // Length unchanged
3197
+ * console.log(deque.length); // 5;
3198
+ */
3199
+ /**
3200
+ * Peek at the front element without removing it (alias for `first`).
3201
+ * @remarks Time O(1), Space O(1)
3202
+ * @returns Front element or undefined.
3203
+ */
3204
+ peek() {
3205
+ return this.first;
3206
+ }
3207
+ /**
3208
+ * Deque peek at both ends
3209
+ * @example
3210
+ * // Deque peek at both ends
3211
+ * const deque = new Deque<number>([10, 20, 30, 40, 50]);
3212
+ *
3213
+ * // Get first element without removing
3214
+ * const first = deque.at(0);
3215
+ * console.log(first); // 10;
3216
+ *
3217
+ * // Get last element without removing
3218
+ * const last = deque.at(deque.length - 1);
3219
+ * console.log(last); // 50;
3220
+ *
3221
+ * // Length unchanged
3063
3222
  * console.log(deque.length); // 5;
3064
3223
  */
3065
3224
  get first() {
@@ -3100,6 +3259,10 @@ var Deque = class extends LinearBase {
3100
3259
 
3101
3260
 
3102
3261
 
3262
+
3263
+
3264
+
3265
+
3103
3266
 
3104
3267
 
3105
3268
 
@@ -3163,6 +3326,10 @@ var Deque = class extends LinearBase {
3163
3326
 
3164
3327
 
3165
3328
 
3329
+
3330
+
3331
+
3332
+
3166
3333
 
3167
3334
 
3168
3335
 
@@ -3239,6 +3406,10 @@ var Deque = class extends LinearBase {
3239
3406
 
3240
3407
 
3241
3408
 
3409
+
3410
+
3411
+
3412
+
3242
3413
 
3243
3414
 
3244
3415
 
@@ -3302,6 +3473,10 @@ var Deque = class extends LinearBase {
3302
3473
 
3303
3474
 
3304
3475
 
3476
+
3477
+
3478
+
3479
+
3305
3480
 
3306
3481
 
3307
3482
 
@@ -3366,6 +3541,10 @@ var Deque = class extends LinearBase {
3366
3541
 
3367
3542
 
3368
3543
 
3544
+
3545
+
3546
+
3547
+
3369
3548
 
3370
3549
 
3371
3550
 
@@ -3471,6 +3650,10 @@ var Deque = class extends LinearBase {
3471
3650
 
3472
3651
 
3473
3652
 
3653
+
3654
+
3655
+
3656
+
3474
3657
 
3475
3658
 
3476
3659
 
@@ -3516,6 +3699,10 @@ var Deque = class extends LinearBase {
3516
3699
 
3517
3700
 
3518
3701
 
3702
+
3703
+
3704
+
3705
+
3519
3706
 
3520
3707
 
3521
3708
 
@@ -3565,6 +3752,10 @@ var Deque = class extends LinearBase {
3565
3752
 
3566
3753
 
3567
3754
 
3755
+
3756
+
3757
+
3758
+
3568
3759
 
3569
3760
 
3570
3761
 
@@ -3765,6 +3956,10 @@ var Deque = class extends LinearBase {
3765
3956
 
3766
3957
 
3767
3958
 
3959
+
3960
+
3961
+
3962
+
3768
3963
 
3769
3964
 
3770
3965
 
@@ -3852,6 +4047,10 @@ var Deque = class extends LinearBase {
3852
4047
 
3853
4048
 
3854
4049
 
4050
+
4051
+
4052
+
4053
+
3855
4054
 
3856
4055
 
3857
4056
 
@@ -3964,6 +4163,10 @@ var Deque = class extends LinearBase {
3964
4163
 
3965
4164
 
3966
4165
 
4166
+
4167
+
4168
+
4169
+
3967
4170
 
3968
4171
 
3969
4172
 
@@ -4035,6 +4238,10 @@ var Deque = class extends LinearBase {
4035
4238
 
4036
4239
 
4037
4240
 
4241
+
4242
+
4243
+
4244
+
4038
4245
 
4039
4246
 
4040
4247
 
@@ -4089,6 +4296,10 @@ var Deque = class extends LinearBase {
4089
4296
 
4090
4297
 
4091
4298
 
4299
+
4300
+
4301
+
4302
+
4092
4303
 
4093
4304
 
4094
4305
 
@@ -4163,6 +4374,10 @@ var Deque = class extends LinearBase {
4163
4374
 
4164
4375
 
4165
4376
 
4377
+
4378
+
4379
+
4380
+
4166
4381
 
4167
4382
 
4168
4383