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
@@ -807,6 +807,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
807
807
 
808
808
 
809
809
 
810
+
811
+
812
+
813
+
810
814
 
811
815
 
812
816
 
@@ -874,6 +878,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
874
878
 
875
879
 
876
880
 
881
+
882
+
883
+
884
+
877
885
 
878
886
 
879
887
 
@@ -947,6 +955,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
947
955
 
948
956
 
949
957
 
958
+
959
+
960
+
961
+
950
962
 
951
963
 
952
964
 
@@ -1001,6 +1013,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1001
1013
 
1002
1014
 
1003
1015
 
1016
+
1017
+
1018
+
1019
+
1004
1020
 
1005
1021
 
1006
1022
 
@@ -1116,6 +1132,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1116
1132
 
1117
1133
 
1118
1134
 
1135
+
1136
+
1137
+
1138
+
1119
1139
 
1120
1140
 
1121
1141
 
@@ -1175,6 +1195,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1175
1195
 
1176
1196
 
1177
1197
 
1198
+
1199
+
1200
+
1201
+
1178
1202
 
1179
1203
 
1180
1204
 
@@ -1223,6 +1247,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1223
1247
 
1224
1248
 
1225
1249
 
1250
+
1251
+
1252
+
1253
+
1226
1254
 
1227
1255
 
1228
1256
 
@@ -1277,6 +1305,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1277
1305
 
1278
1306
 
1279
1307
 
1308
+
1309
+
1310
+
1311
+
1280
1312
 
1281
1313
 
1282
1314
 
@@ -1336,6 +1368,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1336
1368
 
1337
1369
 
1338
1370
 
1371
+
1372
+
1373
+
1374
+
1339
1375
 
1340
1376
 
1341
1377
 
@@ -1403,6 +1439,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1403
1439
 
1404
1440
 
1405
1441
 
1442
+
1443
+
1444
+
1445
+
1406
1446
 
1407
1447
 
1408
1448
 
@@ -1447,6 +1487,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1447
1487
 
1448
1488
 
1449
1489
 
1490
+
1491
+
1492
+
1493
+
1450
1494
 
1451
1495
 
1452
1496
 
@@ -1497,6 +1541,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1497
1541
 
1498
1542
 
1499
1543
 
1544
+
1545
+
1546
+
1547
+
1500
1548
 
1501
1549
 
1502
1550
 
@@ -1713,6 +1761,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1713
1761
 
1714
1762
 
1715
1763
 
1764
+
1765
+
1766
+
1767
+
1716
1768
 
1717
1769
 
1718
1770
 
@@ -1767,6 +1819,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1767
1819
 
1768
1820
 
1769
1821
 
1822
+
1823
+
1824
+
1825
+
1770
1826
 
1771
1827
 
1772
1828
 
@@ -1849,6 +1905,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1849
1905
 
1850
1906
 
1851
1907
 
1908
+
1909
+
1910
+
1911
+
1852
1912
 
1853
1913
 
1854
1914
 
