avl-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.
- package/dist/cjs/index.cjs +1096 -4
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +1096 -4
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +1096 -4
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +1096 -4
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/data-structures/base/index.d.ts +1 -0
- package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
- package/dist/types/data-structures/base/linear-base.d.ts +3 -3
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +252 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +294 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +527 -2
- package/dist/types/data-structures/binary-tree/bst.d.ts +505 -1
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +399 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +126 -1
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +2881 -382
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +2867 -347
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2328 -312
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +2671 -277
- package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
- package/dist/types/data-structures/graph/directed-graph.d.ts +210 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +189 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +241 -10
- package/dist/types/data-structures/heap/heap.d.ts +294 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +360 -3
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +318 -3
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +380 -2
- package/dist/types/data-structures/matrix/matrix.d.ts +168 -0
- package/dist/types/data-structures/queue/deque.d.ts +319 -4
- package/dist/types/data-structures/queue/queue.d.ts +252 -0
- package/dist/types/data-structures/stack/stack.d.ts +210 -0
- package/dist/types/data-structures/trie/trie.d.ts +256 -4
- package/dist/types/interfaces/graph.d.ts +1 -1
- package/dist/types/types/common.d.ts +2 -2
- package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
- package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
- package/dist/types/types/utils/validate-type.d.ts +4 -4
- package/dist/umd/avl-tree-typed.js +1096 -4
- package/dist/umd/avl-tree-typed.js.map +1 -1
- package/dist/umd/avl-tree-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/data-structures/base/index.ts +1 -0
- package/src/data-structures/base/iterable-entry-base.ts +8 -8
- package/src/data-structures/base/linear-base.ts +3 -3
- package/src/data-structures/binary-tree/avl-tree.ts +252 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +295 -1
- package/src/data-structures/binary-tree/binary-tree.ts +527 -2
- package/src/data-structures/binary-tree/bst.ts +505 -1
- package/src/data-structures/binary-tree/red-black-tree.ts +399 -0
- package/src/data-structures/binary-tree/segment-tree.ts +127 -2
- package/src/data-structures/binary-tree/tree-map.ts +2958 -459
- package/src/data-structures/binary-tree/tree-multi-map.ts +3069 -549
- package/src/data-structures/binary-tree/tree-multi-set.ts +2476 -460
- package/src/data-structures/binary-tree/tree-set.ts +2816 -422
- package/src/data-structures/graph/abstract-graph.ts +4 -4
- package/src/data-structures/graph/directed-graph.ts +210 -0
- package/src/data-structures/graph/undirected-graph.ts +189 -0
- package/src/data-structures/hash/hash-map.ts +246 -15
- package/src/data-structures/heap/heap.ts +294 -0
- package/src/data-structures/linked-list/doubly-linked-list.ts +360 -3
- package/src/data-structures/linked-list/singly-linked-list.ts +318 -3
- package/src/data-structures/linked-list/skip-linked-list.ts +380 -2
- package/src/data-structures/matrix/matrix.ts +169 -1
- package/src/data-structures/queue/deque.ts +320 -5
- package/src/data-structures/queue/queue.ts +252 -0
- package/src/data-structures/stack/stack.ts +210 -0
- package/src/data-structures/trie/trie.ts +257 -5
- package/src/interfaces/graph.ts +1 -1
- package/src/types/common.ts +2 -2
- package/src/types/data-structures/heap/heap.ts +1 -0
- package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
- package/src/types/utils/validate-type.ts +4 -4
package/dist/cjs/index.cjs
CHANGED
|
@@ -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]);
|
|
@@ -1660,10 +1912,31 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1660
1912
|
|
|
1661
1913
|
|
|
1662
1914
|
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1915
|
+
|
|
1916
|
+
|
|
1917
|
+
|
|
1918
|
+
|
|
1919
|
+
|
|
1920
|
+
|
|
1921
|
+
|
|
1922
|
+
|
|
1923
|
+
|
|
1924
|
+
|
|
1925
|
+
|
|
1926
|
+
|
|
1927
|
+
|
|
1928
|
+
|
|
1929
|
+
|
|
1930
|
+
|
|
1931
|
+
|
|
1932
|
+
|
|
1933
|
+
|
|
1934
|
+
|
|
1935
|
+
|
|
1936
|
+
* @example
|
|
1937
|
+
* // Add a single node
|
|
1938
|
+
* const tree = new BinaryTree<number>();
|
|
1939
|
+
* tree.add(1);
|
|
1667
1940
|
* tree.add(2);
|
|
1668
1941
|
* tree.add(3);
|
|
1669
1942
|
* console.log(tree.size); // 3;
|
|
@@ -1690,6 +1963,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1690
1963
|
|
|
1691
1964
|
|
|
1692
1965
|
|
|
1966
|
+
|
|
1967
|
+
|
|
1968
|
+
|
|
1969
|
+
|
|
1970
|
+
|
|
1971
|
+
|
|
1972
|
+
|
|
1973
|
+
|
|
1974
|
+
|
|
1975
|
+
|
|
1976
|
+
|
|
1977
|
+
|
|
1978
|
+
|
|
1979
|
+
|
|
1980
|
+
|
|
1981
|
+
|
|
1982
|
+
|
|
1983
|
+
|
|
1984
|
+
|
|
1985
|
+
|
|
1986
|
+
|
|
1693
1987
|
* @example
|
|
1694
1988
|
* // basic BinaryTree creation and insertion
|
|
1695
1989
|
* // Create a BinaryTree with entries
|
|
@@ -1772,6 +2066,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1772
2066
|
|
|
1773
2067
|
|
|
1774
2068
|
|
|
2069
|
+
|
|
2070
|
+
|
|
2071
|
+
|
|
2072
|
+
|
|
2073
|
+
|
|
2074
|
+
|
|
2075
|
+
|
|
2076
|
+
|
|
2077
|
+
|
|
2078
|
+
|
|
2079
|
+
|
|
2080
|
+
|
|
2081
|
+
|
|
2082
|
+
|
|
2083
|
+
|
|
2084
|
+
|
|
2085
|
+
|
|
2086
|
+
|
|
2087
|
+
|
|
2088
|
+
|
|
2089
|
+
|
|
1775
2090
|
* @example
|
|
1776
2091
|
* // Bulk add
|
|
1777
2092
|
* const tree = new BinaryTree<number>();
|
|
@@ -1790,6 +2105,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1790
2105
|
* @returns An array of booleans indicating the success of each individual `set` operation.
|
|
1791
2106
|
|
|
1792
2107
|
|
|
2108
|
+
|
|
2109
|
+
|
|
2110
|
+
|
|
2111
|
+
|
|
2112
|
+
|
|
2113
|
+
|
|
2114
|
+
|
|
2115
|
+
|
|
2116
|
+
|
|
2117
|
+
|
|
2118
|
+
|
|
2119
|
+
|
|
2120
|
+
|
|
2121
|
+
|
|
2122
|
+
|
|
2123
|
+
|
|
2124
|
+
|
|
2125
|
+
|
|
2126
|
+
|
|
2127
|
+
|
|
2128
|
+
|
|
1793
2129
|
* @example
|
|
1794
2130
|
* // Set multiple entries
|
|
1795
2131
|
* const tree = new BinaryTree<number, string>();
|
|
@@ -1829,6 +2165,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1829
2165
|
|
|
1830
2166
|
|
|
1831
2167
|
|
|
2168
|
+
|
|
2169
|
+
|
|
2170
|
+
|
|
2171
|
+
|
|
2172
|
+
|
|
2173
|
+
|
|
2174
|
+
|
|
2175
|
+
|
|
2176
|
+
|
|
2177
|
+
|
|
2178
|
+
|
|
2179
|
+
|
|
2180
|
+
|
|
2181
|
+
|
|
2182
|
+
|
|
2183
|
+
|
|
2184
|
+
|
|
2185
|
+
|
|
2186
|
+
|
|
2187
|
+
|
|
2188
|
+
|
|
1832
2189
|
* @example
|
|
1833
2190
|
* // Combine trees
|
|
1834
2191
|
* const t1 = new BinaryTree<number>([1, 2]);
|
|
@@ -1867,6 +2224,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1867
2224
|
|
|
1868
2225
|
|
|
1869
2226
|
|
|
2227
|
+
|
|
2228
|
+
|
|
2229
|
+
|
|
2230
|
+
|
|
2231
|
+
|
|
2232
|
+
|
|
2233
|
+
|
|
2234
|
+
|
|
2235
|
+
|
|
2236
|
+
|
|
2237
|
+
|
|
2238
|
+
|
|
2239
|
+
|
|
2240
|
+
|
|
2241
|
+
|
|
2242
|
+
|
|
2243
|
+
|
|
2244
|
+
|
|
2245
|
+
|
|
2246
|
+
|
|
2247
|
+
|
|
1870
2248
|
* @example
|
|
1871
2249
|
* // Remove a node
|
|
1872
2250
|
* const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
|
|
@@ -1983,6 +2361,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1983
2361
|
|
|
1984
2362
|
|
|
1985
2363
|
|
|
2364
|
+
|
|
2365
|
+
|
|
2366
|
+
|
|
2367
|
+
|
|
2368
|
+
|
|
2369
|
+
|
|
2370
|
+
|
|
2371
|
+
|
|
2372
|
+
|
|
2373
|
+
|
|
2374
|
+
|
|
2375
|
+
|
|
2376
|
+
|
|
2377
|
+
|
|
2378
|
+
|
|
2379
|
+
|
|
2380
|
+
|
|
2381
|
+
|
|
2382
|
+
|
|
2383
|
+
|
|
2384
|
+
|
|
1986
2385
|
* @example
|
|
1987
2386
|
* // Get node by key
|
|
1988
2387
|
* const tree = new BinaryTree<number, string>([[1, 'root'], [2, 'child']]);
|
|
@@ -2017,6 +2416,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2017
2416
|
|
|
2018
2417
|
|
|
2019
2418
|
|
|
2419
|
+
|
|
2420
|
+
|
|
2421
|
+
|
|
2422
|
+
|
|
2423
|
+
|
|
2424
|
+
|
|
2425
|
+
|
|
2426
|
+
|
|
2427
|
+
|
|
2428
|
+
|
|
2429
|
+
|
|
2430
|
+
|
|
2431
|
+
|
|
2432
|
+
|
|
2433
|
+
|
|
2434
|
+
|
|
2435
|
+
|
|
2436
|
+
|
|
2437
|
+
|
|
2438
|
+
|
|
2439
|
+
|
|
2020
2440
|
* @example
|
|
2021
2441
|
* // Retrieve value by key
|
|
2022
2442
|
* const tree = new BinaryTree<number, string>([[1, 'root'], [2, 'left'], [3, 'right']]);
|
|
@@ -2053,6 +2473,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2053
2473
|
|
|
2054
2474
|
|
|
2055
2475
|
|
|
2476
|
+
|
|
2477
|
+
|
|
2478
|
+
|
|
2479
|
+
|
|
2480
|
+
|
|
2481
|
+
|
|
2482
|
+
|
|
2483
|
+
|
|
2484
|
+
|
|
2485
|
+
|
|
2486
|
+
|
|
2487
|
+
|
|
2488
|
+
|
|
2489
|
+
|
|
2490
|
+
|
|
2491
|
+
|
|
2492
|
+
|
|
2493
|
+
|
|
2494
|
+
|
|
2495
|
+
|
|
2496
|
+
|
|
2056
2497
|
* @example
|
|
2057
2498
|
* // Remove all nodes
|
|
2058
2499
|
* const tree = new BinaryTree<number>([1, 2, 3]);
|
|
@@ -2077,6 +2518,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2077
2518
|
|
|
2078
2519
|
|
|
2079
2520
|
|
|
2521
|
+
|
|
2522
|
+
|
|
2523
|
+
|
|
2524
|
+
|
|
2525
|
+
|
|
2526
|
+
|
|
2527
|
+
|
|
2528
|
+
|
|
2529
|
+
|
|
2530
|
+
|
|
2531
|
+
|
|
2532
|
+
|
|
2533
|
+
|
|
2534
|
+
|
|
2535
|
+
|
|
2536
|
+
|
|
2537
|
+
|
|
2538
|
+
|
|
2539
|
+
|
|
2540
|
+
|
|
2541
|
+
|
|
2080
2542
|
* @example
|
|
2081
2543
|
* // Check empty
|
|
2082
2544
|
* console.log(new BinaryTree().isEmpty()); // true;
|
|
@@ -2110,6 +2572,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2110
2572
|
|
|
2111
2573
|
|
|
2112
2574
|
|
|
2575
|
+
|
|
2576
|
+
|
|
2577
|
+
|
|
2578
|
+
|
|
2579
|
+
|
|
2580
|
+
|
|
2581
|
+
|
|
2582
|
+
|
|
2583
|
+
|
|
2584
|
+
|
|
2585
|
+
|
|
2586
|
+
|
|
2587
|
+
|
|
2588
|
+
|
|
2589
|
+
|
|
2590
|
+
|
|
2591
|
+
|
|
2592
|
+
|
|
2593
|
+
|
|
2594
|
+
|
|
2595
|
+
|
|
2113
2596
|
* @example
|
|
2114
2597
|
* // Check BST property
|
|
2115
2598
|
* const tree = new BinaryTree<number>([1, 2, 3]);
|
|
@@ -2170,6 +2653,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2170
2653
|
|
|
2171
2654
|
|
|
2172
2655
|
|
|
2656
|
+
|
|
2657
|
+
|
|
2658
|
+
|
|
2659
|
+
|
|
2660
|
+
|
|
2661
|
+
|
|
2662
|
+
|
|
2663
|
+
|
|
2664
|
+
|
|
2665
|
+
|
|
2666
|
+
|
|
2667
|
+
|
|
2668
|
+
|
|
2669
|
+
|
|
2670
|
+
|
|
2671
|
+
|
|
2672
|
+
|
|
2673
|
+
|
|
2674
|
+
|
|
2675
|
+
|
|
2676
|
+
|
|
2173
2677
|
* @example
|
|
2174
2678
|
* // Get depth of a node
|
|
2175
2679
|
* const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
|
|
@@ -2207,6 +2711,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2207
2711
|
|
|
2208
2712
|
|
|
2209
2713
|
|
|
2714
|
+
|
|
2715
|
+
|
|
2716
|
+
|
|
2717
|
+
|
|
2718
|
+
|
|
2719
|
+
|
|
2720
|
+
|
|
2721
|
+
|
|
2722
|
+
|
|
2723
|
+
|
|
2724
|
+
|
|
2725
|
+
|
|
2726
|
+
|
|
2727
|
+
|
|
2728
|
+
|
|
2729
|
+
|
|
2730
|
+
|
|
2731
|
+
|
|
2732
|
+
|
|
2733
|
+
|
|
2734
|
+
|
|
2210
2735
|
* @example
|
|
2211
2736
|
* // Get tree height
|
|
2212
2737
|
* const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
|
|
@@ -2660,6 +3185,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2660
3185
|
|
|
2661
3186
|
|
|
2662
3187
|
|
|
3188
|
+
|
|
3189
|
+
|
|
3190
|
+
|
|
3191
|
+
|
|
3192
|
+
|
|
3193
|
+
|
|
3194
|
+
|
|
3195
|
+
|
|
3196
|
+
|
|
3197
|
+
|
|
3198
|
+
|
|
3199
|
+
|
|
3200
|
+
|
|
3201
|
+
|
|
3202
|
+
|
|
3203
|
+
|
|
3204
|
+
|
|
3205
|
+
|
|
3206
|
+
|
|
3207
|
+
|
|
3208
|
+
|
|
2663
3209
|
* @example
|
|
2664
3210
|
* // Deep copy
|
|
2665
3211
|
* const tree = new BinaryTree<number>([1, 2, 3]);
|
|
@@ -2688,6 +3234,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2688
3234
|
|
|
2689
3235
|
|
|
2690
3236
|
|
|
3237
|
+
|
|
3238
|
+
|
|
3239
|
+
|
|
3240
|
+
|
|
3241
|
+
|
|
3242
|
+
|
|
3243
|
+
|
|
3244
|
+
|
|
3245
|
+
|
|
3246
|
+
|
|
3247
|
+
|
|
3248
|
+
|
|
3249
|
+
|
|
3250
|
+
|
|
3251
|
+
|
|
3252
|
+
|
|
3253
|
+
|
|
3254
|
+
|
|
3255
|
+
|
|
3256
|
+
|
|
3257
|
+
|
|
2691
3258
|
* @example
|
|
2692
3259
|
* // Filter nodes by condition
|
|
2693
3260
|
* const tree = new BinaryTree<number>([1, 2, 3, 4]);
|
|
@@ -2720,6 +3287,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2720
3287
|
|
|
2721
3288
|
|
|
2722
3289
|
|
|
3290
|
+
|
|
3291
|
+
|
|
3292
|
+
|
|
3293
|
+
|
|
3294
|
+
|
|
3295
|
+
|
|
3296
|
+
|
|
3297
|
+
|
|
3298
|
+
|
|
3299
|
+
|
|
3300
|
+
|
|
3301
|
+
|
|
3302
|
+
|
|
3303
|
+
|
|
3304
|
+
|
|
3305
|
+
|
|
3306
|
+
|
|
3307
|
+
|
|
3308
|
+
|
|
3309
|
+
|
|
3310
|
+
|
|
2723
3311
|
* @example
|
|
2724
3312
|
* // Transform to new tree
|
|
2725
3313
|
* const tree = new BinaryTree<number, number>([[1, 10], [2, 20]]);
|
|
@@ -2777,6 +3365,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2777
3365
|
|
|
2778
3366
|
|
|
2779
3367
|
|
|
3368
|
+
|
|
3369
|
+
|
|
3370
|
+
|
|
3371
|
+
|
|
3372
|
+
|
|
3373
|
+
|
|
3374
|
+
|
|
3375
|
+
|
|
3376
|
+
|
|
3377
|
+
|
|
3378
|
+
|
|
3379
|
+
|
|
3380
|
+
|
|
3381
|
+
|
|
3382
|
+
|
|
3383
|
+
|
|
3384
|
+
|
|
3385
|
+
|
|
3386
|
+
|
|
3387
|
+
|
|
3388
|
+
|
|
2780
3389
|
* @example
|
|
2781
3390
|
* // Display tree
|
|
2782
3391
|
* const tree = new BinaryTree<number>([1, 2, 3]);
|
|
@@ -3548,6 +4157,48 @@ var BST = class extends BinaryTree {
|
|
|
3548
4157
|
|
|
3549
4158
|
|
|
3550
4159
|
|
|
4160
|
+
|
|
4161
|
+
|
|
4162
|
+
|
|
4163
|
+
|
|
4164
|
+
|
|
4165
|
+
|
|
4166
|
+
|
|
4167
|
+
|
|
4168
|
+
|
|
4169
|
+
|
|
4170
|
+
|
|
4171
|
+
|
|
4172
|
+
|
|
4173
|
+
|
|
4174
|
+
|
|
4175
|
+
|
|
4176
|
+
|
|
4177
|
+
|
|
4178
|
+
|
|
4179
|
+
|
|
4180
|
+
|
|
4181
|
+
|
|
4182
|
+
|
|
4183
|
+
|
|
4184
|
+
|
|
4185
|
+
|
|
4186
|
+
|
|
4187
|
+
|
|
4188
|
+
|
|
4189
|
+
|
|
4190
|
+
|
|
4191
|
+
|
|
4192
|
+
|
|
4193
|
+
|
|
4194
|
+
|
|
4195
|
+
|
|
4196
|
+
|
|
4197
|
+
|
|
4198
|
+
|
|
4199
|
+
|
|
4200
|
+
|
|
4201
|
+
|
|
3551
4202
|
* @example
|
|
3552
4203
|
* // Get node object by key
|
|
3553
4204
|
* const bst = new BST<number, string>([[5, 'root'], [3, 'left'], [7, 'right']]);
|
|
@@ -3729,6 +4380,69 @@ var BST = class extends BinaryTree {
|
|
|
3729
4380
|
|
|
3730
4381
|
|
|
3731
4382
|
|
|
4383
|
+
|
|
4384
|
+
|
|
4385
|
+
|
|
4386
|
+
|
|
4387
|
+
|
|
4388
|
+
|
|
4389
|
+
|
|
4390
|
+
|
|
4391
|
+
|
|
4392
|
+
|
|
4393
|
+
|
|
4394
|
+
|
|
4395
|
+
|
|
4396
|
+
|
|
4397
|
+
|
|
4398
|
+
|
|
4399
|
+
|
|
4400
|
+
|
|
4401
|
+
|
|
4402
|
+
|
|
4403
|
+
|
|
4404
|
+
|
|
4405
|
+
|
|
4406
|
+
|
|
4407
|
+
|
|
4408
|
+
|
|
4409
|
+
|
|
4410
|
+
|
|
4411
|
+
|
|
4412
|
+
|
|
4413
|
+
|
|
4414
|
+
|
|
4415
|
+
|
|
4416
|
+
|
|
4417
|
+
|
|
4418
|
+
|
|
4419
|
+
|
|
4420
|
+
|
|
4421
|
+
|
|
4422
|
+
|
|
4423
|
+
|
|
4424
|
+
|
|
4425
|
+
|
|
4426
|
+
|
|
4427
|
+
|
|
4428
|
+
|
|
4429
|
+
|
|
4430
|
+
|
|
4431
|
+
|
|
4432
|
+
|
|
4433
|
+
|
|
4434
|
+
|
|
4435
|
+
|
|
4436
|
+
|
|
4437
|
+
|
|
4438
|
+
|
|
4439
|
+
|
|
4440
|
+
|
|
4441
|
+
|
|
4442
|
+
|
|
4443
|
+
|
|
4444
|
+
|
|
4445
|
+
|
|
3732
4446
|
|
|
3733
4447
|
|
|
3734
4448
|
|
|
@@ -3798,6 +4512,48 @@ var BST = class extends BinaryTree {
|
|
|
3798
4512
|
|
|
3799
4513
|
|
|
3800
4514
|
|
|
4515
|
+
|
|
4516
|
+
|
|
4517
|
+
|
|
4518
|
+
|
|
4519
|
+
|
|
4520
|
+
|
|
4521
|
+
|
|
4522
|
+
|
|
4523
|
+
|
|
4524
|
+
|
|
4525
|
+
|
|
4526
|
+
|
|
4527
|
+
|
|
4528
|
+
|
|
4529
|
+
|
|
4530
|
+
|
|
4531
|
+
|
|
4532
|
+
|
|
4533
|
+
|
|
4534
|
+
|
|
4535
|
+
|
|
4536
|
+
|
|
4537
|
+
|
|
4538
|
+
|
|
4539
|
+
|
|
4540
|
+
|
|
4541
|
+
|
|
4542
|
+
|
|
4543
|
+
|
|
4544
|
+
|
|
4545
|
+
|
|
4546
|
+
|
|
4547
|
+
|
|
4548
|
+
|
|
4549
|
+
|
|
4550
|
+
|
|
4551
|
+
|
|
4552
|
+
|
|
4553
|
+
|
|
4554
|
+
|
|
4555
|
+
|
|
4556
|
+
|
|
3801
4557
|
* @example
|
|
3802
4558
|
* // Set multiple key-value pairs
|
|
3803
4559
|
* const bst = new BST<number, string>();
|
|
@@ -4061,6 +4817,27 @@ var BST = class extends BinaryTree {
|
|
|
4061
4817
|
|
|
4062
4818
|
|
|
4063
4819
|
|
|
4820
|
+
|
|
4821
|
+
|
|
4822
|
+
|
|
4823
|
+
|
|
4824
|
+
|
|
4825
|
+
|
|
4826
|
+
|
|
4827
|
+
|
|
4828
|
+
|
|
4829
|
+
|
|
4830
|
+
|
|
4831
|
+
|
|
4832
|
+
|
|
4833
|
+
|
|
4834
|
+
|
|
4835
|
+
|
|
4836
|
+
|
|
4837
|
+
|
|
4838
|
+
|
|
4839
|
+
|
|
4840
|
+
|
|
4064
4841
|
* @example
|
|
4065
4842
|
* // Rebalance the tree
|
|
4066
4843
|
* const bst = new BST<number>();
|
|
@@ -4106,6 +4883,27 @@ var BST = class extends BinaryTree {
|
|
|
4106
4883
|
|
|
4107
4884
|
|
|
4108
4885
|
|
|
4886
|
+
|
|
4887
|
+
|
|
4888
|
+
|
|
4889
|
+
|
|
4890
|
+
|
|
4891
|
+
|
|
4892
|
+
|
|
4893
|
+
|
|
4894
|
+
|
|
4895
|
+
|
|
4896
|
+
|
|
4897
|
+
|
|
4898
|
+
|
|
4899
|
+
|
|
4900
|
+
|
|
4901
|
+
|
|
4902
|
+
|
|
4903
|
+
|
|
4904
|
+
|
|
4905
|
+
|
|
4906
|
+
|
|
4109
4907
|
* @example
|
|
4110
4908
|
* // Check if tree is height-balanced
|
|
4111
4909
|
* const bst = new BST<number>([3, 1, 5, 2, 4]);
|
|
@@ -4180,6 +4978,48 @@ var BST = class extends BinaryTree {
|
|
|
4180
4978
|
|
|
4181
4979
|
|
|
4182
4980
|
|
|
4981
|
+
|
|
4982
|
+
|
|
4983
|
+
|
|
4984
|
+
|
|
4985
|
+
|
|
4986
|
+
|
|
4987
|
+
|
|
4988
|
+
|
|
4989
|
+
|
|
4990
|
+
|
|
4991
|
+
|
|
4992
|
+
|
|
4993
|
+
|
|
4994
|
+
|
|
4995
|
+
|
|
4996
|
+
|
|
4997
|
+
|
|
4998
|
+
|
|
4999
|
+
|
|
5000
|
+
|
|
5001
|
+
|
|
5002
|
+
|
|
5003
|
+
|
|
5004
|
+
|
|
5005
|
+
|
|
5006
|
+
|
|
5007
|
+
|
|
5008
|
+
|
|
5009
|
+
|
|
5010
|
+
|
|
5011
|
+
|
|
5012
|
+
|
|
5013
|
+
|
|
5014
|
+
|
|
5015
|
+
|
|
5016
|
+
|
|
5017
|
+
|
|
5018
|
+
|
|
5019
|
+
|
|
5020
|
+
|
|
5021
|
+
|
|
5022
|
+
|
|
4183
5023
|
* @example
|
|
4184
5024
|
* // Transform to new tree
|
|
4185
5025
|
* const bst = new BST<number, number>([[1, 10], [2, 20], [3, 30]]);
|
|
@@ -4856,6 +5696,90 @@ var AVLTree = class extends BST {
|
|
|
4856
5696
|
|
|
4857
5697
|
|
|
4858
5698
|
|
|
5699
|
+
|
|
5700
|
+
|
|
5701
|
+
|
|
5702
|
+
|
|
5703
|
+
|
|
5704
|
+
|
|
5705
|
+
|
|
5706
|
+
|
|
5707
|
+
|
|
5708
|
+
|
|
5709
|
+
|
|
5710
|
+
|
|
5711
|
+
|
|
5712
|
+
|
|
5713
|
+
|
|
5714
|
+
|
|
5715
|
+
|
|
5716
|
+
|
|
5717
|
+
|
|
5718
|
+
|
|
5719
|
+
|
|
5720
|
+
|
|
5721
|
+
|
|
5722
|
+
|
|
5723
|
+
|
|
5724
|
+
|
|
5725
|
+
|
|
5726
|
+
|
|
5727
|
+
|
|
5728
|
+
|
|
5729
|
+
|
|
5730
|
+
|
|
5731
|
+
|
|
5732
|
+
|
|
5733
|
+
|
|
5734
|
+
|
|
5735
|
+
|
|
5736
|
+
|
|
5737
|
+
|
|
5738
|
+
|
|
5739
|
+
|
|
5740
|
+
|
|
5741
|
+
|
|
5742
|
+
|
|
5743
|
+
|
|
5744
|
+
|
|
5745
|
+
|
|
5746
|
+
|
|
5747
|
+
|
|
5748
|
+
|
|
5749
|
+
|
|
5750
|
+
|
|
5751
|
+
|
|
5752
|
+
|
|
5753
|
+
|
|
5754
|
+
|
|
5755
|
+
|
|
5756
|
+
|
|
5757
|
+
|
|
5758
|
+
|
|
5759
|
+
|
|
5760
|
+
|
|
5761
|
+
|
|
5762
|
+
|
|
5763
|
+
|
|
5764
|
+
|
|
5765
|
+
|
|
5766
|
+
|
|
5767
|
+
|
|
5768
|
+
|
|
5769
|
+
|
|
5770
|
+
|
|
5771
|
+
|
|
5772
|
+
|
|
5773
|
+
|
|
5774
|
+
|
|
5775
|
+
|
|
5776
|
+
|
|
5777
|
+
|
|
5778
|
+
|
|
5779
|
+
|
|
5780
|
+
|
|
5781
|
+
|
|
5782
|
+
|
|
4859
5783
|
|
|
4860
5784
|
|
|
4861
5785
|
|
|
@@ -4908,6 +5832,69 @@ var AVLTree = class extends BST {
|
|
|
4908
5832
|
|
|
4909
5833
|
|
|
4910
5834
|
|
|
5835
|
+
|
|
5836
|
+
|
|
5837
|
+
|
|
5838
|
+
|
|
5839
|
+
|
|
5840
|
+
|
|
5841
|
+
|
|
5842
|
+
|
|
5843
|
+
|
|
5844
|
+
|
|
5845
|
+
|
|
5846
|
+
|
|
5847
|
+
|
|
5848
|
+
|
|
5849
|
+
|
|
5850
|
+
|
|
5851
|
+
|
|
5852
|
+
|
|
5853
|
+
|
|
5854
|
+
|
|
5855
|
+
|
|
5856
|
+
|
|
5857
|
+
|
|
5858
|
+
|
|
5859
|
+
|
|
5860
|
+
|
|
5861
|
+
|
|
5862
|
+
|
|
5863
|
+
|
|
5864
|
+
|
|
5865
|
+
|
|
5866
|
+
|
|
5867
|
+
|
|
5868
|
+
|
|
5869
|
+
|
|
5870
|
+
|
|
5871
|
+
|
|
5872
|
+
|
|
5873
|
+
|
|
5874
|
+
|
|
5875
|
+
|
|
5876
|
+
|
|
5877
|
+
|
|
5878
|
+
|
|
5879
|
+
|
|
5880
|
+
|
|
5881
|
+
|
|
5882
|
+
|
|
5883
|
+
|
|
5884
|
+
|
|
5885
|
+
|
|
5886
|
+
|
|
5887
|
+
|
|
5888
|
+
|
|
5889
|
+
|
|
5890
|
+
|
|
5891
|
+
|
|
5892
|
+
|
|
5893
|
+
|
|
5894
|
+
|
|
5895
|
+
|
|
5896
|
+
|
|
5897
|
+
|
|
4911
5898
|
|
|
4912
5899
|
|
|
4913
5900
|
|
|
@@ -4964,6 +5951,48 @@ var AVLTree = class extends BST {
|
|
|
4964
5951
|
|
|
4965
5952
|
|
|
4966
5953
|
|
|
5954
|
+
|
|
5955
|
+
|
|
5956
|
+
|
|
5957
|
+
|
|
5958
|
+
|
|
5959
|
+
|
|
5960
|
+
|
|
5961
|
+
|
|
5962
|
+
|
|
5963
|
+
|
|
5964
|
+
|
|
5965
|
+
|
|
5966
|
+
|
|
5967
|
+
|
|
5968
|
+
|
|
5969
|
+
|
|
5970
|
+
|
|
5971
|
+
|
|
5972
|
+
|
|
5973
|
+
|
|
5974
|
+
|
|
5975
|
+
|
|
5976
|
+
|
|
5977
|
+
|
|
5978
|
+
|
|
5979
|
+
|
|
5980
|
+
|
|
5981
|
+
|
|
5982
|
+
|
|
5983
|
+
|
|
5984
|
+
|
|
5985
|
+
|
|
5986
|
+
|
|
5987
|
+
|
|
5988
|
+
|
|
5989
|
+
|
|
5990
|
+
|
|
5991
|
+
|
|
5992
|
+
|
|
5993
|
+
|
|
5994
|
+
|
|
5995
|
+
|
|
4967
5996
|
* @example
|
|
4968
5997
|
* // Rebalance the tree
|
|
4969
5998
|
* const avl = new AVLTree<number>();
|
|
@@ -5026,6 +6055,69 @@ var AVLTree = class extends BST {
|
|
|
5026
6055
|
|
|
5027
6056
|
|
|
5028
6057
|
|
|
6058
|
+
|
|
6059
|
+
|
|
6060
|
+
|
|
6061
|
+
|
|
6062
|
+
|
|
6063
|
+
|
|
6064
|
+
|
|
6065
|
+
|
|
6066
|
+
|
|
6067
|
+
|
|
6068
|
+
|
|
6069
|
+
|
|
6070
|
+
|
|
6071
|
+
|
|
6072
|
+
|
|
6073
|
+
|
|
6074
|
+
|
|
6075
|
+
|
|
6076
|
+
|
|
6077
|
+
|
|
6078
|
+
|
|
6079
|
+
|
|
6080
|
+
|
|
6081
|
+
|
|
6082
|
+
|
|
6083
|
+
|
|
6084
|
+
|
|
6085
|
+
|
|
6086
|
+
|
|
6087
|
+
|
|
6088
|
+
|
|
6089
|
+
|
|
6090
|
+
|
|
6091
|
+
|
|
6092
|
+
|
|
6093
|
+
|
|
6094
|
+
|
|
6095
|
+
|
|
6096
|
+
|
|
6097
|
+
|
|
6098
|
+
|
|
6099
|
+
|
|
6100
|
+
|
|
6101
|
+
|
|
6102
|
+
|
|
6103
|
+
|
|
6104
|
+
|
|
6105
|
+
|
|
6106
|
+
|
|
6107
|
+
|
|
6108
|
+
|
|
6109
|
+
|
|
6110
|
+
|
|
6111
|
+
|
|
6112
|
+
|
|
6113
|
+
|
|
6114
|
+
|
|
6115
|
+
|
|
6116
|
+
|
|
6117
|
+
|
|
6118
|
+
|
|
6119
|
+
|
|
6120
|
+
|
|
5029
6121
|
|
|
5030
6122
|
|
|
5031
6123
|
* @example
|