bst-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 +840 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +840 -0
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +840 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +840 -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/bst-typed.js +840 -0
- package/dist/umd/bst-typed.js.map +1 -1
- package/dist/umd/bst-typed.min.js +3 -3
- package/dist/umd/bst-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
|
@@ -777,6 +777,27 @@ var Queue = class _Queue extends LinearBase {
|
|
|
777
777
|
|
|
778
778
|
|
|
779
779
|
|
|
780
|
+
|
|
781
|
+
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
|
|
795
|
+
|
|
796
|
+
|
|
797
|
+
|
|
798
|
+
|
|
799
|
+
|
|
800
|
+
|
|
780
801
|
* @example
|
|
781
802
|
* // Track queue length
|
|
782
803
|
* const q = new Queue<number>();
|
|
@@ -803,6 +824,27 @@ var Queue = class _Queue extends LinearBase {
|
|
|
803
824
|
|
|
804
825
|
|
|
805
826
|
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
|
|
847
|
+
|
|
806
848
|
* @example
|
|
807
849
|
* // View the front element
|
|
808
850
|
* const q = new Queue<string>(['first', 'second', 'third']);
|
|
@@ -845,6 +887,27 @@ var Queue = class _Queue extends LinearBase {
|
|
|
845
887
|
|
|
846
888
|
|
|
847
889
|
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
|
|
910
|
+
|
|
848
911
|
* @example
|
|
849
912
|
* // Queue for...of iteration and isEmpty check
|
|
850
913
|
* const queue = new Queue<string>(['A', 'B', 'C', 'D']);
|
|
@@ -883,6 +946,27 @@ var Queue = class _Queue extends LinearBase {
|
|
|
883
946
|
|
|
884
947
|
|
|
885
948
|
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
|
|
952
|
+
|
|
953
|
+
|
|
954
|
+
|
|
955
|
+
|
|
956
|
+
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
|
|
968
|
+
|
|
969
|
+
|
|
886
970
|
* @example
|
|
887
971
|
* // basic Queue creation and push operation
|
|
888
972
|
* // Create a simple Queue with initial values
|
|
@@ -928,6 +1012,27 @@ var Queue = class _Queue extends LinearBase {
|
|
|
928
1012
|
|
|
929
1013
|
|
|
930
1014
|
|
|
1015
|
+
|
|
1016
|
+
|
|
1017
|
+
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+
|
|
1022
|
+
|
|
1023
|
+
|
|
1024
|
+
|
|
1025
|
+
|
|
1026
|
+
|
|
1027
|
+
|
|
1028
|
+
|
|
1029
|
+
|
|
1030
|
+
|
|
1031
|
+
|
|
1032
|
+
|
|
1033
|
+
|
|
1034
|
+
|
|
1035
|
+
|
|
931
1036
|
* @example
|
|
932
1037
|
* // Queue shift and peek operations
|
|
933
1038
|
* const queue = new Queue<number>([10, 20, 30, 40]);
|
|
@@ -963,6 +1068,27 @@ var Queue = class _Queue extends LinearBase {
|
|
|
963
1068
|
|
|
964
1069
|
|
|
965
1070
|
|
|
1071
|
+
|
|
1072
|
+
|
|
1073
|
+
|
|
1074
|
+
|
|
1075
|
+
|
|
1076
|
+
|
|
1077
|
+
|
|
1078
|
+
|
|
1079
|
+
|
|
1080
|
+
|
|
1081
|
+
|
|
1082
|
+
|
|
1083
|
+
|
|
1084
|
+
|
|
1085
|
+
|
|
1086
|
+
|
|
1087
|
+
|
|
1088
|
+
|
|
1089
|
+
|
|
1090
|
+
|
|
1091
|
+
|
|
966
1092
|
* @example
|
|
967
1093
|
* // Remove specific element
|
|
968
1094
|
* const q = new Queue<number>([1, 2, 3, 2]);
|
|
@@ -991,6 +1117,27 @@ var Queue = class _Queue extends LinearBase {
|
|
|
991
1117
|
|
|
992
1118
|
|
|
993
1119
|
|
|
1120
|
+
|
|
1121
|
+
|
|
1122
|
+
|
|
1123
|
+
|
|
1124
|
+
|
|
1125
|
+
|
|
1126
|
+
|
|
1127
|
+
|
|
1128
|
+
|
|
1129
|
+
|
|
1130
|
+
|
|
1131
|
+
|
|
1132
|
+
|
|
1133
|
+
|
|
1134
|
+
|
|
1135
|
+
|
|
1136
|
+
|
|
1137
|
+
|
|
1138
|
+
|
|
1139
|
+
|
|
1140
|
+
|
|
994
1141
|
* @example
|
|
995
1142
|
* // Access element by index
|
|
996
1143
|
* const q = new Queue<string>(['a', 'b', 'c']);
|
|
@@ -1060,6 +1207,27 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1060
1207
|
|
|
1061
1208
|
|
|
1062
1209
|
|
|
1210
|
+
|
|
1211
|
+
|
|
1212
|
+
|
|
1213
|
+
|
|
1214
|
+
|
|
1215
|
+
|
|
1216
|
+
|
|
1217
|
+
|
|
1218
|
+
|
|
1219
|
+
|
|
1220
|
+
|
|
1221
|
+
|
|
1222
|
+
|
|
1223
|
+
|
|
1224
|
+
|
|
1225
|
+
|
|
1226
|
+
|
|
1227
|
+
|
|
1228
|
+
|
|
1229
|
+
|
|
1230
|
+
|
|
1063
1231
|
* @example
|
|
1064
1232
|
* // Remove all elements
|
|
1065
1233
|
* const q = new Queue<number>([1, 2, 3]);
|
|
@@ -1082,6 +1250,27 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1082
1250
|
|
|
1083
1251
|
|
|
1084
1252
|
|
|
1253
|
+
|
|
1254
|
+
|
|
1255
|
+
|
|
1256
|
+
|
|
1257
|
+
|
|
1258
|
+
|
|
1259
|
+
|
|
1260
|
+
|
|
1261
|
+
|
|
1262
|
+
|
|
1263
|
+
|
|
1264
|
+
|
|
1265
|
+
|
|
1266
|
+
|
|
1267
|
+
|
|
1268
|
+
|
|
1269
|
+
|
|
1270
|
+
|
|
1271
|
+
|
|
1272
|
+
|
|
1273
|
+
|
|
1085
1274
|
* @example
|
|
1086
1275
|
* // Reclaim unused memory
|
|
1087
1276
|
* const q = new Queue<number>([1, 2, 3, 4, 5]);
|
|
@@ -1127,6 +1316,27 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1127
1316
|
|
|
1128
1317
|
|
|
1129
1318
|
|
|
1319
|
+
|
|
1320
|
+
|
|
1321
|
+
|
|
1322
|
+
|
|
1323
|
+
|
|
1324
|
+
|
|
1325
|
+
|
|
1326
|
+
|
|
1327
|
+
|
|
1328
|
+
|
|
1329
|
+
|
|
1330
|
+
|
|
1331
|
+
|
|
1332
|
+
|
|
1333
|
+
|
|
1334
|
+
|
|
1335
|
+
|
|
1336
|
+
|
|
1337
|
+
|
|
1338
|
+
|
|
1339
|
+
|
|
1130
1340
|
* @example
|
|
1131
1341
|
* // Create independent copy
|
|
1132
1342
|
* const q = new Queue<number>([1, 2, 3]);
|
|
@@ -1156,6 +1366,27 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1156
1366
|
|
|
1157
1367
|
|
|
1158
1368
|
|
|
1369
|
+
|
|
1370
|
+
|
|
1371
|
+
|
|
1372
|
+
|
|
1373
|
+
|
|
1374
|
+
|
|
1375
|
+
|
|
1376
|
+
|
|
1377
|
+
|
|
1378
|
+
|
|
1379
|
+
|
|
1380
|
+
|
|
1381
|
+
|
|
1382
|
+
|
|
1383
|
+
|
|
1384
|
+
|
|
1385
|
+
|
|
1386
|
+
|
|
1387
|
+
|
|
1388
|
+
|
|
1389
|
+
|
|
1159
1390
|
* @example
|
|
1160
1391
|
* // Filter elements
|
|
1161
1392
|
* const q = new Queue<number>([1, 2, 3, 4, 5]);
|
|
@@ -1189,6 +1420,27 @@ var Queue = class _Queue extends LinearBase {
|
|
|
1189
1420
|
|
|
1190
1421
|
|
|
1191
1422
|
|
|
1423
|
+
|
|
1424
|
+
|
|
1425
|
+
|
|
1426
|
+
|
|
1427
|
+
|
|
1428
|
+
|
|
1429
|
+
|
|
1430
|
+
|
|
1431
|
+
|
|
1432
|
+
|
|
1433
|
+
|
|
1434
|
+
|
|
1435
|
+
|
|
1436
|
+
|
|
1437
|
+
|
|
1438
|
+
|
|
1439
|
+
|
|
1440
|
+
|
|
1441
|
+
|
|
1442
|
+
|
|
1443
|
+
|
|
1192
1444
|
* @example
|
|
1193
1445
|
* // Transform elements
|
|
1194
1446
|
* const q = new Queue<number>([1, 2, 3]);
|
|
@@ -1665,6 +1917,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1665
1917
|
|
|
1666
1918
|
|
|
1667
1919
|
|
|
1920
|
+
|
|
1921
|
+
|
|
1922
|
+
|
|
1923
|
+
|
|
1924
|
+
|
|
1925
|
+
|
|
1926
|
+
|
|
1927
|
+
|
|
1928
|
+
|
|
1929
|
+
|
|
1930
|
+
|
|
1931
|
+
|
|
1932
|
+
|
|
1933
|
+
|
|
1934
|
+
|
|
1935
|
+
|
|
1936
|
+
|
|
1937
|
+
|
|
1938
|
+
|
|
1939
|
+
|
|
1940
|
+
|
|
1668
1941
|
* @example
|
|
1669
1942
|
* // Add a single node
|
|
1670
1943
|
* const tree = new BinaryTree<number>();
|
|
@@ -1695,6 +1968,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1695
1968
|
|
|
1696
1969
|
|
|
1697
1970
|
|
|
1971
|
+
|
|
1972
|
+
|
|
1973
|
+
|
|
1974
|
+
|
|
1975
|
+
|
|
1976
|
+
|
|
1977
|
+
|
|
1978
|
+
|
|
1979
|
+
|
|
1980
|
+
|
|
1981
|
+
|
|
1982
|
+
|
|
1983
|
+
|
|
1984
|
+
|
|
1985
|
+
|
|
1986
|
+
|
|
1987
|
+
|
|
1988
|
+
|
|
1989
|
+
|
|
1990
|
+
|
|
1991
|
+
|
|
1698
1992
|
* @example
|
|
1699
1993
|
* // basic BinaryTree creation and insertion
|
|
1700
1994
|
* // Create a BinaryTree with entries
|
|
@@ -1777,6 +2071,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1777
2071
|
|
|
1778
2072
|
|
|
1779
2073
|
|
|
2074
|
+
|
|
2075
|
+
|
|
2076
|
+
|
|
2077
|
+
|
|
2078
|
+
|
|
2079
|
+
|
|
2080
|
+
|
|
2081
|
+
|
|
2082
|
+
|
|
2083
|
+
|
|
2084
|
+
|
|
2085
|
+
|
|
2086
|
+
|
|
2087
|
+
|
|
2088
|
+
|
|
2089
|
+
|
|
2090
|
+
|
|
2091
|
+
|
|
2092
|
+
|
|
2093
|
+
|
|
2094
|
+
|
|
1780
2095
|
* @example
|
|
1781
2096
|
* // Bulk add
|
|
1782
2097
|
* const tree = new BinaryTree<number>();
|
|
@@ -1795,6 +2110,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1795
2110
|
* @returns An array of booleans indicating the success of each individual `set` operation.
|
|
1796
2111
|
|
|
1797
2112
|
|
|
2113
|
+
|
|
2114
|
+
|
|
2115
|
+
|
|
2116
|
+
|
|
2117
|
+
|
|
2118
|
+
|
|
2119
|
+
|
|
2120
|
+
|
|
2121
|
+
|
|
2122
|
+
|
|
2123
|
+
|
|
2124
|
+
|
|
2125
|
+
|
|
2126
|
+
|
|
2127
|
+
|
|
2128
|
+
|
|
2129
|
+
|
|
2130
|
+
|
|
2131
|
+
|
|
2132
|
+
|
|
2133
|
+
|
|
1798
2134
|
* @example
|
|
1799
2135
|
* // Set multiple entries
|
|
1800
2136
|
* const tree = new BinaryTree<number, string>();
|
|
@@ -1834,6 +2170,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1834
2170
|
|
|
1835
2171
|
|
|
1836
2172
|
|
|
2173
|
+
|
|
2174
|
+
|
|
2175
|
+
|
|
2176
|
+
|
|
2177
|
+
|
|
2178
|
+
|
|
2179
|
+
|
|
2180
|
+
|
|
2181
|
+
|
|
2182
|
+
|
|
2183
|
+
|
|
2184
|
+
|
|
2185
|
+
|
|
2186
|
+
|
|
2187
|
+
|
|
2188
|
+
|
|
2189
|
+
|
|
2190
|
+
|
|
2191
|
+
|
|
2192
|
+
|
|
2193
|
+
|
|
1837
2194
|
* @example
|
|
1838
2195
|
* // Combine trees
|
|
1839
2196
|
* const t1 = new BinaryTree<number>([1, 2]);
|
|
@@ -1872,6 +2229,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1872
2229
|
|
|
1873
2230
|
|
|
1874
2231
|
|
|
2232
|
+
|
|
2233
|
+
|
|
2234
|
+
|
|
2235
|
+
|
|
2236
|
+
|
|
2237
|
+
|
|
2238
|
+
|
|
2239
|
+
|
|
2240
|
+
|
|
2241
|
+
|
|
2242
|
+
|
|
2243
|
+
|
|
2244
|
+
|
|
2245
|
+
|
|
2246
|
+
|
|
2247
|
+
|
|
2248
|
+
|
|
2249
|
+
|
|
2250
|
+
|
|
2251
|
+
|
|
2252
|
+
|
|
1875
2253
|
* @example
|
|
1876
2254
|
* // Remove a node
|
|
1877
2255
|
* const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
|
|
@@ -1988,6 +2366,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
1988
2366
|
|
|
1989
2367
|
|
|
1990
2368
|
|
|
2369
|
+
|
|
2370
|
+
|
|
2371
|
+
|
|
2372
|
+
|
|
2373
|
+
|
|
2374
|
+
|
|
2375
|
+
|
|
2376
|
+
|
|
2377
|
+
|
|
2378
|
+
|
|
2379
|
+
|
|
2380
|
+
|
|
2381
|
+
|
|
2382
|
+
|
|
2383
|
+
|
|
2384
|
+
|
|
2385
|
+
|
|
2386
|
+
|
|
2387
|
+
|
|
2388
|
+
|
|
2389
|
+
|
|
1991
2390
|
* @example
|
|
1992
2391
|
* // Get node by key
|
|
1993
2392
|
* const tree = new BinaryTree<number, string>([[1, 'root'], [2, 'child']]);
|
|
@@ -2022,6 +2421,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2022
2421
|
|
|
2023
2422
|
|
|
2024
2423
|
|
|
2424
|
+
|
|
2425
|
+
|
|
2426
|
+
|
|
2427
|
+
|
|
2428
|
+
|
|
2429
|
+
|
|
2430
|
+
|
|
2431
|
+
|
|
2432
|
+
|
|
2433
|
+
|
|
2434
|
+
|
|
2435
|
+
|
|
2436
|
+
|
|
2437
|
+
|
|
2438
|
+
|
|
2439
|
+
|
|
2440
|
+
|
|
2441
|
+
|
|
2442
|
+
|
|
2443
|
+
|
|
2444
|
+
|
|
2025
2445
|
* @example
|
|
2026
2446
|
* // Retrieve value by key
|
|
2027
2447
|
* const tree = new BinaryTree<number, string>([[1, 'root'], [2, 'left'], [3, 'right']]);
|
|
@@ -2058,6 +2478,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2058
2478
|
|
|
2059
2479
|
|
|
2060
2480
|
|
|
2481
|
+
|
|
2482
|
+
|
|
2483
|
+
|
|
2484
|
+
|
|
2485
|
+
|
|
2486
|
+
|
|
2487
|
+
|
|
2488
|
+
|
|
2489
|
+
|
|
2490
|
+
|
|
2491
|
+
|
|
2492
|
+
|
|
2493
|
+
|
|
2494
|
+
|
|
2495
|
+
|
|
2496
|
+
|
|
2497
|
+
|
|
2498
|
+
|
|
2499
|
+
|
|
2500
|
+
|
|
2501
|
+
|
|
2061
2502
|
* @example
|
|
2062
2503
|
* // Remove all nodes
|
|
2063
2504
|
* const tree = new BinaryTree<number>([1, 2, 3]);
|
|
@@ -2082,6 +2523,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2082
2523
|
|
|
2083
2524
|
|
|
2084
2525
|
|
|
2526
|
+
|
|
2527
|
+
|
|
2528
|
+
|
|
2529
|
+
|
|
2530
|
+
|
|
2531
|
+
|
|
2532
|
+
|
|
2533
|
+
|
|
2534
|
+
|
|
2535
|
+
|
|
2536
|
+
|
|
2537
|
+
|
|
2538
|
+
|
|
2539
|
+
|
|
2540
|
+
|
|
2541
|
+
|
|
2542
|
+
|
|
2543
|
+
|
|
2544
|
+
|
|
2545
|
+
|
|
2546
|
+
|
|
2085
2547
|
* @example
|
|
2086
2548
|
* // Check empty
|
|
2087
2549
|
* console.log(new BinaryTree().isEmpty()); // true;
|
|
@@ -2115,6 +2577,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2115
2577
|
|
|
2116
2578
|
|
|
2117
2579
|
|
|
2580
|
+
|
|
2581
|
+
|
|
2582
|
+
|
|
2583
|
+
|
|
2584
|
+
|
|
2585
|
+
|
|
2586
|
+
|
|
2587
|
+
|
|
2588
|
+
|
|
2589
|
+
|
|
2590
|
+
|
|
2591
|
+
|
|
2592
|
+
|
|
2593
|
+
|
|
2594
|
+
|
|
2595
|
+
|
|
2596
|
+
|
|
2597
|
+
|
|
2598
|
+
|
|
2599
|
+
|
|
2600
|
+
|
|
2118
2601
|
* @example
|
|
2119
2602
|
* // Check BST property
|
|
2120
2603
|
* const tree = new BinaryTree<number>([1, 2, 3]);
|
|
@@ -2175,6 +2658,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2175
2658
|
|
|
2176
2659
|
|
|
2177
2660
|
|
|
2661
|
+
|
|
2662
|
+
|
|
2663
|
+
|
|
2664
|
+
|
|
2665
|
+
|
|
2666
|
+
|
|
2667
|
+
|
|
2668
|
+
|
|
2669
|
+
|
|
2670
|
+
|
|
2671
|
+
|
|
2672
|
+
|
|
2673
|
+
|
|
2674
|
+
|
|
2675
|
+
|
|
2676
|
+
|
|
2677
|
+
|
|
2678
|
+
|
|
2679
|
+
|
|
2680
|
+
|
|
2681
|
+
|
|
2178
2682
|
* @example
|
|
2179
2683
|
* // Get depth of a node
|
|
2180
2684
|
* const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
|
|
@@ -2212,6 +2716,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2212
2716
|
|
|
2213
2717
|
|
|
2214
2718
|
|
|
2719
|
+
|
|
2720
|
+
|
|
2721
|
+
|
|
2722
|
+
|
|
2723
|
+
|
|
2724
|
+
|
|
2725
|
+
|
|
2726
|
+
|
|
2727
|
+
|
|
2728
|
+
|
|
2729
|
+
|
|
2730
|
+
|
|
2731
|
+
|
|
2732
|
+
|
|
2733
|
+
|
|
2734
|
+
|
|
2735
|
+
|
|
2736
|
+
|
|
2737
|
+
|
|
2738
|
+
|
|
2739
|
+
|
|
2215
2740
|
* @example
|
|
2216
2741
|
* // Get tree height
|
|
2217
2742
|
* const tree = new BinaryTree<number>([1, 2, 3, 4, 5]);
|
|
@@ -2665,6 +3190,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2665
3190
|
|
|
2666
3191
|
|
|
2667
3192
|
|
|
3193
|
+
|
|
3194
|
+
|
|
3195
|
+
|
|
3196
|
+
|
|
3197
|
+
|
|
3198
|
+
|
|
3199
|
+
|
|
3200
|
+
|
|
3201
|
+
|
|
3202
|
+
|
|
3203
|
+
|
|
3204
|
+
|
|
3205
|
+
|
|
3206
|
+
|
|
3207
|
+
|
|
3208
|
+
|
|
3209
|
+
|
|
3210
|
+
|
|
3211
|
+
|
|
3212
|
+
|
|
3213
|
+
|
|
2668
3214
|
* @example
|
|
2669
3215
|
* // Deep copy
|
|
2670
3216
|
* const tree = new BinaryTree<number>([1, 2, 3]);
|
|
@@ -2693,6 +3239,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2693
3239
|
|
|
2694
3240
|
|
|
2695
3241
|
|
|
3242
|
+
|
|
3243
|
+
|
|
3244
|
+
|
|
3245
|
+
|
|
3246
|
+
|
|
3247
|
+
|
|
3248
|
+
|
|
3249
|
+
|
|
3250
|
+
|
|
3251
|
+
|
|
3252
|
+
|
|
3253
|
+
|
|
3254
|
+
|
|
3255
|
+
|
|
3256
|
+
|
|
3257
|
+
|
|
3258
|
+
|
|
3259
|
+
|
|
3260
|
+
|
|
3261
|
+
|
|
3262
|
+
|
|
2696
3263
|
* @example
|
|
2697
3264
|
* // Filter nodes by condition
|
|
2698
3265
|
* const tree = new BinaryTree<number>([1, 2, 3, 4]);
|
|
@@ -2725,6 +3292,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2725
3292
|
|
|
2726
3293
|
|
|
2727
3294
|
|
|
3295
|
+
|
|
3296
|
+
|
|
3297
|
+
|
|
3298
|
+
|
|
3299
|
+
|
|
3300
|
+
|
|
3301
|
+
|
|
3302
|
+
|
|
3303
|
+
|
|
3304
|
+
|
|
3305
|
+
|
|
3306
|
+
|
|
3307
|
+
|
|
3308
|
+
|
|
3309
|
+
|
|
3310
|
+
|
|
3311
|
+
|
|
3312
|
+
|
|
3313
|
+
|
|
3314
|
+
|
|
3315
|
+
|
|
2728
3316
|
* @example
|
|
2729
3317
|
* // Transform to new tree
|
|
2730
3318
|
* const tree = new BinaryTree<number, number>([[1, 10], [2, 20]]);
|
|
@@ -2782,6 +3370,27 @@ var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
2782
3370
|
|
|
2783
3371
|
|
|
2784
3372
|
|
|
3373
|
+
|
|
3374
|
+
|
|
3375
|
+
|
|
3376
|
+
|
|
3377
|
+
|
|
3378
|
+
|
|
3379
|
+
|
|
3380
|
+
|
|
3381
|
+
|
|
3382
|
+
|
|
3383
|
+
|
|
3384
|
+
|
|
3385
|
+
|
|
3386
|
+
|
|
3387
|
+
|
|
3388
|
+
|
|
3389
|
+
|
|
3390
|
+
|
|
3391
|
+
|
|
3392
|
+
|
|
3393
|
+
|
|
2785
3394
|
* @example
|
|
2786
3395
|
* // Display tree
|
|
2787
3396
|
* const tree = new BinaryTree<number>([1, 2, 3]);
|
|
@@ -3553,6 +4162,48 @@ var BST = class extends BinaryTree {
|
|
|
3553
4162
|
|
|
3554
4163
|
|
|
3555
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
|
+
|
|
4202
|
+
|
|
4203
|
+
|
|
4204
|
+
|
|
4205
|
+
|
|
4206
|
+
|
|
3556
4207
|
* @example
|
|
3557
4208
|
* // Get node object by key
|
|
3558
4209
|
* const bst = new BST<number, string>([[5, 'root'], [3, 'left'], [7, 'right']]);
|
|
@@ -3734,6 +4385,69 @@ var BST = class extends BinaryTree {
|
|
|
3734
4385
|
|
|
3735
4386
|
|
|
3736
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
|
+
|
|
4446
|
+
|
|
4447
|
+
|
|
4448
|
+
|
|
4449
|
+
|
|
4450
|
+
|
|
3737
4451
|
|
|
3738
4452
|
|
|
3739
4453
|
|
|
@@ -3803,6 +4517,48 @@ var BST = class extends BinaryTree {
|
|
|
3803
4517
|
|
|
3804
4518
|
|
|
3805
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
|
+
|
|
4557
|
+
|
|
4558
|
+
|
|
4559
|
+
|
|
4560
|
+
|
|
4561
|
+
|
|
3806
4562
|
* @example
|
|
3807
4563
|
* // Set multiple key-value pairs
|
|
3808
4564
|
* const bst = new BST<number, string>();
|
|
@@ -4066,6 +4822,27 @@ var BST = class extends BinaryTree {
|
|
|
4066
4822
|
|
|
4067
4823
|
|
|
4068
4824
|
|
|
4825
|
+
|
|
4826
|
+
|
|
4827
|
+
|
|
4828
|
+
|
|
4829
|
+
|
|
4830
|
+
|
|
4831
|
+
|
|
4832
|
+
|
|
4833
|
+
|
|
4834
|
+
|
|
4835
|
+
|
|
4836
|
+
|
|
4837
|
+
|
|
4838
|
+
|
|
4839
|
+
|
|
4840
|
+
|
|
4841
|
+
|
|
4842
|
+
|
|
4843
|
+
|
|
4844
|
+
|
|
4845
|
+
|
|
4069
4846
|
* @example
|
|
4070
4847
|
* // Rebalance the tree
|
|
4071
4848
|
* const bst = new BST<number>();
|
|
@@ -4111,6 +4888,27 @@ var BST = class extends BinaryTree {
|
|
|
4111
4888
|
|
|
4112
4889
|
|
|
4113
4890
|
|
|
4891
|
+
|
|
4892
|
+
|
|
4893
|
+
|
|
4894
|
+
|
|
4895
|
+
|
|
4896
|
+
|
|
4897
|
+
|
|
4898
|
+
|
|
4899
|
+
|
|
4900
|
+
|
|
4901
|
+
|
|
4902
|
+
|
|
4903
|
+
|
|
4904
|
+
|
|
4905
|
+
|
|
4906
|
+
|
|
4907
|
+
|
|
4908
|
+
|
|
4909
|
+
|
|
4910
|
+
|
|
4911
|
+
|
|
4114
4912
|
* @example
|
|
4115
4913
|
* // Check if tree is height-balanced
|
|
4116
4914
|
* const bst = new BST<number>([3, 1, 5, 2, 4]);
|
|
@@ -4185,6 +4983,48 @@ var BST = class extends BinaryTree {
|
|
|
4185
4983
|
|
|
4186
4984
|
|
|
4187
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
|
+
|
|
5023
|
+
|
|
5024
|
+
|
|
5025
|
+
|
|
5026
|
+
|
|
5027
|
+
|
|
4188
5028
|
* @example
|
|
4189
5029
|
* // Transform to new tree
|
|
4190
5030
|
* const bst = new BST<number, number>([[1, 10], [2, 20], [3, 30]]);
|