binary-tree-typed 2.5.0 → 2.5.1

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 (75) hide show
  1. package/dist/cjs/index.cjs +609 -0
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +609 -0
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +609 -0
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +609 -0
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/data-structures/base/index.d.ts +1 -0
  10. package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
  11. package/dist/types/data-structures/base/linear-base.d.ts +3 -3
  12. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +252 -0
  13. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +294 -0
  14. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +527 -2
  15. package/dist/types/data-structures/binary-tree/bst.d.ts +505 -1
  16. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +399 -0
  17. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +126 -1
  18. package/dist/types/data-structures/binary-tree/tree-map.d.ts +2881 -382
  19. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +2867 -347
  20. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2328 -312
  21. package/dist/types/data-structures/binary-tree/tree-set.d.ts +2671 -277
  22. package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
  23. package/dist/types/data-structures/graph/directed-graph.d.ts +210 -0
  24. package/dist/types/data-structures/graph/undirected-graph.d.ts +189 -0
  25. package/dist/types/data-structures/hash/hash-map.d.ts +241 -10
  26. package/dist/types/data-structures/heap/heap.d.ts +294 -0
  27. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +360 -3
  28. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +318 -3
  29. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +380 -2
  30. package/dist/types/data-structures/matrix/matrix.d.ts +168 -0
  31. package/dist/types/data-structures/queue/deque.d.ts +319 -4
  32. package/dist/types/data-structures/queue/queue.d.ts +252 -0
  33. package/dist/types/data-structures/stack/stack.d.ts +210 -0
  34. package/dist/types/data-structures/trie/trie.d.ts +256 -4
  35. package/dist/types/interfaces/graph.d.ts +1 -1
  36. package/dist/types/types/common.d.ts +2 -2
  37. package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
  38. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
  39. package/dist/types/types/utils/validate-type.d.ts +4 -4
  40. package/dist/umd/binary-tree-typed.js +609 -0
  41. package/dist/umd/binary-tree-typed.js.map +1 -1
  42. package/dist/umd/binary-tree-typed.min.js +5 -5
  43. package/dist/umd/binary-tree-typed.min.js.map +1 -1
  44. package/package.json +2 -2
  45. package/src/data-structures/base/index.ts +1 -0
  46. package/src/data-structures/base/iterable-entry-base.ts +8 -8
  47. package/src/data-structures/base/linear-base.ts +3 -3
  48. package/src/data-structures/binary-tree/avl-tree.ts +252 -0
  49. package/src/data-structures/binary-tree/binary-indexed-tree.ts +295 -1
  50. package/src/data-structures/binary-tree/binary-tree.ts +527 -2
  51. package/src/data-structures/binary-tree/bst.ts +505 -1
  52. package/src/data-structures/binary-tree/red-black-tree.ts +399 -0
  53. package/src/data-structures/binary-tree/segment-tree.ts +127 -2
  54. package/src/data-structures/binary-tree/tree-map.ts +2958 -459
  55. package/src/data-structures/binary-tree/tree-multi-map.ts +3069 -549
  56. package/src/data-structures/binary-tree/tree-multi-set.ts +2476 -460
  57. package/src/data-structures/binary-tree/tree-set.ts +2816 -422
  58. package/src/data-structures/graph/abstract-graph.ts +4 -4
  59. package/src/data-structures/graph/directed-graph.ts +210 -0
  60. package/src/data-structures/graph/undirected-graph.ts +189 -0
  61. package/src/data-structures/hash/hash-map.ts +246 -15
  62. package/src/data-structures/heap/heap.ts +294 -0
  63. package/src/data-structures/linked-list/doubly-linked-list.ts +360 -3
  64. package/src/data-structures/linked-list/singly-linked-list.ts +318 -3
  65. package/src/data-structures/linked-list/skip-linked-list.ts +380 -2
  66. package/src/data-structures/matrix/matrix.ts +169 -1
  67. package/src/data-structures/queue/deque.ts +320 -5
  68. package/src/data-structures/queue/queue.ts +252 -0
  69. package/src/data-structures/stack/stack.ts +210 -0
  70. package/src/data-structures/trie/trie.ts +257 -5
  71. package/src/interfaces/graph.ts +1 -1
  72. package/src/types/common.ts +2 -2
  73. package/src/types/data-structures/heap/heap.ts +1 -0
  74. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
  75. package/src/types/utils/validate-type.ts +4 -4
