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.
- package/dist/cjs/index.cjs +609 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +609 -0
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +609 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +609 -0
- 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/binary-tree-typed.js +609 -0
- package/dist/umd/binary-tree-typed.js.map +1 -1
- package/dist/umd/binary-tree-typed.min.js +5 -5
- package/dist/umd/binary-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
|
@@ -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]);
|