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
@@ -809,6 +809,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
809
809
 
810
810
 
811
811
 
812
+
813
+
814
+
815
+
812
816
 
813
817
 
814
818
 
@@ -876,6 +880,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
876
880
 
877
881
 
878
882
 
883
+
884
+
885
+
886
+
879
887
 
880
888
 
881
889
 
@@ -949,6 +957,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
949
957
 
950
958
 
951
959
 
960
+
961
+
962
+
963
+
952
964
 
953
965
 
954
966
 
@@ -1003,6 +1015,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1003
1015
 
1004
1016
 
1005
1017
 
1018
+
1019
+
1020
+
1021
+
1006
1022
 
1007
1023
 
1008
1024
 
@@ -1118,6 +1134,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1118
1134
 
1119
1135
 
1120
1136
 
1137
+
1138
+
1139
+
1140
+
1121
1141
 
1122
1142
 
1123
1143
 
@@ -1177,6 +1197,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1177
1197
 
1178
1198
 
1179
1199
 
1200
+
1201
+
1202
+
1203
+
1180
1204
 
1181
1205
 
1182
1206
 
@@ -1225,6 +1249,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1225
1249
 
1226
1250
 
1227
1251
 
1252
+
1253
+
1254
+
1255
+
1228
1256
 
1229
1257
 
1230
1258
 
@@ -1279,6 +1307,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1279
1307
 
1280
1308
 
1281
1309
 
1310
+
1311
+
1312
+
1313
+
1282
1314
 
1283
1315
 
1284
1316
 
@@ -1338,6 +1370,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1338
1370
 
1339
1371
 
1340
1372
 
1373
+
1374
+
1375
+
1376
+
1341
1377
 
1342
1378
 
1343
1379
 
@@ -1405,6 +1441,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1405
1441
 
1406
1442
 
1407
1443
 
1444
+
1445
+
1446
+
1447
+
1408
1448
 
1409
1449
 
1410
1450
 
@@ -1449,6 +1489,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1449
1489
 
1450
1490
 
1451
1491
 
1492
+
1493
+
1494
+
1495
+
1452
1496
 
1453
1497
 
1454
1498
 
@@ -1499,6 +1543,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1499
1543
 
1500
1544
 
1501
1545
 
1546
+
1547
+
1548
+
1549
+
1502
1550
 
1503
1551
 
1504
1552
 
@@ -1715,6 +1763,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1715
1763
 
1716
1764
 
1717
1765
 
1766
+
1767
+
1768
+
1769
+
1718
1770
 
1719
1771
 
1720
1772
 
@@ -1769,6 +1821,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1769
1821
 
1770
1822
 
1771
1823
 
1824
+
1825
+
1826
+
1827
+
1772
1828
 
1773
1829
 
1774
1830
 
@@ -1851,6 +1907,10 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1851
1907
 
1852
1908
 
1853
1909
 
1910
+
1911
+
1912
+
1913
+
1854
1914
 
1855
1915
 
1856
1916
 