@@ -772,6 +772,27 @@ var _Queue = class _Queue extends LinearBase {
772
772
 
773
773
 
774
774
 
775
+
776
+
777
+
778
+
779
+
780
+
781
+
782
+
783
+
784
+
785
+
786
+
787
+
788
+
789
+
790
+
791
+
792
+
793
+
794
+
795
+
775
796
  * @example
776
797
  * // Track queue length
777
798
  * const q = new Queue<number>();
@@ -798,6 +819,27 @@ var _Queue = class _Queue extends LinearBase {
798
819
 
799
820
 
800
821
 
822
+
823
+
824
+
825
+
826
+
827
+
828
+
829
+
830
+
831
+
832
+
833
+
834
+
835
+
836
+
837
+
838
+
839
+
840
+
841
+
842
+
801
843
  * @example
802
844
  * // View the front element
803
845
  * const q = new Queue<string>(['first', 'second', 'third']);
@@ -840,6 +882,27 @@ var _Queue = class _Queue extends LinearBase {
840
882
 
841
883
 
842
884
 
885
+
886
+
887
+
888
+
889
+
890
+
891
+
892
+
893
+
894
+
895
+
896
+
897
+
898
+
899
+
900
+
901
+
902
+
903
+
904
+
905
+
843
906
  * @example
844
907
  * // Queue for...of iteration and isEmpty check
845
908
  * const queue = new Queue<string>(['A', 'B', 'C', 'D']);
@@ -878,6 +941,27 @@ var _Queue = class _Queue extends LinearBase {
878
941
 
879
942
 
880
943
 
944
+
945
+
946
+
947
+
948
+
949
+
950
+
951
+
952
+
953
+
954
+
955
+
956
+
957
+
958
+
959
+
960
+
961
+
962
+
963
+
964
+
881
965
  * @example
882
966
  * // basic Queue creation and push operation
883
967
  * // Create a simple Queue with initial values
@@ -923,6 +1007,27 @@ var _Queue = class _Queue extends LinearBase {
923
1007
 
924
1008
 
925
1009
 
1010
+
1011
+
1012
+
1013
+
1014
+
1015
+
1016
+
1017
+
1018
+
1019
+
1020
+
1021
+
1022
+
1023
+
1024
+
1025
+
1026
+
1027
+
1028
+
1029
+
1030
+
926
1031
  * @example
927
1032
  * // Queue shift and peek operations
928
1033
  * const queue = new Queue<number>([10, 20, 30, 40]);
@@ -958,6 +1063,27 @@ var _Queue = class _Queue extends LinearBase {
958
1063
 
959
1064
 
960
1065
 
1066
+
1067
+
1068
+
1069
+
1070
+
1071
+
1072
+
1073
+
1074
+
1075
+
1076
+
1077
+
1078
+
1079
+
1080
+
1081
+
1082
+
1083
+
1084
+
1085
+
1086
+
961
1087
  * @example
962
1088
  * // Remove specific element
963
1089
  * const q = new Queue<number>([1, 2, 3, 2]);
@@ -986,6 +1112,27 @@ var _Queue = class _Queue extends LinearBase {
986
1112
 
987
1113
 
988
1114
 
1115
+
1116
+
1117
+
1118
+
1119
+
1120
+
1121
+
1122
+
1123
+
1124
+
1125
+
1126
+
1127
+
1128
+
1129
+
1130
+
1131
+
1132
+
1133
+
1134
+
1135
+
989
1136
  * @example
990
1137
  * // Access element by index
991
1138
  * const q = new Queue<string>(['a', 'b', 'c']);
@@ -1055,6 +1202,27 @@ var _Queue = class _Queue extends LinearBase {
1055
1202
 
1056
1203
 
1057
1204
 
1205
+
1206
+
1207
+
1208
+
1209
+
1210
+
1211
+
1212
+
1213
+
1214
+
1215
+
1216
+
1217
+
1218
+
1219
+
1220
+
1221
+
1222
+
1223
+
1224
+
1225
+
1058
1226
  * @example
1059
1227
  * // Remove all elements
1060
1228
  * const q = new Queue<number>([1, 2, 3]);
@@ -1077,6 +1245,27 @@ var _Queue = class _Queue extends LinearBase {
1077
1245
 
1078
1246
 
1079
1247
 
1248
+
1249
+
1250
+
1251
+
1252
+
1253
+
1254
+
1255
+
1256
+
1257
+
1258
+
1259
+
1260
+
1261
+
1262
+
1263
+
1264
+
1265
+
1266
+
1267
+
1268
+
1080
1269
  * @example
1081
1270
  * // Reclaim unused memory
1082
1271
  * const q = new Queue<number>([1, 2, 3, 4, 5]);
@@ -1122,6 +1311,27 @@ var _Queue = class _Queue extends LinearBase {
1122
1311
 
1123
1312
 
1124
1313
 
1314
+
1315
+
1316
+
1317
+
1318
+
1319
+
1320
+
1321
+
1322
+
1323
+
1324
+
1325
+
1326
+
1327
+
1328
+
1329
+
1330
+
1331
+
1332
+
1333
+
1334
+
1125
1335
  * @example
1126
1336
  * // Create independent copy
1127
1337
  * const q = new Queue<number>([1, 2, 3]);
@@ -1151,6 +1361,27 @@ var _Queue = class _Queue extends LinearBase {
1151
1361
 
1152
1362
 
1153
1363
 
1364
+
1365
+
1366
+
1367
+
1368
+
1369
+
1370
+
1371
+
1372
+
1373
+
1374
+
1375
+
1376
+
1377
+
1378
+
1379
+
1380
+
1381
+
1382
+
1383
+
1384
+
1154
1385
  * @example
1155
1386
  * // Filter elements
1156
1387
  * const q = new Queue<number>([1, 2, 3, 4, 5]);
@@ -1184,6 +1415,27 @@ var _Queue = class _Queue extends LinearBase {
1184
1415
 
1185
1416
 
1186
1417
 
1418
+
1419
+
1420
+
1421
+
1422
+
1423
+
1424
+
1425
+
1426
+
1427
+
1428
+
1429
+
1430
+
1431
+
1432
+
1433
+
1434
+
1435
+
1436
+
1437
+
1438
+
1187
1439
  * @example
1188
1440
  * // Transform elements
1189
1441
  * const q = new Queue<number>([1, 2, 3]);
@@ -1668,6 +1920,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1668
1920
 
1669
1921
 
1670
1922
 
1923
+
1924
+
1925
+
1926
+
1927
+
1928
+
1929
+
1930
+
1931
+
1932
+
1933
+
1934
+
1935
+
1936
+
1937
+
1938
+
1939
+
1940
+
1941
+
1942
+
1943
+
1671
1944
  * @example
1672
1945
  * // Add a single node
1673
1946
  * const tree = new BinaryTree<number>();
@@ -1698,6 +1971,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1698
1971
 
1699
1972
 
1700
1973
 
1974
+
1975
+
1976
+
1977
+
1978
+
1979
+
1980
+
1981
+
1982
+
1983
+
1984
+
1985
+
1986
+
1987
+
1988
+
1989
+
1990
+
1991
+
1992
+
1993
+
1994
+
1701
1995
  * @example
1702
1996
  * // basic BinaryTree creation and insertion
1703
1997
  * // Create a BinaryTree with entries
@@ -1780,6 +2074,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1780
2074
 
1781
2075
 
1782
2076
 
2077
+
2078
+
2079
+
2080
+
2081
+
2082
+
2083
+
2084
+
2085
+
2086
+
2087
+
2088
+
2089
+
2090
+
2091
+
2092
+
2093
+
2094
+
2095
+
2096
+
2097
+
1783
2098
  * @example
1784
2099
  * // Bulk add
1785
2100
  * const tree = new BinaryTree<number>();
@@ -1798,6 +2113,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1798
2113
  * @returns An array of booleans indicating the success of each individual `set` operation.
1799
2114
 
1800
2115
 
2116
+
2117
+
2118
+
2119
+
2120
+
2121
+
2122
+
2123
+
2124
+
2125
+
2126
+
2127
+
2128
+
2129
+
2130
+
2131
+
2132
+
2133
+
2134
+
2135
+
2136
+
1801
2137
  * @example
1802
2138
  * // Set multiple entries
1803
2139
  * const tree = new BinaryTree<number, string>();
@@ -1837,6 +2173,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1837
2173
 
1838
2174
 
1839
2175
 
2176
+
2177
+
2178
+
2179
+
2180
+
2181
+
2182
+
2183
+
2184
+
2185
+
2186
+
2187
+
2188
+
2189
+
2190
+
2191
+
2192
+
2193
+
2194
+
2195
+
2196
+
1840
2197
  * @example
1841
2198
  * // Combine trees
1842
2199
  * const t1 = new BinaryTree<number>([1, 2]);
@@ -1875,6 +2232,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1875
2232
 
1876
2233
 
1877
2234
 
2235
+
2236
+
2237
+
2238
+
2239
+
2240
+
2241
+
2242
+
2243
+
2244
+
2245
+
2246
+
2247
+
2248
+
2249
+
2250
+
2251
+
2252
+
2253
+
2254
+
2255
+
1878
2256
  * @example
1879
2257
  * // Remove a node
1880
2258
  * const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
@@ -1991,6 +2369,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1991
2369
 
1992
2370
 
1993
2371
 
2372
+
2373
+
2374
+
2375
+
2376
+
2377
+
2378
+
2379
+
2380
+
2381
+
2382
+
2383
+
2384
+
2385
+
2386
+
2387
+
2388
+
2389
+
2390
+
2391
+
2392
+
1994
2393
  * @example
1995
2394
  * // Get node by key
1996
2395
  * const tree = new BinaryTree<number, string>([[1, 'root'], [2, 'child']]);
@@ -2025,6 +2424,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2025
2424
 
2026
2425
 
2027
2426
 
2427
+
2428
+
2429
+
2430
+
2431
+
2432
+
2433
+
2434
+
2435
+
2436
+
2437
+
2438
+
2439
+
2440
+
2441
+
2442
+
2443
+
2444
+
2445
+
2446
+
2447
+
2028
2448
  * @example
2029
2449
  * // Retrieve value by key
2030
2450
  * const tree = new BinaryTree<number, string>([[1, 'root'], [2, 'left'], [3, 'right']]);
@@ -2062,6 +2482,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2062
2482
 
2063
2483
 
2064
2484
 
2485
+
2486
+
2487
+
2488
+
2489
+
2490
+
2491
+
2492
+
2493
+
2494
+
2495
+
2496
+
2497
+
2498
+
2499
+
2500
+
2501
+
2502
+
2503
+
2504
+
2505
+
2065
2506
  * @example
2066
2507
  * // Remove all nodes
2067
2508
  * const tree = new BinaryTree<number>([1, 2, 3]);
@@ -2086,6 +2527,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2086
2527
 
2087
2528
 
2088
2529
 
2530
+
2531
+
2532
+
2533
+
2534
+
2535
+
2536
+
2537
+
2538
+
2539
+
2540
+
2541
+
2542
+
2543
+
2544
+
2545
+
2546
+
2547
+
2548
+
2549
+
2550
+
2089
2551
  * @example
2090
2552
  * // Check empty
2091
2553
  * console.log(new BinaryTree().isEmpty()); // true;
@@ -2119,6 +2581,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2119
2581
 
2120
2582
 
2121
2583
 
2584
+
2585
+
2586
+
2587
+
2588
+
2589
+
2590
+
2591
+
2592
+
2593
+
2594
+
2595
+
2596
+
2597
+
2598
+
2599
+
2600
+
2601
+
2602
+
2603
+
2604
+
2122
2605
  * @example
2123
2606
  * // Check BST property
2124
2607
  * const tree = new BinaryTree<number>([1, 2, 3]);
@@ -2179,6 +2662,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2179
2662
 
2180
2663
 
2181
2664
 
2665
+
2666
+
2667
+
2668
+
2669
+
2670
+
2671
+
2672
+
2673
+
2674
+
2675
+
2676
+
2677
+
2678
+
2679
+
2680
+
2681
+
2682
+
2683
+
2684
+
2685
+
2182
2686
  * @example
2183
2687
  * // Get depth of a node
2184
2688
  * const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
@@ -2216,6 +2720,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2216
2720
 
2217
2721
 
2218
2722
 
2723
+
2724
+
2725
+
2726
+
2727
+
2728
+
2729
+
2730
+
2731
+
2732
+
2733
+
2734
+
2735
+
2736
+
2737
+
2738
+
2739
+
2740
+
2741
+
2742
+
2743
+
2219
2744
  * @example
2220
2745
  * // Get tree height
2221
2746
  * const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
@@ -2669,6 +3194,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2669
3194
 
2670
3195
 
2671
3196
 
3197
+
3198
+
3199
+
3200
+
3201
+
3202
+
3203
+
3204
+
3205
+
3206
+
3207
+
3208
+
3209
+
3210
+
3211
+
3212
+
3213
+
3214
+
3215
+
3216
+
3217
+
2672
3218
  * @example
2673
3219
  * // Deep copy
2674
3220
  * const tree = new BinaryTree<number>([1, 2, 3]);
@@ -2697,6 +3243,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2697
3243
 
2698
3244
 
2699
3245
 
3246
+
3247
+
3248
+
3249
+
3250
+
3251
+
3252
+
3253
+
3254
+
3255
+
3256
+
3257
+
3258
+
3259
+
3260
+
3261
+
3262
+
3263
+
3264
+
3265
+
3266
+
2700
3267
  * @example
2701
3268
  * // Filter nodes by condition
2702
3269
  * const tree = new BinaryTree<number>([1, 2, 3, 4]);
@@ -2729,6 +3296,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2729
3296
 
2730
3297
 
2731
3298
 
3299
+
3300
+
3301
+
3302
+
3303
+
3304
+
3305
+
3306
+
3307
+
3308
+
3309
+
3310
+
3311
+
3312
+
3313
+
3314
+
3315
+
3316
+
3317
+
3318
+
3319
+
2732
3320
  * @example
2733
3321
  * // Transform to new tree
2734
3322
  * const tree = new BinaryTree<number, number>([[1, 10], [2, 20]]);
@@ -2786,6 +3374,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2786
3374
 
2787
3375
 
2788
3376
 
3377
+
3378
+
3379
+
3380
+
3381
+
3382
+
3383
+
3384
+
3385
+
3386
+
3387
+
3388
+
3389
+
3390
+
3391
+
3392
+
3393
+
3394
+
3395
+
3396
+
3397
+
2789
3398
  * @example
2790
3399
  * // Display tree
2791
3400
  * const tree = new BinaryTree<number>([1, 2, 3]);