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
@@ -814,6 +814,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
814
814
 
815
815
 
816
816
 
817
+
818
+
819
+
820
+
817
821
 
818
822
 
819
823
 
@@ -881,6 +885,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
881
885
 
882
886
 
883
887
 
888
+
889
+
890
+
891
+
884
892
 
885
893
 
886
894
 
@@ -953,6 +961,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
953
961
 
954
962
 
955
963
 
964
+
965
+
966
+
967
+
956
968
 
957
969
 
958
970
 
@@ -1007,6 +1019,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1007
1019
 
1008
1020
 
1009
1021
 
1022
+
1023
+
1024
+
1025
+
1010
1026
 
1011
1027
 
1012
1028
 
@@ -1122,6 +1138,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1122
1138
 
1123
1139
 
1124
1140
 
1141
+
1142
+
1143
+
1144
+
1125
1145
 
1126
1146
 
1127
1147
 
@@ -1181,6 +1201,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1181
1201
 
1182
1202
 
1183
1203
 
1204
+
1205
+
1206
+
1207
+
1184
1208
 
1185
1209
 
1186
1210
 
@@ -1229,6 +1253,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1229
1253
 
1230
1254
 
1231
1255
 
1256
+
1257
+
1258
+
1259
+
1232
1260
 
1233
1261
 
1234
1262
 
@@ -1283,6 +1311,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1283
1311
 
1284
1312
 
1285
1313
 
1314
+
1315
+
1316
+
1317
+
1286
1318
 
1287
1319
 
1288
1320
 
@@ -1342,6 +1374,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1342
1374
 
1343
1375
 
1344
1376
 
1377
+
1378
+
1379
+
1380
+
1345
1381
 
1346
1382
 
1347
1383
 
@@ -1409,6 +1445,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1409
1445
 
1410
1446
 
1411
1447
 
1448
+
1449
+
1450
+
1451
+
1412
1452
 
1413
1453
 
1414
1454
 
@@ -1453,6 +1493,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1453
1493
 
1454
1494
 
1455
1495
 
1496
+
1497
+
1498
+
1499
+
1456
1500
 
1457
1501
 
1458
1502
 
@@ -1503,6 +1547,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1503
1547
 
1504
1548
 
1505
1549
 
1550
+
1551
+
1552
+
1553
+
1506
1554
 
1507
1555
 
1508
1556
 
@@ -1719,6 +1767,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1719
1767
 
1720
1768
 
1721
1769
 
1770
+
1771
+
1772
+
1773
+
1722
1774
 
1723
1775
 
1724
1776
 
@@ -1773,6 +1825,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1773
1825
 
1774
1826
 
1775
1827
 
1828
+
1829
+
1830
+
1831
+
1776
1832
 
1777
1833
 
1778
1834
 
@@ -1855,6 +1911,10 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1855
1911
 
1856
1912
 
1857
1913
 
1914
+
1915
+
1916
+
1917
+
1858
1918
 
1859
1919
 
1860
1920
 
