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
@@ -770,6 +770,27 @@ var _Queue = class _Queue extends LinearBase {
770
770
 
771
771
 
772
772
 
773
+
774
+
775
+
776
+
777
+
778
+
779
+
780
+
781
+
782
+
783
+
784
+
785
+
786
+
787
+
788
+
789
+
790
+
791
+
792
+
793
+
773
794
  * @example
774
795
  * // Track queue length
775
796
  * const q = new Queue<number>();
@@ -796,6 +817,27 @@ var _Queue = class _Queue extends LinearBase {
796
817
 
797
818
 
798
819
 
820
+
821
+
822
+
823
+
824
+
825
+
826
+
827
+
828
+
829
+
830
+
831
+
832
+
833
+
834
+
835
+
836
+
837
+
838
+
839
+
840
+
799
841
  * @example
800
842
  * // View the front element
801
843
  * const q = new Queue<string>(['first', 'second', 'third']);
@@ -838,6 +880,27 @@ var _Queue = class _Queue extends LinearBase {
838
880
 
839
881
 
840
882
 
883
+
884
+
885
+
886
+
887
+
888
+
889
+
890
+
891
+
892
+
893
+
894
+
895
+
896
+
897
+
898
+
899
+
900
+
901
+
902
+
903
+
841
904
  * @example
842
905
  * // Queue for...of iteration and isEmpty check
843
906
  * const queue = new Queue<string>(['A', 'B', 'C', 'D']);
@@ -876,6 +939,27 @@ var _Queue = class _Queue extends LinearBase {
876
939
 
877
940
 
878
941
 
942
+
943
+
944
+
945
+
946
+
947
+
948
+
949
+
950
+
951
+
952
+
953
+
954
+
955
+
956
+
957
+
958
+
959
+
960
+
961
+
962
+
879
963
  * @example
880
964
  * // basic Queue creation and push operation
881
965
  * // Create a simple Queue with initial values
@@ -921,6 +1005,27 @@ var _Queue = class _Queue extends LinearBase {
921
1005
 
922
1006
 
923
1007
 
1008
+
1009
+
1010
+
1011
+
1012
+
1013
+
1014
+
1015
+
1016
+
1017
+
1018
+
1019
+
1020
+
1021
+
1022
+
1023
+
1024
+
1025
+
1026
+
1027
+
1028
+
924
1029
  * @example
925
1030
  * // Queue shift and peek operations
926
1031
  * const queue = new Queue<number>([10, 20, 30, 40]);
@@ -956,6 +1061,27 @@ var _Queue = class _Queue extends LinearBase {
956
1061
 
957
1062
 
958
1063
 
1064
+
1065
+
1066
+
1067
+
1068
+
1069
+
1070
+
1071
+
1072
+
1073
+
1074
+
1075
+
1076
+
1077
+
1078
+
1079
+
1080
+
1081
+
1082
+
1083
+
1084
+
959
1085
  * @example
960
1086
  * // Remove specific element
961
1087
  * const q = new Queue<number>([1, 2, 3, 2]);
@@ -984,6 +1110,27 @@ var _Queue = class _Queue extends LinearBase {
984
1110
 
985
1111
 
986
1112
 
1113
+
1114
+
1115
+
1116
+
1117
+
1118
+
1119
+
1120
+
1121
+
1122
+
1123
+
1124
+
1125
+
1126
+
1127
+
1128
+
1129
+
1130
+
1131
+
1132
+
1133
+
987
1134
  * @example
988
1135
  * // Access element by index
989
1136
  * const q = new Queue<string>(['a', 'b', 'c']);
@@ -1053,6 +1200,27 @@ var _Queue = class _Queue extends LinearBase {
1053
1200
 
1054
1201
 
1055
1202
 
1203
+
1204
+
1205
+
1206
+
1207
+
1208
+
1209
+
1210
+
1211
+
1212
+
1213
+
1214
+
1215
+
1216
+
1217
+
1218
+
1219
+
1220
+
1221
+
1222
+
1223
+
1056
1224
  * @example
1057
1225
  * // Remove all elements
1058
1226
  * const q = new Queue<number>([1, 2, 3]);
@@ -1075,6 +1243,27 @@ var _Queue = class _Queue extends LinearBase {
1075
1243
 
1076
1244
 
1077
1245
 
1246
+
1247
+
1248
+
1249
+
1250
+
1251
+
1252
+
1253
+
1254
+
1255
+
1256
+
1257
+
1258
+
1259
+
1260
+
1261
+
1262
+
1263
+
1264
+
1265
+
1266
+
1078
1267
  * @example
1079
1268
  * // Reclaim unused memory
1080
1269
  * const q = new Queue<number>([1, 2, 3, 4, 5]);
@@ -1120,6 +1309,27 @@ var _Queue = class _Queue extends LinearBase {
1120
1309
 
1121
1310
 
1122
1311
 
1312
+
1313
+
1314
+
1315
+
1316
+
1317
+
1318
+
1319
+
1320
+
1321
+
1322
+
1323
+
1324
+
1325
+
1326
+
1327
+
1328
+
1329
+
1330
+
1331
+
1332
+
1123
1333
  * @example
1124
1334
  * // Create independent copy
1125
1335
  * const q = new Queue<number>([1, 2, 3]);
@@ -1149,6 +1359,27 @@ var _Queue = class _Queue extends LinearBase {
1149
1359
 
1150
1360
 
1151
1361
 
1362
+
1363
+
1364
+
1365
+
1366
+
1367
+
1368
+
1369
+
1370
+
1371
+
1372
+
1373
+
1374
+
1375
+
1376
+
1377
+
1378
+
1379
+
1380
+
1381
+
1382
+
1152
1383
  * @example
1153
1384
  * // Filter elements
1154
1385
  * const q = new Queue<number>([1, 2, 3, 4, 5]);
@@ -1182,6 +1413,27 @@ var _Queue = class _Queue extends LinearBase {
1182
1413
 
1183
1414
 
1184
1415
 
1416
+
1417
+
1418
+
1419
+
1420
+
1421
+
1422
+
1423
+
1424
+
1425
+
1426
+
1427
+
1428
+
1429
+
1430
+
1431
+
1432
+
1433
+
1434
+
1435
+
1436
+
1185
1437
  * @example
1186
1438
  * // Transform elements
1187
1439
  * const q = new Queue<number>([1, 2, 3]);
@@ -1666,6 +1918,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1666
1918
 
1667
1919
 
1668
1920
 
1921
+
1922
+
1923
+
1924
+
1925
+
1926
+
1927
+
1928
+
1929
+
1930
+
1931
+
1932
+
1933
+
1934
+
1935
+
1936
+
1937
+
1938
+
1939
+
1940
+
1941
+
1669
1942
  * @example
1670
1943
  * // Add a single node
1671
1944
  * const tree = new BinaryTree<number>();
@@ -1696,6 +1969,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1696
1969
 
1697
1970
 
1698
1971
 
1972
+
1973
+
1974
+
1975
+
1976
+
1977
+
1978
+
1979
+
1980
+
1981
+
1982
+
1983
+
1984
+
1985
+
1986
+
1987
+
1988
+
1989
+
1990
+
1991
+
1992
+
1699
1993
  * @example
1700
1994
  * // basic BinaryTree creation and insertion
1701
1995
  * // Create a BinaryTree with entries
@@ -1778,6 +2072,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1778
2072
 
1779
2073
 
1780
2074
 
2075
+
2076
+
2077
+
2078
+
2079
+
2080
+
2081
+
2082
+
2083
+
2084
+
2085
+
2086
+
2087
+
2088
+
2089
+
2090
+
2091
+
2092
+
2093
+
2094
+
2095
+
1781
2096
  * @example
1782
2097
  * // Bulk add
1783
2098
  * const tree = new BinaryTree<number>();
@@ -1796,6 +2111,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1796
2111
  * @returns An array of booleans indicating the success of each individual `set` operation.
1797
2112
 
1798
2113
 
2114
+
2115
+
2116
+
2117
+
2118
+
2119
+
2120
+
2121
+
2122
+
2123
+
2124
+
2125
+
2126
+
2127
+
2128
+
2129
+
2130
+
2131
+
2132
+
2133
+
2134
+
1799
2135
  * @example
1800
2136
  * // Set multiple entries
1801
2137
  * const tree = new BinaryTree<number, string>();
@@ -1835,6 +2171,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1835
2171
 
1836
2172
 
1837
2173
 
2174
+
2175
+
2176
+
2177
+
2178
+
2179
+
2180
+
2181
+
2182
+
2183
+
2184
+
2185
+
2186
+
2187
+
2188
+
2189
+
2190
+
2191
+
2192
+
2193
+
2194
+
1838
2195
  * @example
1839
2196
  * // Combine trees
1840
2197
  * const t1 = new BinaryTree<number>([1, 2]);
@@ -1873,6 +2230,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1873
2230
 
1874
2231
 
1875
2232
 
2233
+
2234
+
2235
+
2236
+
2237
+
2238
+
2239
+
2240
+
2241
+
2242
+
2243
+
2244
+
2245
+
2246
+
2247
+
2248
+
2249
+
2250
+
2251
+
2252
+
2253
+
1876
2254
  * @example
1877
2255
  * // Remove a node
1878
2256
  * const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
@@ -1989,6 +2367,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1989
2367
 
1990
2368
 
1991
2369
 
2370
+
2371
+
2372
+
2373
+
2374
+
2375
+
2376
+
2377
+
2378
+
2379
+
2380
+
2381
+
2382
+
2383
+
2384
+
2385
+
2386
+
2387
+
2388
+
2389
+
2390
+
1992
2391
  * @example
1993
2392
  * // Get node by key
1994
2393
  * const tree = new BinaryTree<number, string>([[1, 'root'], [2, 'child']]);
@@ -2023,6 +2422,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2023
2422
 
2024
2423
 
2025
2424
 
2425
+
2426
+
2427
+
2428
+
2429
+
2430
+
2431
+
2432
+
2433
+
2434
+
2435
+
2436
+
2437
+
2438
+
2439
+
2440
+
2441
+
2442
+
2443
+
2444
+
2445
+
2026
2446
  * @example
2027
2447
  * // Retrieve value by key
2028
2448
  * const tree = new BinaryTree<number, string>([[1, 'root'], [2, 'left'], [3, 'right']]);
@@ -2060,6 +2480,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2060
2480
 
2061
2481
 
2062
2482
 
2483
+
2484
+
2485
+
2486
+
2487
+
2488
+
2489
+
2490
+
2491
+
2492
+
2493
+
2494
+
2495
+
2496
+
2497
+
2498
+
2499
+
2500
+
2501
+
2502
+
2503
+
2063
2504
  * @example
2064
2505
  * // Remove all nodes
2065
2506
  * const tree = new BinaryTree<number>([1, 2, 3]);
@@ -2084,6 +2525,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2084
2525
 
2085
2526
 
2086
2527
 
2528
+
2529
+
2530
+
2531
+
2532
+
2533
+
2534
+
2535
+
2536
+
2537
+
2538
+
2539
+
2540
+
2541
+
2542
+
2543
+
2544
+
2545
+
2546
+
2547
+
2548
+
2087
2549
  * @example
2088
2550
  * // Check empty
2089
2551
  * console.log(new BinaryTree().isEmpty()); // true;
@@ -2117,6 +2579,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2117
2579
 
2118
2580
 
2119
2581
 
2582
+
2583
+
2584
+
2585
+
2586
+
2587
+
2588
+
2589
+
2590
+
2591
+
2592
+
2593
+
2594
+
2595
+
2596
+
2597
+
2598
+
2599
+
2600
+
2601
+
2602
+
2120
2603
  * @example
2121
2604
  * // Check BST property
2122
2605
  * const tree = new BinaryTree<number>([1, 2, 3]);
@@ -2177,6 +2660,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2177
2660
 
2178
2661
 
2179
2662
 
2663
+
2664
+
2665
+
2666
+
2667
+
2668
+
2669
+
2670
+
2671
+
2672
+
2673
+
2674
+
2675
+
2676
+
2677
+
2678
+
2679
+
2680
+
2681
+
2682
+
2683
+
2180
2684
  * @example
2181
2685
  * // Get depth of a node
2182
2686
  * const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
@@ -2214,6 +2718,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2214
2718
 
2215
2719
 
2216
2720
 
2721
+
2722
+
2723
+
2724
+
2725
+
2726
+
2727
+
2728
+
2729
+
2730
+
2731
+
2732
+
2733
+
2734
+
2735
+
2736
+
2737
+
2738
+
2739
+
2740
+
2741
+
2217
2742
  * @example
2218
2743
  * // Get tree height
2219
2744
  * const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
@@ -2667,6 +3192,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2667
3192
 
2668
3193
 
2669
3194
 
3195
+
3196
+
3197
+
3198
+
3199
+
3200
+
3201
+
3202
+
3203
+
3204
+
3205
+
3206
+
3207
+
3208
+
3209
+
3210
+
3211
+
3212
+
3213
+
3214
+
3215
+
2670
3216
  * @example
2671
3217
  * // Deep copy
2672
3218
  * const tree = new BinaryTree<number>([1, 2, 3]);
@@ -2695,6 +3241,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2695
3241
 
2696
3242
 
2697
3243
 
3244
+
3245
+
3246
+
3247
+
3248
+
3249
+
3250
+
3251
+
3252
+
3253
+
3254
+
3255
+
3256
+
3257
+
3258
+
3259
+
3260
+
3261
+
3262
+
3263
+
3264
+
2698
3265
  * @example
2699
3266
  * // Filter nodes by condition
2700
3267
  * const tree = new BinaryTree<number>([1, 2, 3, 4]);
@@ -2727,6 +3294,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2727
3294
 
2728
3295
 
2729
3296
 
3297
+
3298
+
3299
+
3300
+
3301
+
3302
+
3303
+
3304
+
3305
+
3306
+
3307
+
3308
+
3309
+
3310
+
3311
+
3312
+
3313
+
3314
+
3315
+
3316
+
3317
+
2730
3318
  * @example
2731
3319
  * // Transform to new tree
2732
3320
  * const tree = new BinaryTree<number, number>([[1, 10], [2, 20]]);
@@ -2784,6 +3372,27 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
2784
3372
 
2785
3373
 
2786
3374
 
3375
+
3376
+
3377
+
3378
+
3379
+
3380
+
3381
+
3382
+
3383
+
3384
+
3385
+
3386
+
3387
+
3388
+
3389
+
3390
+
3391
+
3392
+
3393
+
3394
+
3395
+
2787
3396
  * @example
2788
3397
  * // Display tree
2789
3398
  * const tree = new BinaryTree<number>([1, 2, 3]);