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
package/dist/esm/index.mjs
CHANGED
|
@@ -775,6 +775,27 @@ var Queue = class _Queue extends LinearBase {
|
|
|
775
775
|
|
|
776
776
|
|
|
777
777
|
|
|
778
|
+
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
|
|
795
|
+
|
|
796
|
+
|
|
797
|
+
|
|
798
|
+
|
|
778
799
|
* @example
|
|
779
800
|
* // Track queue length
|
|
780
801
|
* const q = new Queue<number>();
|
|
@@ -801,6 +822,27 @@ var Queue = class _Queue extends LinearBase {
|
|
|
801
822
|
|
|
802
823
|
|
|
803
824
|
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
|
|
845
|
+
|
|
804
846
|
* @example
|
|
805
847
|
* // View the front element
|
|
806
848
|
* const q = new Queue<string>(['first', 'second', 'third']);
|
|
@@ -843,6 +885,27 @@ var Queue = class _Queue extends LinearBase {
|
|
|
843
885
|
|
|
844
886
|
|
|
845
887
|
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
|
|
846
909
|
* @example
|
|
847
910
|
* // Queue for...of iteration and isEmpty check
|
|
848
911
|
* const queue = new Queue<string>(['A', 'B', 'C', 'D']);
|
|
@@ -881,6 +944,27 @@ var Queue = class _Queue extends LinearBase {
|
|
|
881
944
|
|
|
882
945
|
|
|
883
946
|
|
|
947
|
+
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
|
|
952
|
+
|
|
953
|
+
|
|
954
|
+
|
|
955
|
+
|
|
956
|
+
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
|
|
884
968
|
* @example
|
|
885
969
|
* // basic Queue creation and push operation
|
|
886
970
|
* // Create a simple Queue with initial values
|
|
@@ -926,6 +1010,27 @@ var Queue = class _Queue extends LinearBase {
|
|
|
926
1010
|
|
|
927
1011
|
|
|
928
1012
|
|
|
1013
|
+
|
|
1014
|
+
|
|
1015
|
+
|
|
1016
|
+
|
|
1017
|
+
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+
|
|
1022
|
+
|
|
1023
|
+
|
|
1024
|
+
|
|
1025
|
+
|
|
1026
|
+
|
|
1027
|
+
|
|
1028
|
+
|
|
1029
|
+
|
|
1030
|
+
|
|
1031
|
+
|
|
1032
|
+
|
|
1033
|
+
|
|
929
1034
|
* @example
|
|
930
1035
|
* // Queue shift and peek operations
|
|
931
1036
|
* const queue = new Queue<number>([10, 20, 30, 40]);
|
|
@@ -961,6 +1066,27 @@ var Queue = class _Queue extends LinearBase {
|
|
|
961
1066
|
|
|
962
1067
|
|
|
963
1068
|
|
|
1069
|
+
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
|
|
1073
|
+
|
|
1074
|
+
|
|
1075
|
+
|
|
1076
|
+
|
|
1077
|
+
|
|
1078
|
+
|
|
1079
|
+
|
|
1080
|
+
|
|
1081
|
+
|
|
1082
|
+
|
|
1083
|
+
|
|
1084
|
+
|
|
1085
|
+
|
|
1086
|
+
|
|
1087
|
+
|
|
1088
|
+
|
|
1089
|
+
|
|
964
1090
|
* @example
|
|
965
1091
|
* // Remove specific element
|
|
966
1092
|
* const q = new Queue<number>([1, 2, 3, 2]);
|
|
@@ -989,6 +1115,27 @@ var Queue = class _Queue extends LinearBase {
|
|
|
989
1115
|
|
|
990
1116
|
|
|
991
1117
|
|
|
1118
|
+
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
|
|
1122
|
+
|
|
1123
|
+
|
|
1124
|
+
|
|
1125
|
+
|
|
1126
|
+
|
|
1127
|
+
|
|
1128
|
+
|
|
1129
|
+
|
|
1130
|
+
|
|
1131
|
+
|
|
1132
|
+
|
|
1133
|
+
|
|
1134
|
+
|
|
1135
|
+
|
|
1136
|
+
|
|
1137
|
+
|
|
1138
|
+
|
|
992
1139
|
* @example
|
|
993
1140
|
* // Access element by index
|
|
994
1141
|
* const q = new Queue<string>(['a', 'b', 'c']);
|
|
@@ -1058,6 +1205,27 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1058
1205
|
|
|
1059
1206
|
|
|
1060
1207
|
|
|
1208
|
+
|
|
1209
|
+
|
|
1210
|
+
|
|
1211
|
+
|
|
1212
|
+
|
|
1213
|
+
|
|
1214
|
+
|
|
1215
|
+
|
|
1216
|
+
|
|
1217
|
+
|
|
1218
|
+
|
|
1219
|
+
|
|
1220
|
+
|
|
1221
|
+
|
|
1222
|
+
|
|
1223
|
+
|
|
1224
|
+
|
|
1225
|
+
|
|
1226
|
+
|
|
1227
|
+
|
|
1228
|
+
|
|
1061
1229
|
* @example
|
|
1062
1230
|
* // Remove all elements
|
|
1063
1231
|
* const q = new Queue<number>([1, 2, 3]);
|
|
@@ -1080,6 +1248,27 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1080
1248
|
|
|
1081
1249
|
|
|
1082
1250
|
|
|
1251
|
+
|
|
1252
|
+
|
|
1253
|
+
|
|
1254
|
+
|
|
1255
|
+
|
|
1256
|
+
|
|
1257
|
+
|
|
1258
|
+
|
|
1259
|
+
|
|
1260
|
+
|
|
1261
|
+
|
|
1262
|
+
|
|
1263
|
+
|
|
1264
|
+
|
|
1265
|
+
|
|
1266
|
+
|
|
1267
|
+
|
|
1268
|
+
|
|
1269
|
+
|
|
1270
|
+
|
|
1271
|
+
|
|
1083
1272
|
* @example
|
|
1084
1273
|
* // Reclaim unused memory
|
|
1085
1274
|
* const q = new Queue<number>([1, 2, 3, 4, 5]);
|
|
@@ -1125,6 +1314,27 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1125
1314
|
|
|
1126
1315
|
|
|
1127
1316
|
|
|
1317
|
+
|
|
1318
|
+
|
|
1319
|
+
|
|
1320
|
+
|
|
1321
|
+
|
|
1322
|
+
|
|
1323
|
+
|
|
1324
|
+
|
|
1325
|
+
|
|
1326
|
+
|
|
1327
|
+
|
|
1328
|
+
|
|
1329
|
+
|
|
1330
|
+
|
|
1331
|
+
|
|
1332
|
+
|
|
1333
|
+
|
|
1334
|
+
|
|
1335
|
+
|
|
1336
|
+
|
|
1337
|
+
|
|
1128
1338
|
* @example
|
|
1129
1339
|
* // Create independent copy
|
|
1130
1340
|
* const q = new Queue<number>([1, 2, 3]);
|
|
@@ -1154,6 +1364,27 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1154
1364
|
|
|
1155
1365
|
|
|
1156
1366
|
|
|
1367
|
+
|
|
1368
|
+
|
|
1369
|
+
|
|
1370
|
+
|
|
1371
|
+
|
|
1372
|
+
|
|
1373
|
+
|
|
1374
|
+
|
|
1375
|
+
|
|
1376
|
+
|
|
1377
|
+
|
|
1378
|
+
|
|
1379
|
+
|
|
1380
|
+
|
|
1381
|
+
|
|
1382
|
+
|
|
1383
|
+
|
|
1384
|
+
|
|
1385
|
+
|
|
1386
|
+
|
|
1387
|
+
|
|
1157
1388
|
* @example
|
|
1158
1389
|
* // Filter elements
|
|
1159
1390
|
* const q = new Queue<number>([1, 2, 3, 4, 5]);
|
|
@@ -1187,6 +1418,27 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1187
1418
|
|
|
1188
1419
|
|
|
1189
1420
|
|
|
1421
|
+
|
|
1422
|
+
|
|
1423
|
+
|
|
1424
|
+
|
|
1425
|
+
|
|
1426
|
+
|
|
1427
|
+
|
|
1428
|
+
|
|
1429
|
+
|
|
1430
|
+
|
|
1431
|
+
|
|
1432
|
+
|
|
1433
|
+
|
|
1434
|
+
|
|
1435
|
+
|
|
1436
|
+
|
|
1437
|
+
|
|
1438
|
+
|
|
1439
|
+
|
|
1440
|
+
|
|
1441
|
+
|
|
1190
1442
|
* @example
|
|
1191
1443
|
* // Transform elements
|
|
1192
1444
|
* const q = new Queue<number>([1, 2, 3]);
|
|
@@ -1663,6 +1915,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1663
1915
|
|
|
1664
1916
|
|
|
1665
1917
|
|
|
1918
|
+
|
|
1919
|
+
|
|
1920
|
+
|
|
1921
|
+
|
|
1922
|
+
|
|
1923
|
+
|
|
1924
|
+
|
|
1925
|
+
|
|
1926
|
+
|
|
1927
|
+
|
|
1928
|
+
|
|
1929
|
+
|
|
1930
|
+
|
|
1931
|
+
|
|
1932
|
+
|
|
1933
|
+
|
|
1934
|
+
|
|
1935
|
+
|
|
1936
|
+
|
|
1937
|
+
|
|
1938
|
+
|
|
1666
1939
|
* @example
|
|
1667
1940
|
* // Add a single node
|
|
1668
1941
|
* const tree = new BinaryTree<number>();
|
|
@@ -1693,6 +1966,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1693
1966
|
|
|
1694
1967
|
|
|
1695
1968
|
|
|
1969
|
+
|
|
1970
|
+
|
|
1971
|
+
|
|
1972
|
+
|
|
1973
|
+
|
|
1974
|
+
|
|
1975
|
+
|
|
1976
|
+
|
|
1977
|
+
|
|
1978
|
+
|
|
1979
|
+
|
|
1980
|
+
|
|
1981
|
+
|
|
1982
|
+
|
|
1983
|
+
|
|
1984
|
+
|
|
1985
|
+
|
|
1986
|
+
|
|
1987
|
+
|
|
1988
|
+
|
|
1989
|
+
|
|
1696
1990
|
* @example
|
|
1697
1991
|
* // basic BinaryTree creation and insertion
|
|
1698
1992
|
* // Create a BinaryTree with entries
|
|
@@ -1775,6 +2069,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1775
2069
|
|
|
1776
2070
|
|
|
1777
2071
|
|
|
2072
|
+
|
|
2073
|
+
|
|
2074
|
+
|
|
2075
|
+
|
|
2076
|
+
|
|
2077
|
+
|
|
2078
|
+
|
|
2079
|
+
|
|
2080
|
+
|
|
2081
|
+
|
|
2082
|
+
|
|
2083
|
+
|
|
2084
|
+
|
|
2085
|
+
|
|
2086
|
+
|
|
2087
|
+
|
|
2088
|
+
|
|
2089
|
+
|
|
2090
|
+
|
|
2091
|
+
|
|
2092
|
+
|
|
1778
2093
|
* @example
|
|
1779
2094
|
* // Bulk add
|
|
1780
2095
|
* const tree = new BinaryTree<number>();
|
|
@@ -1793,6 +2108,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1793
2108
|
* @returns An array of booleans indicating the success of each individual `set` operation.
|
|
1794
2109
|
|
|
1795
2110
|
|
|
2111
|
+
|
|
2112
|
+
|
|
2113
|
+
|
|
2114
|
+
|
|
2115
|
+
|
|
2116
|
+
|
|
2117
|
+
|
|
2118
|
+
|
|
2119
|
+
|
|
2120
|
+
|
|
2121
|
+
|
|
2122
|
+
|
|
2123
|
+
|
|
2124
|
+
|
|
2125
|
+
|
|
2126
|
+
|
|
2127
|
+
|
|
2128
|
+
|
|
2129
|
+
|
|
2130
|
+
|
|
2131
|
+
|
|
1796
2132
|
* @example
|
|
1797
2133
|
* // Set multiple entries
|
|
1798
2134
|
* const tree = new BinaryTree<number, string>();
|
|
@@ -1832,6 +2168,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1832
2168
|
|
|
1833
2169
|
|
|
1834
2170
|
|
|
2171
|
+
|
|
2172
|
+
|
|
2173
|
+
|
|
2174
|
+
|
|
2175
|
+
|
|
2176
|
+
|
|
2177
|
+
|
|
2178
|
+
|
|
2179
|
+
|
|
2180
|
+
|
|
2181
|
+
|
|
2182
|
+
|
|
2183
|
+
|
|
2184
|
+
|
|
2185
|
+
|
|
2186
|
+
|
|
2187
|
+
|
|
2188
|
+
|
|
2189
|
+
|
|
2190
|
+
|
|
2191
|
+
|
|
1835
2192
|
* @example
|
|
1836
2193
|
* // Combine trees
|
|
1837
2194
|
* const t1 = new BinaryTree<number>([1, 2]);
|
|
@@ -1870,6 +2227,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1870
2227
|
|
|
1871
2228
|
|
|
1872
2229
|
|
|
2230
|
+
|
|
2231
|
+
|
|
2232
|
+
|
|
2233
|
+
|
|
2234
|
+
|
|
2235
|
+
|
|
2236
|
+
|
|
2237
|
+
|
|
2238
|
+
|
|
2239
|
+
|
|
2240
|
+
|
|
2241
|
+
|
|
2242
|
+
|
|
2243
|
+
|
|
2244
|
+
|
|
2245
|
+
|
|
2246
|
+
|
|
2247
|
+
|
|
2248
|
+
|
|
2249
|
+
|
|
2250
|
+
|
|
1873
2251
|
* @example
|
|
1874
2252
|
* // Remove a node
|
|
1875
2253
|
* const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
|
|
@@ -1986,6 +2364,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1986
2364
|
|
|
1987
2365
|
|
|
1988
2366
|
|
|
2367
|
+
|
|
2368
|
+
|
|
2369
|
+
|
|
2370
|
+
|
|
2371
|
+
|
|
2372
|
+
|
|
2373
|
+
|
|
2374
|
+
|
|
2375
|
+
|
|
2376
|
+
|
|
2377
|
+
|
|
2378
|
+
|
|
2379
|
+
|
|
2380
|
+
|
|
2381
|
+
|
|
2382
|
+
|
|
2383
|
+
|
|
2384
|
+
|
|
2385
|
+
|
|
2386
|
+
|
|
2387
|
+
|
|
1989
2388
|
* @example
|
|
1990
2389
|
* // Get node by key
|
|
1991
2390
|
* const tree = new BinaryTree<number, string>([[1, 'root'], [2, 'child']]);
|
|
@@ -2020,6 +2419,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2020
2419
|
|
|
2021
2420
|
|
|
2022
2421
|
|
|
2422
|
+
|
|
2423
|
+
|
|
2424
|
+
|
|
2425
|
+
|
|
2426
|
+
|
|
2427
|
+
|
|
2428
|
+
|
|
2429
|
+
|
|
2430
|
+
|
|
2431
|
+
|
|
2432
|
+
|
|
2433
|
+
|
|
2434
|
+
|
|
2435
|
+
|
|
2436
|
+
|
|
2437
|
+
|
|
2438
|
+
|
|
2439
|
+
|
|
2440
|
+
|
|
2441
|
+
|
|
2442
|
+
|
|
2023
2443
|
* @example
|
|
2024
2444
|
* // Retrieve value by key
|
|
2025
2445
|
* const tree = new BinaryTree<number, string>([[1, 'root'], [2, 'left'], [3, 'right']]);
|
|
@@ -2056,6 +2476,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2056
2476
|
|
|
2057
2477
|
|
|
2058
2478
|
|
|
2479
|
+
|
|
2480
|
+
|
|
2481
|
+
|
|
2482
|
+
|
|
2483
|
+
|
|
2484
|
+
|
|
2485
|
+
|
|
2486
|
+
|
|
2487
|
+
|
|
2488
|
+
|
|
2489
|
+
|
|
2490
|
+
|
|
2491
|
+
|
|
2492
|
+
|
|
2493
|
+
|
|
2494
|
+
|
|
2495
|
+
|
|
2496
|
+
|
|
2497
|
+
|
|
2498
|
+
|
|
2499
|
+
|
|
2059
2500
|
* @example
|
|
2060
2501
|
* // Remove all nodes
|
|
2061
2502
|
* const tree = new BinaryTree<number>([1, 2, 3]);
|
|
@@ -2080,6 +2521,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2080
2521
|
|
|
2081
2522
|
|
|
2082
2523
|
|
|
2524
|
+
|
|
2525
|
+
|
|
2526
|
+
|
|
2527
|
+
|
|
2528
|
+
|
|
2529
|
+
|
|
2530
|
+
|
|
2531
|
+
|
|
2532
|
+
|
|
2533
|
+
|
|
2534
|
+
|
|
2535
|
+
|
|
2536
|
+
|
|
2537
|
+
|
|
2538
|
+
|
|
2539
|
+
|
|
2540
|
+
|
|
2541
|
+
|
|
2542
|
+
|
|
2543
|
+
|
|
2544
|
+
|
|
2083
2545
|
* @example
|
|
2084
2546
|
* // Check empty
|
|
2085
2547
|
* console.log(new BinaryTree().isEmpty()); // true;
|
|
@@ -2113,6 +2575,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2113
2575
|
|
|
2114
2576
|
|
|
2115
2577
|
|
|
2578
|
+
|
|
2579
|
+
|
|
2580
|
+
|
|
2581
|
+
|
|
2582
|
+
|
|
2583
|
+
|
|
2584
|
+
|
|
2585
|
+
|
|
2586
|
+
|
|
2587
|
+
|
|
2588
|
+
|
|
2589
|
+
|
|
2590
|
+
|
|
2591
|
+
|
|
2592
|
+
|
|
2593
|
+
|
|
2594
|
+
|
|
2595
|
+
|
|
2596
|
+
|
|
2597
|
+
|
|
2598
|
+
|
|
2116
2599
|
* @example
|
|
2117
2600
|
* // Check BST property
|
|
2118
2601
|
* const tree = new BinaryTree<number>([1, 2, 3]);
|
|
@@ -2173,6 +2656,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2173
2656
|
|
|
2174
2657
|
|
|
2175
2658
|
|
|
2659
|
+
|
|
2660
|
+
|
|
2661
|
+
|
|
2662
|
+
|
|
2663
|
+
|
|
2664
|
+
|
|
2665
|
+
|
|
2666
|
+
|
|
2667
|
+
|
|
2668
|
+
|
|
2669
|
+
|
|
2670
|
+
|
|
2671
|
+
|
|
2672
|
+
|
|
2673
|
+
|
|
2674
|
+
|
|
2675
|
+
|
|
2676
|
+
|
|
2677
|
+
|
|
2678
|
+
|
|
2679
|
+
|
|
2176
2680
|
* @example
|
|
2177
2681
|
* // Get depth of a node
|
|
2178
2682
|
* const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
|
|
@@ -2210,6 +2714,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2210
2714
|
|
|
2211
2715
|
|
|
2212
2716
|
|
|
2717
|
+
|
|
2718
|
+
|
|
2719
|
+
|
|
2720
|
+
|
|
2721
|
+
|
|
2722
|
+
|
|
2723
|
+
|
|
2724
|
+
|
|
2725
|
+
|
|
2726
|
+
|
|
2727
|
+
|
|
2728
|
+
|
|
2729
|
+
|
|
2730
|
+
|
|
2731
|
+
|
|
2732
|
+
|
|
2733
|
+
|
|
2734
|
+
|
|
2735
|
+
|
|
2736
|
+
|
|
2737
|
+
|
|
2213
2738
|
* @example
|
|
2214
2739
|
* // Get tree height
|
|
2215
2740
|
* const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
|
|
@@ -2663,6 +3188,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2663
3188
|
|
|
2664
3189
|
|
|
2665
3190
|
|
|
3191
|
+
|
|
3192
|
+
|
|
3193
|
+
|
|
3194
|
+
|
|
3195
|
+
|
|
3196
|
+
|
|
3197
|
+
|
|
3198
|
+
|
|
3199
|
+
|
|
3200
|
+
|
|
3201
|
+
|
|
3202
|
+
|
|
3203
|
+
|
|
3204
|
+
|
|
3205
|
+
|
|
3206
|
+
|
|
3207
|
+
|
|
3208
|
+
|
|
3209
|
+
|
|
3210
|
+
|
|
3211
|
+
|
|
2666
3212
|
* @example
|
|
2667
3213
|
* // Deep copy
|
|
2668
3214
|
* const tree = new BinaryTree<number>([1, 2, 3]);
|
|
@@ -2691,6 +3237,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2691
3237
|
|
|
2692
3238
|
|
|
2693
3239
|
|
|
3240
|
+
|
|
3241
|
+
|
|
3242
|
+
|
|
3243
|
+
|
|
3244
|
+
|
|
3245
|
+
|
|
3246
|
+
|
|
3247
|
+
|
|
3248
|
+
|
|
3249
|
+
|
|
3250
|
+
|
|
3251
|
+
|
|
3252
|
+
|
|
3253
|
+
|
|
3254
|
+
|
|
3255
|
+
|
|
3256
|
+
|
|
3257
|
+
|
|
3258
|
+
|
|
3259
|
+
|
|
3260
|
+
|
|
2694
3261
|
* @example
|
|
2695
3262
|
* // Filter nodes by condition
|
|
2696
3263
|
* const tree = new BinaryTree<number>([1, 2, 3, 4]);
|
|
@@ -2723,6 +3290,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2723
3290
|
|
|
2724
3291
|
|
|
2725
3292
|
|
|
3293
|
+
|
|
3294
|
+
|
|
3295
|
+
|
|
3296
|
+
|
|
3297
|
+
|
|
3298
|
+
|
|
3299
|
+
|
|
3300
|
+
|
|
3301
|
+
|
|
3302
|
+
|
|
3303
|
+
|
|
3304
|
+
|
|
3305
|
+
|
|
3306
|
+
|
|
3307
|
+
|
|
3308
|
+
|
|
3309
|
+
|
|
3310
|
+
|
|
3311
|
+
|
|
3312
|
+
|
|
3313
|
+
|
|
2726
3314
|
* @example
|
|
2727
3315
|
* // Transform to new tree
|
|
2728
3316
|
* const tree = new BinaryTree<number, number>([[1, 10], [2, 20]]);
|
|
@@ -2780,6 +3368,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2780
3368
|
|
|
2781
3369
|
|
|
2782
3370
|
|
|
3371
|
+
|
|
3372
|
+
|
|
3373
|
+
|
|
3374
|
+
|
|
3375
|
+
|
|
3376
|
+
|
|
3377
|
+
|
|
3378
|
+
|
|
3379
|
+
|
|
3380
|
+
|
|
3381
|
+
|
|
3382
|
+
|
|
3383
|
+
|
|
3384
|
+
|
|
3385
|
+
|
|
3386
|
+
|
|
3387
|
+
|
|
3388
|
+
|
|
3389
|
+
|
|
3390
|
+
|
|
3391
|
+
|
|
2783
3392
|
* @example
|
|
2784
3393
|
* // Display tree
|
|
2785
3394
|
* const tree = new BinaryTree<number>([1, 2, 3]);
|