@@ -2090,6 +2150,10 @@ var Queue = class _Queue extends LinearBase {
2090
2150
 
2091
2151
 
2092
2152
 
2153
+
2154
+
2155
+
2156
+
2093
2157
 
2094
2158
 
2095
2159
 
@@ -2140,6 +2204,10 @@ var Queue = class _Queue extends LinearBase {
2140
2204
 
2141
2205
 
2142
2206
 
2207
+
2208
+
2209
+
2210
+
2143
2211
 
2144
2212
 
2145
2213
 
@@ -2154,6 +2222,14 @@ var Queue = class _Queue extends LinearBase {
2154
2222
  get first() {
2155
2223
  return this.length > 0 ? this.elements[this._offset] : void 0;
2156
2224
  }
2225
+ /**
2226
+ * Peek at the front element without removing it (alias for `first`).
2227
+ * @remarks Time O(1), Space O(1)
2228
+ * @returns Front element or undefined.
2229
+ */
2230
+ peek() {
2231
+ return this.first;
2232
+ }
2157
2233
  /**
2158
2234
  * Get the last element (back) without removing it.
2159
2235
  * @remarks Time O(1), Space O(1)
@@ -2206,6 +2282,10 @@ var Queue = class _Queue extends LinearBase {
2206
2282
 
2207
2283
 
2208
2284
 
2285
+
2286
+
2287
+
2288
+
2209
2289
 
2210
2290
 
2211
2291
 
@@ -2268,6 +2348,10 @@ var Queue = class _Queue extends LinearBase {
2268
2348
 
2269
2349
 
2270
2350
 
2351
+
2352
+
2353
+
2354
+
2271
2355
 
2272
2356
 
2273
2357
 
@@ -2337,6 +2421,10 @@ var Queue = class _Queue extends LinearBase {
2337
2421
 
2338
2422
 
2339
2423
 
2424
+
2425
+
2426
+
2427
+
2340
2428
 
2341
2429
 
2342
2430
 
@@ -2396,6 +2484,10 @@ var Queue = class _Queue extends LinearBase {
2396
2484
 
2397
2485
 
2398
2486
 
2487
+
2488
+
2489
+
2490
+
2399
2491
 
2400
2492
 
2401
2493
 
@@ -2448,6 +2540,10 @@ var Queue = class _Queue extends LinearBase {
2448
2540
 
2449
2541
 
2450
2542
 
2543
+
2544
+
2545
+
2546
+
2451
2547
 
2452
2548
 
2453
2549
 
@@ -2499,6 +2595,21 @@ var Queue = class _Queue extends LinearBase {
2499
2595
  this._elements[this._offset + index] = newElement;
2500
2596
  return true;
2501
2597
  }
2598
+ /**
2599
+ * Delete the first element that satisfies a predicate.
2600
+ * @remarks Time O(N), Space O(N)
2601
+ * @param predicate - Function (value, index, queue) → boolean to decide deletion.
2602
+ * @returns True if a match was removed.
2603
+ */
2604
+ deleteWhere(predicate) {
2605
+ for (let i = 0; i < this.length; i++) {
2606
+ if (predicate(this._elements[this._offset + i], i, this)) {
2607
+ this.deleteAt(i);
2608
+ return true;
2609
+ }
2610
+ }
2611
+ return false;
2612
+ }
2502
2613
  /**
2503
2614
  * Reverse the queue in-place by compacting then reversing.
2504
2615
  * @remarks Time O(N), Space O(N)
@@ -2541,6 +2652,10 @@ var Queue = class _Queue extends LinearBase {
2541
2652
 
2542
2653
 
2543
2654
 
2655
+
2656
+
2657
+
2658
+
2544
2659
 
2545
2660
 
2546
2661
 
@@ -2587,6 +2702,10 @@ var Queue = class _Queue extends LinearBase {
2587
2702
 
2588
2703
 
2589
2704
 
2705
+
2706
+
2707
+
2708
+
2590
2709
 
2591
2710
 
2592
2711
 
@@ -2656,6 +2775,10 @@ var Queue = class _Queue extends LinearBase {
2656
2775
 
2657
2776
 
2658
2777
 
2778
+
2779
+
2780
+
2781
+
2659
2782
 
2660
2783
 
2661
2784
 
@@ -2709,6 +2832,10 @@ var Queue = class _Queue extends LinearBase {
2709
2832
 
2710
2833
 
2711
2834
 
2835
+
2836
+
2837
+
2838
+
2712
2839
 
2713
2840
 
2714
2841
 
@@ -2766,6 +2893,10 @@ var Queue = class _Queue extends LinearBase {
2766
2893
 
2767
2894
 
2768
2895
 
2896
+
2897
+
2898
+
2899
+
2769
2900
 
2770
2901
 
2771
2902
 
@@ -3045,6 +3176,9 @@ var Deque = class extends LinearBase {
3045
3176
 
3046
3177
 
3047
3178
 
3179
+
3180
+
3181
+
3048
3182
 
3049
3183
 
3050
3184
 
@@ -3062,6 +3196,31 @@ var Deque = class extends LinearBase {
3062
3196
  * console.log(last); // 50;
3063
3197
  *
3064
3198
  * // Length unchanged
3199
+ * console.log(deque.length); // 5;
3200
+ */
3201
+ /**
3202
+ * Peek at the front element without removing it (alias for `first`).
3203
+ * @remarks Time O(1), Space O(1)
3204
+ * @returns Front element or undefined.
3205
+ */
3206
+ peek() {
3207
+ return this.first;
3208
+ }
3209
+ /**
3210
+ * Deque peek at both ends
3211
+ * @example
3212
+ * // Deque peek at both ends
3213
+ * const deque = new Deque<number>([10, 20, 30, 40, 50]);
3214
+ *
3215
+ * // Get first element without removing
3216
+ * const first = deque.at(0);
3217
+ * console.log(first); // 10;
3218
+ *
3219
+ * // Get last element without removing
3220
+ * const last = deque.at(deque.length - 1);
3221
+ * console.log(last); // 50;
3222
+ *
3223
+ * // Length unchanged
3065
3224
  * console.log(deque.length); // 5;
3066
3225
  */
3067
3226
  get first() {
@@ -3102,6 +3261,10 @@ var Deque = class extends LinearBase {
3102
3261
 
3103
3262
 
3104
3263
 
3264
+
3265
+
3266
+
3267
+
3105
3268
 
3106
3269
 
3107
3270
 
@@ -3165,6 +3328,10 @@ var Deque = class extends LinearBase {
3165
3328
 
3166
3329
 
3167
3330
 
3331
+
3332
+
3333
+
3334
+
3168
3335
 
3169
3336
 
3170
3337
 
@@ -3241,6 +3408,10 @@ var Deque = class extends LinearBase {
3241
3408
 
3242
3409
 
3243
3410
 
3411
+
3412
+
3413
+
3414
+
3244
3415
 
3245
3416
 
3246
3417
 
@@ -3304,6 +3475,10 @@ var Deque = class extends LinearBase {
3304
3475
 
3305
3476
 
3306
3477
 
3478
+
3479
+
3480
+
3481
+
3307
3482
 
3308
3483
 
3309
3484
 
@@ -3368,6 +3543,10 @@ var Deque = class extends LinearBase {
3368
3543
 
3369
3544
 
3370
3545
 
3546
+
3547
+
3548
+
3549
+
3371
3550
 
3372
3551
 
3373
3552
 
@@ -3473,6 +3652,10 @@ var Deque = class extends LinearBase {
3473
3652
 
3474
3653
 
3475
3654
 
3655
+
3656
+
3657
+
3658
+
3476
3659
 
3477
3660
 
3478
3661
 
@@ -3518,6 +3701,10 @@ var Deque = class extends LinearBase {
3518
3701
 
3519
3702
 
3520
3703
 
3704
+
3705
+
3706
+
3707
+
3521
3708
 
3522
3709
 
3523
3710
 
@@ -3567,6 +3754,10 @@ var Deque = class extends LinearBase {
3567
3754
 
3568
3755
 
3569
3756
 
3757
+
3758
+
3759
+
3760
+
3570
3761
 
3571
3762
 
3572
3763
 
@@ -3767,6 +3958,10 @@ var Deque = class extends LinearBase {
3767
3958
 
3768
3959
 
3769
3960
 
3961
+
3962
+
3963
+
3964
+
3770
3965
 
3771
3966
 
3772
3967
 
@@ -3854,6 +4049,10 @@ var Deque = class extends LinearBase {
3854
4049
 
3855
4050
 
3856
4051
 
4052
+
4053
+
4054
+
4055
+
3857
4056
 
3858
4057
 
3859
4058
 
@@ -3966,6 +4165,10 @@ var Deque = class extends LinearBase {
3966
4165
 
3967
4166
 
3968
4167
 
4168
+
4169
+
4170
+
4171
+
3969
4172
 
3970
4173
 
3971
4174
 
@@ -4037,6 +4240,10 @@ var Deque = class extends LinearBase {
4037
4240
 
4038
4241
 
4039
4242
 
4243
+
4244
+
4245
+
4246
+
4040
4247
 
4041
4248
 
4042
4249
 
@@ -4091,6 +4298,10 @@ var Deque = class extends LinearBase {
4091
4298
 
4092
4299
 
4093
4300
 
4301
+
4302
+
4303
+
4304
+
4094
4305
 
4095
4306
 
4096
4307
 
@@ -4165,6 +4376,10 @@ var Deque = class extends LinearBase {
4165
4376
 
4166
4377
 
4167
4378
 
4379
+
4380
+
4381
+
4382
+
4168
4383
 
4169
4384
 
4170
4385