@@ -2085,6 +2145,10 @@ var _Queue = class _Queue extends LinearBase {
2085
2145
 
2086
2146
 
2087
2147
 
2148
+
2149
+
2150
+
2151
+
2088
2152
 
2089
2153
 
2090
2154
 
@@ -2135,6 +2199,10 @@ var _Queue = class _Queue extends LinearBase {
2135
2199
 
2136
2200
 
2137
2201
 
2202
+
2203
+
2204
+
2205
+
2138
2206
 
2139
2207
 
2140
2208
 
@@ -2149,6 +2217,14 @@ var _Queue = class _Queue extends LinearBase {
2149
2217
  get first() {
2150
2218
  return this.length > 0 ? this.elements[this._offset] : void 0;
2151
2219
  }
2220
+ /**
2221
+ * Peek at the front element without removing it (alias for `first`).
2222
+ * @remarks Time O(1), Space O(1)
2223
+ * @returns Front element or undefined.
2224
+ */
2225
+ peek() {
2226
+ return this.first;
2227
+ }
2152
2228
  /**
2153
2229
  * Get the last element (back) without removing it.
2154
2230
  * @remarks Time O(1), Space O(1)
@@ -2201,6 +2277,10 @@ var _Queue = class _Queue extends LinearBase {
2201
2277
 
2202
2278
 
2203
2279
 
2280
+
2281
+
2282
+
2283
+
2204
2284
 
2205
2285
 
2206
2286
 
@@ -2263,6 +2343,10 @@ var _Queue = class _Queue extends LinearBase {
2263
2343
 
2264
2344
 
2265
2345
 
2346
+
2347
+
2348
+
2349
+
2266
2350
 
2267
2351
 
2268
2352
 
@@ -2332,6 +2416,10 @@ var _Queue = class _Queue extends LinearBase {
2332
2416
 
2333
2417
 
2334
2418
 
2419
+
2420
+
2421
+
2422
+
2335
2423
 
2336
2424
 
2337
2425
 
@@ -2391,6 +2479,10 @@ var _Queue = class _Queue extends LinearBase {
2391
2479
 
2392
2480
 
2393
2481
 
2482
+
2483
+
2484
+
2485
+
2394
2486
 
2395
2487
 
2396
2488
 
@@ -2443,6 +2535,10 @@ var _Queue = class _Queue extends LinearBase {
2443
2535
 
2444
2536
 
2445
2537
 
2538
+
2539
+
2540
+
2541
+
2446
2542
 
2447
2543
 
2448
2544
 
@@ -2494,6 +2590,21 @@ var _Queue = class _Queue extends LinearBase {
2494
2590
  this._elements[this._offset + index] = newElement;
2495
2591
  return true;
2496
2592
  }
2593
+ /**
2594
+ * Delete the first element that satisfies a predicate.
2595
+ * @remarks Time O(N), Space O(N)
2596
+ * @param predicate - Function (value, index, queue) → boolean to decide deletion.
2597
+ * @returns True if a match was removed.
2598
+ */
2599
+ deleteWhere(predicate) {
2600
+ for (let i = 0; i < this.length; i++) {
2601
+ if (predicate(this._elements[this._offset + i], i, this)) {
2602
+ this.deleteAt(i);
2603
+ return true;
2604
+ }
2605
+ }
2606
+ return false;
2607
+ }
2497
2608
  /**
2498
2609
  * Reverse the queue in-place by compacting then reversing.
2499
2610
  * @remarks Time O(N), Space O(N)
@@ -2536,6 +2647,10 @@ var _Queue = class _Queue extends LinearBase {
2536
2647
 
2537
2648
 
2538
2649
 
2650
+
2651
+
2652
+
2653
+
2539
2654
 
2540
2655
 
2541
2656
 
@@ -2582,6 +2697,10 @@ var _Queue = class _Queue extends LinearBase {
2582
2697
 
2583
2698
 
2584
2699
 
2700
+
2701
+
2702
+
2703
+
2585
2704
 
2586
2705
 
2587
2706
 
@@ -2651,6 +2770,10 @@ var _Queue = class _Queue extends LinearBase {
2651
2770
 
2652
2771
 
2653
2772
 
2773
+
2774
+
2775
+
2776
+
2654
2777
 
2655
2778
 
2656
2779
 
@@ -2704,6 +2827,10 @@ var _Queue = class _Queue extends LinearBase {
2704
2827
 
2705
2828
 
2706
2829
 
2830
+
2831
+
2832
+
2833
+
2707
2834
 
2708
2835
 
2709
2836
 
@@ -2761,6 +2888,10 @@ var _Queue = class _Queue extends LinearBase {
2761
2888
 
2762
2889
 
2763
2890
 
2891
+
2892
+
2893
+
2894
+
2764
2895
 
2765
2896
 
2766
2897
 
@@ -3040,6 +3171,9 @@ var _Deque = class _Deque extends LinearBase {
3040
3171
 
3041
3172
 
3042
3173
 
3174
+
3175
+
3176
+
3043
3177
 
3044
3178
 
3045
3179
 
@@ -3057,6 +3191,31 @@ var _Deque = class _Deque extends LinearBase {
3057
3191
  * console.log(last); // 50;
3058
3192
  *
3059
3193
  * // Length unchanged
3194
+ * console.log(deque.length); // 5;
3195
+ */
3196
+ /**
3197
+ * Peek at the front element without removing it (alias for `first`).
3198
+ * @remarks Time O(1), Space O(1)
3199
+ * @returns Front element or undefined.
3200
+ */
3201
+ peek() {
3202
+ return this.first;
3203
+ }
3204
+ /**
3205
+ * Deque peek at both ends
3206
+ * @example
3207
+ * // Deque peek at both ends
3208
+ * const deque = new Deque<number>([10, 20, 30, 40, 50]);
3209
+ *
3210
+ * // Get first element without removing
3211
+ * const first = deque.at(0);
3212
+ * console.log(first); // 10;
3213
+ *
3214
+ * // Get last element without removing
3215
+ * const last = deque.at(deque.length - 1);
3216
+ * console.log(last); // 50;
3217
+ *
3218
+ * // Length unchanged
3060
3219
  * console.log(deque.length); // 5;
3061
3220
  */
3062
3221
  get first() {
@@ -3097,6 +3256,10 @@ var _Deque = class _Deque extends LinearBase {
3097
3256
 
3098
3257
 
3099
3258
 
3259
+
3260
+
3261
+
3262
+
3100
3263
 
3101
3264
 
3102
3265
 
@@ -3160,6 +3323,10 @@ var _Deque = class _Deque extends LinearBase {
3160
3323
 
3161
3324
 
3162
3325
 
3326
+
3327
+
3328
+
3329
+
3163
3330
 
3164
3331
 
3165
3332
 
@@ -3236,6 +3403,10 @@ var _Deque = class _Deque extends LinearBase {
3236
3403
 
3237
3404
 
3238
3405
 
3406
+
3407
+
3408
+
3409
+
3239
3410
 
3240
3411
 
3241
3412
 
@@ -3299,6 +3470,10 @@ var _Deque = class _Deque extends LinearBase {
3299
3470
 
3300
3471
 
3301
3472
 
3473
+
3474
+
3475
+
3476
+
3302
3477
 
3303
3478
 
3304
3479
 
@@ -3363,6 +3538,10 @@ var _Deque = class _Deque extends LinearBase {
3363
3538
 
3364
3539
 
3365
3540
 
3541
+
3542
+
3543
+
3544
+
3366
3545
 
3367
3546
 
3368
3547
 
@@ -3468,6 +3647,10 @@ var _Deque = class _Deque extends LinearBase {
3468
3647
 
3469
3648
 
3470
3649
 
3650
+
3651
+
3652
+
3653
+
3471
3654
 
3472
3655
 
3473
3656
 
@@ -3513,6 +3696,10 @@ var _Deque = class _Deque extends LinearBase {
3513
3696
 
3514
3697
 
3515
3698
 
3699
+
3700
+
3701
+
3702
+
3516
3703
 
3517
3704
 
3518
3705
 
@@ -3562,6 +3749,10 @@ var _Deque = class _Deque extends LinearBase {
3562
3749
 
3563
3750
 
3564
3751
 
3752
+
3753
+
3754
+
3755
+
3565
3756
 
3566
3757
 
3567
3758
 
@@ -3762,6 +3953,10 @@ var _Deque = class _Deque extends LinearBase {
3762
3953
 
3763
3954
 
3764
3955
 
3956
+
3957
+
3958
+
3959
+
3765
3960
 
3766
3961
 
3767
3962
 
@@ -3849,6 +4044,10 @@ var _Deque = class _Deque extends LinearBase {
3849
4044
 
3850
4045
 
3851
4046
 
4047
+
4048
+
4049
+
4050
+
3852
4051
 
3853
4052
 
3854
4053
 
@@ -3961,6 +4160,10 @@ var _Deque = class _Deque extends LinearBase {
3961
4160
 
3962
4161
 
3963
4162
 
4163
+
4164
+
4165
+
4166
+
3964
4167
 
3965
4168
 
3966
4169
 
@@ -4032,6 +4235,10 @@ var _Deque = class _Deque extends LinearBase {
4032
4235
 
4033
4236
 
4034
4237
 
4238
+
4239
+
4240
+
4241
+
4035
4242
 
4036
4243
 
4037
4244
 
@@ -4086,6 +4293,10 @@ var _Deque = class _Deque extends LinearBase {
4086
4293
 
4087
4294
 
4088
4295
 
4296
+
4297
+
4298
+
4299
+
4089
4300
 
4090
4301
 
4091
4302
 
@@ -4160,6 +4371,10 @@ var _Deque = class _Deque extends LinearBase {
4160
4371
 
4161
4372
 
4162
4373
 
4374
+
4375
+
4376
+
4377
+
4163
4378
 
4164
4379
 
4165
4380