@@ -2083,6 +2143,10 @@ var _Queue = class _Queue extends LinearBase {
2083
2143
 
2084
2144
 
2085
2145
 
2146
+
2147
+
2148
+
2149
+
2086
2150
 
2087
2151
 
2088
2152
 
@@ -2133,6 +2197,10 @@ var _Queue = class _Queue extends LinearBase {
2133
2197
 
2134
2198
 
2135
2199
 
2200
+
2201
+
2202
+
2203
+
2136
2204
 
2137
2205
 
2138
2206
 
@@ -2147,6 +2215,14 @@ var _Queue = class _Queue extends LinearBase {
2147
2215
  get first() {
2148
2216
  return this.length > 0 ? this.elements[this._offset] : void 0;
2149
2217
  }
2218
+ /**
2219
+ * Peek at the front element without removing it (alias for `first`).
2220
+ * @remarks Time O(1), Space O(1)
2221
+ * @returns Front element or undefined.
2222
+ */
2223
+ peek() {
2224
+ return this.first;
2225
+ }
2150
2226
  /**
2151
2227
  * Get the last element (back) without removing it.
2152
2228
  * @remarks Time O(1), Space O(1)
@@ -2199,6 +2275,10 @@ var _Queue = class _Queue extends LinearBase {
2199
2275
 
2200
2276
 
2201
2277
 
2278
+
2279
+
2280
+
2281
+
2202
2282
 
2203
2283
 
2204
2284
 
@@ -2261,6 +2341,10 @@ var _Queue = class _Queue extends LinearBase {
2261
2341
 
2262
2342
 
2263
2343
 
2344
+
2345
+
2346
+
2347
+
2264
2348
 
2265
2349
 
2266
2350
 
@@ -2330,6 +2414,10 @@ var _Queue = class _Queue extends LinearBase {
2330
2414
 
2331
2415
 
2332
2416
 
2417
+
2418
+
2419
+
2420
+
2333
2421
 
2334
2422
 
2335
2423
 
@@ -2389,6 +2477,10 @@ var _Queue = class _Queue extends LinearBase {
2389
2477
 
2390
2478
 
2391
2479
 
2480
+
2481
+
2482
+
2483
+
2392
2484
 
2393
2485
 
2394
2486
 
@@ -2441,6 +2533,10 @@ var _Queue = class _Queue extends LinearBase {
2441
2533
 
2442
2534
 
2443
2535
 
2536
+
2537
+
2538
+
2539
+
2444
2540
 
2445
2541
 
2446
2542
 
@@ -2492,6 +2588,21 @@ var _Queue = class _Queue extends LinearBase {
2492
2588
  this._elements[this._offset + index] = newElement;
2493
2589
  return true;
2494
2590
  }
2591
+ /**
2592
+ * Delete the first element that satisfies a predicate.
2593
+ * @remarks Time O(N), Space O(N)
2594
+ * @param predicate - Function (value, index, queue) → boolean to decide deletion.
2595
+ * @returns True if a match was removed.
2596
+ */
2597
+ deleteWhere(predicate) {
2598
+ for (let i = 0; i < this.length; i++) {
2599
+ if (predicate(this._elements[this._offset + i], i, this)) {
2600
+ this.deleteAt(i);
2601
+ return true;
2602
+ }
2603
+ }
2604
+ return false;
2605
+ }
2495
2606
  /**
2496
2607
  * Reverse the queue in-place by compacting then reversing.
2497
2608
  * @remarks Time O(N), Space O(N)
@@ -2534,6 +2645,10 @@ var _Queue = class _Queue extends LinearBase {
2534
2645
 
2535
2646
 
2536
2647
 
2648
+
2649
+
2650
+
2651
+
2537
2652
 
2538
2653
 
2539
2654
 
@@ -2580,6 +2695,10 @@ var _Queue = class _Queue extends LinearBase {
2580
2695
 
2581
2696
 
2582
2697
 
2698
+
2699
+
2700
+
2701
+
2583
2702
 
2584
2703
 
2585
2704
 
@@ -2649,6 +2768,10 @@ var _Queue = class _Queue extends LinearBase {
2649
2768
 
2650
2769
 
2651
2770
 
2771
+
2772
+
2773
+
2774
+
2652
2775
 
2653
2776
 
2654
2777
 
@@ -2702,6 +2825,10 @@ var _Queue = class _Queue extends LinearBase {
2702
2825
 
2703
2826
 
2704
2827
 
2828
+
2829
+
2830
+
2831
+
2705
2832
 
2706
2833
 
2707
2834
 
@@ -2759,6 +2886,10 @@ var _Queue = class _Queue extends LinearBase {
2759
2886
 
2760
2887
 
2761
2888
 
2889
+
2890
+
2891
+
2892
+
2762
2893
 
2763
2894
 
2764
2895
 
@@ -3038,6 +3169,9 @@ var _Deque = class _Deque extends LinearBase {
3038
3169
 
3039
3170
 
3040
3171
 
3172
+
3173
+
3174
+
3041
3175
 
3042
3176
 
3043
3177
 
@@ -3055,6 +3189,31 @@ var _Deque = class _Deque extends LinearBase {
3055
3189
  * console.log(last); // 50;
3056
3190
  *
3057
3191
  * // Length unchanged
3192
+ * console.log(deque.length); // 5;
3193
+ */
3194
+ /**
3195
+ * Peek at the front element without removing it (alias for `first`).
3196
+ * @remarks Time O(1), Space O(1)
3197
+ * @returns Front element or undefined.
3198
+ */
3199
+ peek() {
3200
+ return this.first;
3201
+ }
3202
+ /**
3203
+ * Deque peek at both ends
3204
+ * @example
3205
+ * // Deque peek at both ends
3206
+ * const deque = new Deque<number>([10, 20, 30, 40, 50]);
3207
+ *
3208
+ * // Get first element without removing
3209
+ * const first = deque.at(0);
3210
+ * console.log(first); // 10;
3211
+ *
3212
+ * // Get last element without removing
3213
+ * const last = deque.at(deque.length - 1);
3214
+ * console.log(last); // 50;
3215
+ *
3216
+ * // Length unchanged
3058
3217
  * console.log(deque.length); // 5;
3059
3218
  */
3060
3219
  get first() {
@@ -3095,6 +3254,10 @@ var _Deque = class _Deque extends LinearBase {
3095
3254
 
3096
3255
 
3097
3256
 
3257
+
3258
+
3259
+
3260
+
3098
3261
 
3099
3262
 
3100
3263
 
@@ -3158,6 +3321,10 @@ var _Deque = class _Deque extends LinearBase {
3158
3321
 
3159
3322
 
3160
3323
 
3324
+
3325
+
3326
+
3327
+
3161
3328
 
3162
3329
 
3163
3330
 
@@ -3234,6 +3401,10 @@ var _Deque = class _Deque extends LinearBase {
3234
3401
 
3235
3402
 
3236
3403
 
3404
+
3405
+
3406
+
3407
+
3237
3408
 
3238
3409
 
3239
3410
 
@@ -3297,6 +3468,10 @@ var _Deque = class _Deque extends LinearBase {
3297
3468
 
3298
3469
 
3299
3470
 
3471
+
3472
+
3473
+
3474
+
3300
3475
 
3301
3476
 
3302
3477
 
@@ -3361,6 +3536,10 @@ var _Deque = class _Deque extends LinearBase {
3361
3536
 
3362
3537
 
3363
3538
 
3539
+
3540
+
3541
+
3542
+
3364
3543
 
3365
3544
 
3366
3545
 
@@ -3466,6 +3645,10 @@ var _Deque = class _Deque extends LinearBase {
3466
3645
 
3467
3646
 
3468
3647
 
3648
+
3649
+
3650
+
3651
+
3469
3652
 
3470
3653
 
3471
3654
 
@@ -3511,6 +3694,10 @@ var _Deque = class _Deque extends LinearBase {
3511
3694
 
3512
3695
 
3513
3696
 
3697
+
3698
+
3699
+
3700
+
3514
3701
 
3515
3702
 
3516
3703
 
@@ -3560,6 +3747,10 @@ var _Deque = class _Deque extends LinearBase {
3560
3747
 
3561
3748
 
3562
3749
 
3750
+
3751
+
3752
+
3753
+
3563
3754
 
3564
3755
 
3565
3756
 
@@ -3760,6 +3951,10 @@ var _Deque = class _Deque extends LinearBase {
3760
3951
 
3761
3952
 
3762
3953
 
3954
+
3955
+
3956
+
3957
+
3763
3958
 
3764
3959
 
3765
3960
 
@@ -3847,6 +4042,10 @@ var _Deque = class _Deque extends LinearBase {
3847
4042
 
3848
4043
 
3849
4044
 
4045
+
4046
+
4047
+
4048
+
3850
4049
 
3851
4050
 
3852
4051
 
@@ -3959,6 +4158,10 @@ var _Deque = class _Deque extends LinearBase {
3959
4158
 
3960
4159
 
3961
4160
 
4161
+
4162
+
4163
+
4164
+
3962
4165
 
3963
4166
 
3964
4167
 
@@ -4030,6 +4233,10 @@ var _Deque = class _Deque extends LinearBase {
4030
4233
 
4031
4234
 
4032
4235
 
4236
+
4237
+
4238
+
4239
+
4033
4240
 
4034
4241
 
4035
4242
 
@@ -4084,6 +4291,10 @@ var _Deque = class _Deque extends LinearBase {
4084
4291
 
4085
4292
 
4086
4293
 
4294
+
4295
+
4296
+
4297
+
4087
4298
 
4088
4299
 
4089
4300
 
@@ -4158,6 +4369,10 @@ var _Deque = class _Deque extends LinearBase {
4158
4369
 
4159
4370
 
4160
4371
 
4372
+
4373
+
4374
+
4375
+
4161
4376
 
4162
4377
 
4163
4378