data-structure-typed 1.49.8 → 1.50.0
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/CHANGELOG.md +1 -1
- package/benchmark/report.html +1 -37
- package/benchmark/report.json +22 -370
- package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +0 -7
- package/dist/cjs/data-structures/binary-tree/avl-tree.js +0 -9
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +5 -22
- package/dist/cjs/data-structures/binary-tree/binary-tree.js +9 -80
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/bst.d.ts +89 -27
- package/dist/cjs/data-structures/binary-tree/bst.js +131 -46
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +0 -7
- package/dist/cjs/data-structures/binary-tree/rb-tree.js +1 -10
- package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/tree-multimap.d.ts +0 -7
- package/dist/cjs/data-structures/binary-tree/tree-multimap.js +2 -11
- package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
- package/dist/cjs/data-structures/hash/hash-map.d.ts +16 -12
- package/dist/cjs/data-structures/hash/hash-map.js +36 -15
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
- package/dist/cjs/types/data-structures/hash/hash-map.d.ts +2 -1
- package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +0 -7
- package/dist/mjs/data-structures/binary-tree/avl-tree.js +0 -9
- package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +5 -22
- package/dist/mjs/data-structures/binary-tree/binary-tree.js +9 -80
- package/dist/mjs/data-structures/binary-tree/bst.d.ts +89 -27
- package/dist/mjs/data-structures/binary-tree/bst.js +131 -46
- package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +0 -7
- package/dist/mjs/data-structures/binary-tree/rb-tree.js +1 -10
- package/dist/mjs/data-structures/binary-tree/tree-multimap.d.ts +0 -7
- package/dist/mjs/data-structures/binary-tree/tree-multimap.js +2 -11
- package/dist/mjs/data-structures/hash/hash-map.d.ts +16 -12
- package/dist/mjs/data-structures/hash/hash-map.js +36 -15
- package/dist/mjs/types/data-structures/hash/hash-map.d.ts +2 -1
- package/dist/umd/data-structure-typed.js +176 -165
- package/dist/umd/data-structure-typed.min.js +2 -2
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +1 -1
- package/src/data-structures/binary-tree/avl-tree.ts +0 -10
- package/src/data-structures/binary-tree/binary-tree.ts +104 -141
- package/src/data-structures/binary-tree/bst.ts +153 -49
- package/src/data-structures/binary-tree/rb-tree.ts +1 -11
- package/src/data-structures/binary-tree/tree-multimap.ts +2 -12
- package/src/data-structures/hash/hash-map.ts +42 -16
- package/src/types/data-structures/hash/hash-map.ts +2 -1
- package/test/integration/all-in-one.test.ts +1 -1
- package/test/integration/index.html +2 -2
- package/test/performance/data-structures/queue/deque.test.ts +8 -2
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +2 -2
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +38 -9
- package/test/unit/data-structures/binary-tree/bst.test.ts +8 -12
- package/test/unit/data-structures/binary-tree/tree-multimap.test.ts +4 -4
- package/test/unit/data-structures/hash/hash-map.test.ts +17 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash-map.js","sourceRoot":"","sources":["../../../../src/data-structures/hash/hash-map.ts"],"names":[],"mappings":";;;AAcA,kCAA4C;AAC5C,uCAAoD;AAEpD;;;;;GAKG;AACH,MAAa,OAA0B,SAAQ,wBAAuB;IAIpE;;;;;;;OAOG;IACH,YAAY,UAA4B,EAAE,EAAE,OAA2B;QACrE,KAAK,EAAE,CAAC;QAZA,WAAM,GAA8C,EAAE,CAAC;QACvD,YAAO,GA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IAWD;;;;;OAKG;IACM,CAAE,YAAY;QACrB,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;QACtB,OAAO,IAAI,KAAK,IAAI,CAAC,SAAS,EAAE,CAAC;YAC/B,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAW,CAAC;YACvC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACnB,CAAC;IACH,CAAC;IAED;;;;;;;;;OASG;IACO,WAAW,CAAC,IAAyC;QAC7D,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,IAAI,IAAI,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;YACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QACpB,CAAC;QAED,IAAI,IAAI,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;YACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QACpB,CAAC;QAED,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAvZD,sCAuZC"}
|
|
@@ -8,8 +8,9 @@ export type LinkedHashMapOptions<K> = {
|
|
|
8
8
|
hashFn?: (key: K) => string;
|
|
9
9
|
objHashFn?: (key: K) => object;
|
|
10
10
|
};
|
|
11
|
-
export type HashMapOptions<K> = {
|
|
11
|
+
export type HashMapOptions<K, V, T> = {
|
|
12
12
|
hashFn?: (key: K) => string;
|
|
13
|
+
toEntryFn?: (rawElement: T) => [K, V];
|
|
13
14
|
};
|
|
14
15
|
export type HashMapStoreItem<K, V> = {
|
|
15
16
|
key: K;
|
|
@@ -56,13 +56,6 @@ export declare class AVLTree<K = any, V = any, N extends AVLTreeNode<K, V, N> =
|
|
|
56
56
|
* @returns a boolean value indicating whether the keyOrNodeOrEntry is an instance of the AVLTreeNode class.
|
|
57
57
|
*/
|
|
58
58
|
isNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, N>): keyOrNodeOrEntry is N;
|
|
59
|
-
/**
|
|
60
|
-
* The function "isNotNodeInstance" checks if a potential key is a K.
|
|
61
|
-
* @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
|
|
62
|
-
* data type.
|
|
63
|
-
* @returns a boolean value indicating whether the potentialKey is of type number or not.
|
|
64
|
-
*/
|
|
65
|
-
isNotNodeInstance(potentialKey: KeyOrNodeOrEntry<K, V, N>): potentialKey is K;
|
|
66
59
|
/**
|
|
67
60
|
* Time Complexity: O(log n)
|
|
68
61
|
* Space Complexity: O(1)
|
|
@@ -71,15 +71,6 @@ export class AVLTree extends BST {
|
|
|
71
71
|
isNode(keyOrNodeOrEntry) {
|
|
72
72
|
return keyOrNodeOrEntry instanceof AVLTreeNode;
|
|
73
73
|
}
|
|
74
|
-
/**
|
|
75
|
-
* The function "isNotNodeInstance" checks if a potential key is a K.
|
|
76
|
-
* @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
|
|
77
|
-
* data type.
|
|
78
|
-
* @returns a boolean value indicating whether the potentialKey is of type number or not.
|
|
79
|
-
*/
|
|
80
|
-
isNotNodeInstance(potentialKey) {
|
|
81
|
-
return !(potentialKey instanceof AVLTreeNode);
|
|
82
|
-
}
|
|
83
74
|
/**
|
|
84
75
|
* Time Complexity: O(log n)
|
|
85
76
|
* Space Complexity: O(1)
|
|
@@ -135,13 +135,6 @@ export declare class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V,
|
|
|
135
135
|
* @returns a boolean value.
|
|
136
136
|
*/
|
|
137
137
|
isNodeOrNull(node: KeyOrNodeOrEntry<K, V, N>): node is N | null;
|
|
138
|
-
/**
|
|
139
|
-
* The function "isNotNodeInstance" checks if a potential key is a K.
|
|
140
|
-
* @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
|
|
141
|
-
* data type.
|
|
142
|
-
* @returns a boolean value indicating whether the potentialKey is of type number or not.
|
|
143
|
-
*/
|
|
144
|
-
isNotNodeInstance(potentialKey: KeyOrNodeOrEntry<K, V, N>): potentialKey is K;
|
|
145
138
|
/**
|
|
146
139
|
* Time Complexity O(log n) - O(n)
|
|
147
140
|
* Space Complexity O(1)
|
|
@@ -344,7 +337,7 @@ export declare class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V,
|
|
|
344
337
|
*
|
|
345
338
|
* The function `getPathToRoot` returns an array of nodes from a given node to the root of a tree
|
|
346
339
|
* structure, with the option to reverse the order of the nodes.
|
|
347
|
-
* @param {K | N | null | undefined}
|
|
340
|
+
* @param {K | N | null | undefined} beginNode - The `beginRoot` parameter represents the
|
|
348
341
|
* starting node from which you want to find the path to the root. It can be of type `K`, `N`,
|
|
349
342
|
* `null`, or `undefined`.
|
|
350
343
|
* @param [isReverse=true] - The `isReverse` parameter is a boolean flag that determines whether the
|
|
@@ -352,7 +345,7 @@ export declare class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V,
|
|
|
352
345
|
* reversed before returning it. If `isReverse` is set to `false`, the path will be returned as is
|
|
353
346
|
* @returns The function `getPathToRoot` returns an array of nodes (`N[]`).
|
|
354
347
|
*/
|
|
355
|
-
getPathToRoot(
|
|
348
|
+
getPathToRoot(beginNode: KeyOrNodeOrEntry<K, V, N>, isReverse?: boolean): N[];
|
|
356
349
|
/**
|
|
357
350
|
* Time Complexity: O(log n)
|
|
358
351
|
* Space Complexity: O(1)
|
|
@@ -409,30 +402,20 @@ export declare class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V,
|
|
|
409
402
|
* @returns a boolean value.
|
|
410
403
|
*/
|
|
411
404
|
isBST(beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType): boolean;
|
|
412
|
-
/**
|
|
413
|
-
* Time complexity: O(n)
|
|
414
|
-
* Space complexity: O(log n)
|
|
415
|
-
*/
|
|
416
|
-
subTreeTraverse<C extends BTNCallback<N>>(callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[];
|
|
417
|
-
subTreeTraverse<C extends BTNCallback<N>>(callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType, includeNull?: undefined): ReturnType<C>[];
|
|
418
|
-
subTreeTraverse<C extends BTNCallback<N | null | undefined>>(callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
|
|
419
405
|
dfs<C extends BTNCallback<N>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[];
|
|
420
|
-
dfs<C extends BTNCallback<N>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType, includeNull?:
|
|
421
|
-
dfs<C extends BTNCallback<N | null | undefined>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
|
|
406
|
+
dfs<C extends BTNCallback<N | null>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
|
|
422
407
|
/**
|
|
423
408
|
* Time complexity: O(n)
|
|
424
409
|
* Space complexity: O(n)
|
|
425
410
|
*/
|
|
426
411
|
bfs<C extends BTNCallback<N>>(callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[];
|
|
427
|
-
bfs<C extends BTNCallback<N>>(callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType, includeNull?:
|
|
428
|
-
bfs<C extends BTNCallback<N | null | undefined>>(callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
|
|
412
|
+
bfs<C extends BTNCallback<N | null>>(callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[];
|
|
429
413
|
/**
|
|
430
414
|
* Time complexity: O(n)
|
|
431
415
|
* Space complexity: O(n)
|
|
432
416
|
*/
|
|
433
417
|
listLevels<C extends BTNCallback<N>>(callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType, includeNull?: false): ReturnType<C>[][];
|
|
434
|
-
listLevels<C extends BTNCallback<N>>(callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType, includeNull?:
|
|
435
|
-
listLevels<C extends BTNCallback<N | null | undefined>>(callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[][];
|
|
418
|
+
listLevels<C extends BTNCallback<N | null>>(callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType, includeNull?: true): ReturnType<C>[][];
|
|
436
419
|
/**
|
|
437
420
|
* Time Complexity: O(log n)
|
|
438
421
|
* Space Complexity: O(1)
|
|
@@ -152,7 +152,7 @@ export class BinaryTree extends IterableEntryBase {
|
|
|
152
152
|
else if (this.isNode(keyOrNodeOrEntry)) {
|
|
153
153
|
node = keyOrNodeOrEntry;
|
|
154
154
|
}
|
|
155
|
-
else if (this.
|
|
155
|
+
else if (!this.isNode(keyOrNodeOrEntry)) {
|
|
156
156
|
node = this.createNode(keyOrNodeOrEntry, value);
|
|
157
157
|
}
|
|
158
158
|
else {
|
|
@@ -243,15 +243,6 @@ export class BinaryTree extends IterableEntryBase {
|
|
|
243
243
|
isNodeOrNull(node) {
|
|
244
244
|
return this.isRealNode(node) || node === null;
|
|
245
245
|
}
|
|
246
|
-
/**
|
|
247
|
-
* The function "isNotNodeInstance" checks if a potential key is a K.
|
|
248
|
-
* @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
|
|
249
|
-
* data type.
|
|
250
|
-
* @returns a boolean value indicating whether the potentialKey is of type number or not.
|
|
251
|
-
*/
|
|
252
|
-
isNotNodeInstance(potentialKey) {
|
|
253
|
-
return !(potentialKey instanceof BinaryTreeNode);
|
|
254
|
-
}
|
|
255
246
|
/**
|
|
256
247
|
* Time Complexity O(log n) - O(n)
|
|
257
248
|
* Space Complexity O(1)
|
|
@@ -810,7 +801,7 @@ export class BinaryTree extends IterableEntryBase {
|
|
|
810
801
|
*
|
|
811
802
|
* The function `getPathToRoot` returns an array of nodes from a given node to the root of a tree
|
|
812
803
|
* structure, with the option to reverse the order of the nodes.
|
|
813
|
-
* @param {K | N | null | undefined}
|
|
804
|
+
* @param {K | N | null | undefined} beginNode - The `beginRoot` parameter represents the
|
|
814
805
|
* starting node from which you want to find the path to the root. It can be of type `K`, `N`,
|
|
815
806
|
* `null`, or `undefined`.
|
|
816
807
|
* @param [isReverse=true] - The `isReverse` parameter is a boolean flag that determines whether the
|
|
@@ -818,19 +809,19 @@ export class BinaryTree extends IterableEntryBase {
|
|
|
818
809
|
* reversed before returning it. If `isReverse` is set to `false`, the path will be returned as is
|
|
819
810
|
* @returns The function `getPathToRoot` returns an array of nodes (`N[]`).
|
|
820
811
|
*/
|
|
821
|
-
getPathToRoot(
|
|
812
|
+
getPathToRoot(beginNode, isReverse = true) {
|
|
822
813
|
// TODO to support get path through passing key
|
|
823
814
|
const result = [];
|
|
824
|
-
|
|
825
|
-
if (!
|
|
815
|
+
beginNode = this.ensureNode(beginNode);
|
|
816
|
+
if (!beginNode)
|
|
826
817
|
return result;
|
|
827
|
-
while (
|
|
818
|
+
while (beginNode.parent) {
|
|
828
819
|
// Array.push + Array.reverse is more efficient than Array.unshift
|
|
829
820
|
// TODO may consider using Deque, so far this is not the performance bottleneck
|
|
830
|
-
result.push(
|
|
831
|
-
|
|
821
|
+
result.push(beginNode);
|
|
822
|
+
beginNode = beginNode.parent;
|
|
832
823
|
}
|
|
833
|
-
result.push(
|
|
824
|
+
result.push(beginNode);
|
|
834
825
|
return isReverse ? result.reverse() : result;
|
|
835
826
|
}
|
|
836
827
|
/**
|
|
@@ -973,68 +964,6 @@ export class BinaryTree extends IterableEntryBase {
|
|
|
973
964
|
return isStandardBST || isInverseBST;
|
|
974
965
|
}
|
|
975
966
|
}
|
|
976
|
-
/**
|
|
977
|
-
* Time complexity: O(n)
|
|
978
|
-
* Space complexity: O(log n)
|
|
979
|
-
*
|
|
980
|
-
* The function `subTreeTraverse` traverses a binary tree and applies a callback function to each
|
|
981
|
-
* node, either recursively or iteratively.
|
|
982
|
-
* @param {C} callback - The `callback` parameter is a function that will be called for each node in
|
|
983
|
-
* the subtree traversal. It takes a single parameter, which is the current node being traversed, and
|
|
984
|
-
* returns a value of any type.
|
|
985
|
-
* @param {K | N | null | undefined} beginRoot - The `beginRoot` parameter represents the
|
|
986
|
-
* starting node or key from which the subtree traversal should begin. It can be of type `K`,
|
|
987
|
-
* `N`, `null`, or `undefined`. If not provided, the `root` property of the current object is used as
|
|
988
|
-
* the default value.
|
|
989
|
-
* @param iterationType - The `iterationType` parameter determines the type of traversal to be
|
|
990
|
-
* performed on the subtree. It can have two possible values:
|
|
991
|
-
* @param [includeNull=false] - The `includeNull` parameter is a boolean value that determines
|
|
992
|
-
* whether to include null values in the traversal. If `includeNull` is set to `true`, the
|
|
993
|
-
* traversal will include null values, otherwise it will skip them.
|
|
994
|
-
* @returns The function `subTreeTraverse` returns an array of values that are the result of invoking
|
|
995
|
-
* the `callback` function on each node in the subtree. The type of the array nodes is determined
|
|
996
|
-
* by the return type of the `callback` function.
|
|
997
|
-
*/
|
|
998
|
-
subTreeTraverse(callback = this._defaultOneParamCallback, beginRoot = this.root, iterationType = this.iterationType, includeNull = false) {
|
|
999
|
-
beginRoot = this.ensureNode(beginRoot);
|
|
1000
|
-
const ans = [];
|
|
1001
|
-
if (!beginRoot)
|
|
1002
|
-
return ans;
|
|
1003
|
-
if (iterationType === IterationType.RECURSIVE) {
|
|
1004
|
-
const _traverse = (cur) => {
|
|
1005
|
-
if (cur !== undefined) {
|
|
1006
|
-
ans.push(callback(cur));
|
|
1007
|
-
if (includeNull) {
|
|
1008
|
-
cur && this.isNodeOrNull(cur.left) && _traverse(cur.left);
|
|
1009
|
-
cur && this.isNodeOrNull(cur.right) && _traverse(cur.right);
|
|
1010
|
-
}
|
|
1011
|
-
else {
|
|
1012
|
-
cur && cur.left && _traverse(cur.left);
|
|
1013
|
-
cur && cur.right && _traverse(cur.right);
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
};
|
|
1017
|
-
_traverse(beginRoot);
|
|
1018
|
-
}
|
|
1019
|
-
else {
|
|
1020
|
-
const stack = [beginRoot];
|
|
1021
|
-
while (stack.length > 0) {
|
|
1022
|
-
const cur = stack.pop();
|
|
1023
|
-
if (cur !== undefined) {
|
|
1024
|
-
ans.push(callback(cur));
|
|
1025
|
-
if (includeNull) {
|
|
1026
|
-
cur && this.isNodeOrNull(cur.right) && stack.push(cur.right);
|
|
1027
|
-
cur && this.isNodeOrNull(cur.left) && stack.push(cur.left);
|
|
1028
|
-
}
|
|
1029
|
-
else {
|
|
1030
|
-
cur && cur.right && stack.push(cur.right);
|
|
1031
|
-
cur && cur.left && stack.push(cur.left);
|
|
1032
|
-
}
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
return ans;
|
|
1037
|
-
}
|
|
1038
967
|
/**
|
|
1039
968
|
* Time complexity: O(n)
|
|
1040
969
|
* Space complexity: O(n)
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
8
|
import type { BSTNested, BSTNodeNested, BSTOptions, BTNCallback, KeyOrNodeOrEntry } from '../../types';
|
|
9
|
-
import { BSTVariant, CP, IterationType } from '../../types';
|
|
9
|
+
import { BSTVariant, CP, DFSOrderPattern, IterationType } from '../../types';
|
|
10
10
|
import { BinaryTree, BinaryTreeNode } from './binary-tree';
|
|
11
11
|
import { IBinaryTree } from '../../interfaces';
|
|
12
12
|
export declare class BSTNode<K = any, V = any, N extends BSTNode<K, V, N> = BSTNodeNested<K, V>> extends BinaryTreeNode<K, V, N> {
|
|
@@ -100,13 +100,6 @@ export declare class BST<K = any, V = any, N extends BSTNode<K, V, N> = BSTNode<
|
|
|
100
100
|
* @returns either a node object (N) or undefined.
|
|
101
101
|
*/
|
|
102
102
|
ensureNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType): N | undefined;
|
|
103
|
-
/**
|
|
104
|
-
* The function "isNotNodeInstance" checks if a potential key is a K.
|
|
105
|
-
* @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
|
|
106
|
-
* data type.
|
|
107
|
-
* @returns a boolean value indicating whether the potentialKey is of type number or not.
|
|
108
|
-
*/
|
|
109
|
-
isNotNodeInstance(potentialKey: KeyOrNodeOrEntry<K, V, N>): potentialKey is K;
|
|
110
103
|
/**
|
|
111
104
|
* The function checks if an keyOrNodeOrEntry is an instance of BSTNode.
|
|
112
105
|
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is a variable of type `KeyOrNodeOrEntry<K, V, N>`.
|
|
@@ -157,25 +150,6 @@ export declare class BST<K = any, V = any, N extends BSTNode<K, V, N> = BSTNode<
|
|
|
157
150
|
* @returns The function `addMany` returns an array of nodes (`N`) or `undefined` values.
|
|
158
151
|
*/
|
|
159
152
|
addMany(keysOrNodesOrEntries: Iterable<KeyOrNodeOrEntry<K, V, N>>, values?: Iterable<V | undefined>, isBalanceAdd?: boolean, iterationType?: IterationType): boolean[];
|
|
160
|
-
/**
|
|
161
|
-
* Time Complexity: O(n log n)
|
|
162
|
-
* Space Complexity: O(n)
|
|
163
|
-
* Adding each element individually in a balanced tree. Additional space is required for the sorted array.
|
|
164
|
-
*/
|
|
165
|
-
/**
|
|
166
|
-
* Time Complexity: O(n log n)
|
|
167
|
-
* Space Complexity: O(n)
|
|
168
|
-
*
|
|
169
|
-
* The `lastKey` function returns the key of the rightmost node in a binary tree, or the key of the
|
|
170
|
-
* leftmost node if the comparison result is greater than.
|
|
171
|
-
* @param {K | N | undefined} beginRoot - The `beginRoot` parameter is optional and can be of
|
|
172
|
-
* type `K`, `N`, or `undefined`. It represents the starting point for finding the last key in
|
|
173
|
-
* the binary tree. If not provided, it defaults to the root of the binary tree (`this.root`).
|
|
174
|
-
* @returns the key of the rightmost node in the binary tree if the comparison result is less than,
|
|
175
|
-
* the key of the leftmost node if the comparison result is greater than, and the key of the
|
|
176
|
-
* rightmost node otherwise. If no node is found, it returns 0.
|
|
177
|
-
*/
|
|
178
|
-
lastKey(beginRoot?: KeyOrNodeOrEntry<K, V, N>): K | undefined;
|
|
179
153
|
/**
|
|
180
154
|
* Time Complexity: O(log n)
|
|
181
155
|
* Space Complexity: O(1)
|
|
@@ -225,6 +199,94 @@ export declare class BST<K = any, V = any, N extends BSTNode<K, V, N> = BSTNode<
|
|
|
225
199
|
* @returns The method returns an array of nodes (`N[]`).
|
|
226
200
|
*/
|
|
227
201
|
getNodes<C extends BTNCallback<N>>(identifier: ReturnType<C> | undefined, callback?: C, onlyOne?: boolean, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType): N[];
|
|
202
|
+
/**
|
|
203
|
+
* Time complexity: O(n)
|
|
204
|
+
* Space complexity: O(n)
|
|
205
|
+
*/
|
|
206
|
+
/**
|
|
207
|
+
* Time complexity: O(n)
|
|
208
|
+
* Space complexity: O(n)
|
|
209
|
+
*
|
|
210
|
+
* The function overrides the depth-first search method and returns an array of the return types of
|
|
211
|
+
* the callback function.
|
|
212
|
+
* @param {C} callback - The `callback` parameter is a function that will be called for each node
|
|
213
|
+
* during the depth-first search traversal. It is an optional parameter and if not provided, a
|
|
214
|
+
* default callback function will be used.
|
|
215
|
+
* @param {DFSOrderPattern} [pattern=in] - The `pattern` parameter specifies the order in which the
|
|
216
|
+
* nodes are visited during the depth-first search. It can have one of the following values:
|
|
217
|
+
* @param beginRoot - The `beginRoot` parameter is used to specify the starting point for the
|
|
218
|
+
* Depth-First Search (DFS) traversal. It can be either a key, a node, or an entry in the tree. If no
|
|
219
|
+
* value is provided, the DFS traversal will start from the root of the tree.
|
|
220
|
+
* @param {IterationType} iterationType - The `iterationType` parameter specifies the type of
|
|
221
|
+
* iteration to be used during the Depth-First Search (DFS) traversal. It can have one of the
|
|
222
|
+
* following values:
|
|
223
|
+
* @returns The method is returning an array of the return type of the callback function.
|
|
224
|
+
*/
|
|
225
|
+
dfs<C extends BTNCallback<N>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType): ReturnType<C>[];
|
|
226
|
+
/**
|
|
227
|
+
* Time complexity: O(n)
|
|
228
|
+
* Space complexity: O(n)
|
|
229
|
+
*/
|
|
230
|
+
/**
|
|
231
|
+
* Time complexity: O(n)
|
|
232
|
+
* Space complexity: O(n)
|
|
233
|
+
*
|
|
234
|
+
* The function overrides the breadth-first search method and returns an array of the return types of
|
|
235
|
+
* the callback function.
|
|
236
|
+
* @param {C} callback - The `callback` parameter is a function that will be called for each node
|
|
237
|
+
* visited during the breadth-first search traversal. It is an optional parameter and if not
|
|
238
|
+
* provided, a default callback function will be used.
|
|
239
|
+
* @param beginRoot - The `beginRoot` parameter is the starting point for the breadth-first search
|
|
240
|
+
* traversal. It can be either a key, a node, or an entry in the tree. If not specified, the root of
|
|
241
|
+
* the tree is used as the starting point.
|
|
242
|
+
* @param iterationType - The `iterationType` parameter is used to specify the type of iteration to
|
|
243
|
+
* be performed during the breadth-first search (BFS) traversal. It determines the order in which the
|
|
244
|
+
* nodes are visited.
|
|
245
|
+
* @returns The method is returning an array of the return type of the callback function.
|
|
246
|
+
*/
|
|
247
|
+
bfs<C extends BTNCallback<N>>(callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType): ReturnType<C>[];
|
|
248
|
+
/**
|
|
249
|
+
* Time complexity: O(n)
|
|
250
|
+
* Space complexity: O(n)
|
|
251
|
+
*/
|
|
252
|
+
/**
|
|
253
|
+
* Time complexity: O(n)
|
|
254
|
+
* Space complexity: O(n)
|
|
255
|
+
*
|
|
256
|
+
* The function overrides the listLevels method and returns an array of arrays containing the return
|
|
257
|
+
* type of the callback function for each level of the tree.
|
|
258
|
+
* @param {C} callback - The `callback` parameter is a generic type `C` that extends
|
|
259
|
+
* `BTNCallback<N>`. It represents a callback function that will be called for each node in the tree
|
|
260
|
+
* during the level listing process.
|
|
261
|
+
* @param beginRoot - The `beginRoot` parameter is used to specify the starting point for listing the
|
|
262
|
+
* levels of a binary tree. It can be either a key, a node, or an entry in the binary tree. If not
|
|
263
|
+
* provided, the root of the binary tree is used as the starting point.
|
|
264
|
+
* @param iterationType - The `iterationType` parameter is used to specify the type of iteration to
|
|
265
|
+
* be performed on the tree. It determines the order in which the nodes are visited during the
|
|
266
|
+
* iteration.
|
|
267
|
+
* @returns The method is returning a two-dimensional array of the return type of the callback
|
|
268
|
+
* function.
|
|
269
|
+
*/
|
|
270
|
+
listLevels<C extends BTNCallback<N>>(callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, N>, iterationType?: IterationType): ReturnType<C>[][];
|
|
271
|
+
/**
|
|
272
|
+
* Time Complexity: O(n log n)
|
|
273
|
+
* Space Complexity: O(n)
|
|
274
|
+
* Adding each element individually in a balanced tree. Additional space is required for the sorted array.
|
|
275
|
+
*/
|
|
276
|
+
/**
|
|
277
|
+
* Time Complexity: O(n log n)
|
|
278
|
+
* Space Complexity: O(n)
|
|
279
|
+
*
|
|
280
|
+
* The `lastKey` function returns the key of the rightmost node in a binary tree, or the key of the
|
|
281
|
+
* leftmost node if the comparison result is greater than.
|
|
282
|
+
* @param {K | N | undefined} beginRoot - The `beginRoot` parameter is optional and can be of
|
|
283
|
+
* type `K`, `N`, or `undefined`. It represents the starting point for finding the last key in
|
|
284
|
+
* the binary tree. If not provided, it defaults to the root of the binary tree (`this.root`).
|
|
285
|
+
* @returns the key of the rightmost node in the binary tree if the comparison result is less than,
|
|
286
|
+
* the key of the leftmost node if the comparison result is greater than, and the key of the
|
|
287
|
+
* rightmost node otherwise. If no node is found, it returns 0.
|
|
288
|
+
*/
|
|
289
|
+
lastKey(beginRoot?: KeyOrNodeOrEntry<K, V, N>): K | undefined;
|
|
228
290
|
/**
|
|
229
291
|
* Time Complexity: O(log n)
|
|
230
292
|
* Space Complexity: O(log n)
|
|
@@ -131,7 +131,7 @@ export class BST extends BinaryTree {
|
|
|
131
131
|
node = this.createNode(key, value);
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
-
else if (this.
|
|
134
|
+
else if (!this.isNode(keyOrNodeOrEntry)) {
|
|
135
135
|
node = this.createNode(keyOrNodeOrEntry, value);
|
|
136
136
|
}
|
|
137
137
|
else {
|
|
@@ -171,15 +171,6 @@ export class BST extends BinaryTree {
|
|
|
171
171
|
}
|
|
172
172
|
return res;
|
|
173
173
|
}
|
|
174
|
-
/**
|
|
175
|
-
* The function "isNotNodeInstance" checks if a potential key is a K.
|
|
176
|
-
* @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
|
|
177
|
-
* data type.
|
|
178
|
-
* @returns a boolean value indicating whether the potentialKey is of type number or not.
|
|
179
|
-
*/
|
|
180
|
-
isNotNodeInstance(potentialKey) {
|
|
181
|
-
return !(potentialKey instanceof BSTNode);
|
|
182
|
-
}
|
|
183
174
|
/**
|
|
184
175
|
* The function checks if an keyOrNodeOrEntry is an instance of BSTNode.
|
|
185
176
|
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is a variable of type `KeyOrNodeOrEntry<K, V, N>`.
|
|
@@ -347,42 +338,6 @@ export class BST extends BinaryTree {
|
|
|
347
338
|
}
|
|
348
339
|
return inserted;
|
|
349
340
|
}
|
|
350
|
-
/**
|
|
351
|
-
* Time Complexity: O(n log n)
|
|
352
|
-
* Space Complexity: O(n)
|
|
353
|
-
* Adding each element individually in a balanced tree. Additional space is required for the sorted array.
|
|
354
|
-
*/
|
|
355
|
-
/**
|
|
356
|
-
* Time Complexity: O(n log n)
|
|
357
|
-
* Space Complexity: O(n)
|
|
358
|
-
*
|
|
359
|
-
* The `lastKey` function returns the key of the rightmost node in a binary tree, or the key of the
|
|
360
|
-
* leftmost node if the comparison result is greater than.
|
|
361
|
-
* @param {K | N | undefined} beginRoot - The `beginRoot` parameter is optional and can be of
|
|
362
|
-
* type `K`, `N`, or `undefined`. It represents the starting point for finding the last key in
|
|
363
|
-
* the binary tree. If not provided, it defaults to the root of the binary tree (`this.root`).
|
|
364
|
-
* @returns the key of the rightmost node in the binary tree if the comparison result is less than,
|
|
365
|
-
* the key of the leftmost node if the comparison result is greater than, and the key of the
|
|
366
|
-
* rightmost node otherwise. If no node is found, it returns 0.
|
|
367
|
-
*/
|
|
368
|
-
lastKey(beginRoot = this.root) {
|
|
369
|
-
let current = this.ensureNode(beginRoot);
|
|
370
|
-
if (!current)
|
|
371
|
-
return undefined;
|
|
372
|
-
if (this._variant === BSTVariant.STANDARD) {
|
|
373
|
-
// For BSTVariant.MIN, find the rightmost node
|
|
374
|
-
while (current.right !== undefined) {
|
|
375
|
-
current = current.right;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
else {
|
|
379
|
-
// For BSTVariant.MAX, find the leftmost node
|
|
380
|
-
while (current.left !== undefined) {
|
|
381
|
-
current = current.left;
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
return current.key;
|
|
385
|
-
}
|
|
386
341
|
/**
|
|
387
342
|
* Time Complexity: O(log n)
|
|
388
343
|
* Space Complexity: O(1)
|
|
@@ -517,6 +472,136 @@ export class BST extends BinaryTree {
|
|
|
517
472
|
}
|
|
518
473
|
return ans;
|
|
519
474
|
}
|
|
475
|
+
// /**
|
|
476
|
+
// * The function overrides the subTreeTraverse method and returns the result of calling the super
|
|
477
|
+
// * method with the provided arguments.
|
|
478
|
+
// * @param {C} callback - The `callback` parameter is a function that will be called for each node in
|
|
479
|
+
// * the subtree traversal. It should accept a single parameter of type `N`, which represents a node in
|
|
480
|
+
// * the tree. The return type of the callback function can be any type.
|
|
481
|
+
// * @param beginRoot - The `beginRoot` parameter is the starting point for traversing the subtree. It
|
|
482
|
+
// * can be either a key, a node, or an entry.
|
|
483
|
+
// * @param iterationType - The `iterationType` parameter is used to specify the type of iteration to
|
|
484
|
+
// * be performed during the traversal of the subtree. It can have one of the following values:
|
|
485
|
+
// * @returns The method is returning an array of the return type of the callback function.
|
|
486
|
+
// */
|
|
487
|
+
// override subTreeTraverse<C extends BTNCallback<N>>(
|
|
488
|
+
// callback: C = this._defaultOneParamCallback as C,
|
|
489
|
+
// beginRoot: KeyOrNodeOrEntry<K, V, N> = this.root,
|
|
490
|
+
// iterationType = this.iterationType
|
|
491
|
+
// ): ReturnType<C>[] {
|
|
492
|
+
// return super.subTreeTraverse(callback, beginRoot, iterationType, false);
|
|
493
|
+
// }
|
|
494
|
+
/**
|
|
495
|
+
* Time complexity: O(n)
|
|
496
|
+
* Space complexity: O(n)
|
|
497
|
+
*/
|
|
498
|
+
/**
|
|
499
|
+
* Time complexity: O(n)
|
|
500
|
+
* Space complexity: O(n)
|
|
501
|
+
*
|
|
502
|
+
* The function overrides the depth-first search method and returns an array of the return types of
|
|
503
|
+
* the callback function.
|
|
504
|
+
* @param {C} callback - The `callback` parameter is a function that will be called for each node
|
|
505
|
+
* during the depth-first search traversal. It is an optional parameter and if not provided, a
|
|
506
|
+
* default callback function will be used.
|
|
507
|
+
* @param {DFSOrderPattern} [pattern=in] - The `pattern` parameter specifies the order in which the
|
|
508
|
+
* nodes are visited during the depth-first search. It can have one of the following values:
|
|
509
|
+
* @param beginRoot - The `beginRoot` parameter is used to specify the starting point for the
|
|
510
|
+
* Depth-First Search (DFS) traversal. It can be either a key, a node, or an entry in the tree. If no
|
|
511
|
+
* value is provided, the DFS traversal will start from the root of the tree.
|
|
512
|
+
* @param {IterationType} iterationType - The `iterationType` parameter specifies the type of
|
|
513
|
+
* iteration to be used during the Depth-First Search (DFS) traversal. It can have one of the
|
|
514
|
+
* following values:
|
|
515
|
+
* @returns The method is returning an array of the return type of the callback function.
|
|
516
|
+
*/
|
|
517
|
+
dfs(callback = this._defaultOneParamCallback, pattern = 'in', beginRoot = this.root, iterationType = IterationType.ITERATIVE) {
|
|
518
|
+
return super.dfs(callback, pattern, beginRoot, iterationType, false);
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Time complexity: O(n)
|
|
522
|
+
* Space complexity: O(n)
|
|
523
|
+
*/
|
|
524
|
+
/**
|
|
525
|
+
* Time complexity: O(n)
|
|
526
|
+
* Space complexity: O(n)
|
|
527
|
+
*
|
|
528
|
+
* The function overrides the breadth-first search method and returns an array of the return types of
|
|
529
|
+
* the callback function.
|
|
530
|
+
* @param {C} callback - The `callback` parameter is a function that will be called for each node
|
|
531
|
+
* visited during the breadth-first search traversal. It is an optional parameter and if not
|
|
532
|
+
* provided, a default callback function will be used.
|
|
533
|
+
* @param beginRoot - The `beginRoot` parameter is the starting point for the breadth-first search
|
|
534
|
+
* traversal. It can be either a key, a node, or an entry in the tree. If not specified, the root of
|
|
535
|
+
* the tree is used as the starting point.
|
|
536
|
+
* @param iterationType - The `iterationType` parameter is used to specify the type of iteration to
|
|
537
|
+
* be performed during the breadth-first search (BFS) traversal. It determines the order in which the
|
|
538
|
+
* nodes are visited.
|
|
539
|
+
* @returns The method is returning an array of the return type of the callback function.
|
|
540
|
+
*/
|
|
541
|
+
bfs(callback = this._defaultOneParamCallback, beginRoot = this.root, iterationType = this.iterationType) {
|
|
542
|
+
return super.bfs(callback, beginRoot, iterationType, false);
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Time complexity: O(n)
|
|
546
|
+
* Space complexity: O(n)
|
|
547
|
+
*/
|
|
548
|
+
/**
|
|
549
|
+
* Time complexity: O(n)
|
|
550
|
+
* Space complexity: O(n)
|
|
551
|
+
*
|
|
552
|
+
* The function overrides the listLevels method and returns an array of arrays containing the return
|
|
553
|
+
* type of the callback function for each level of the tree.
|
|
554
|
+
* @param {C} callback - The `callback` parameter is a generic type `C` that extends
|
|
555
|
+
* `BTNCallback<N>`. It represents a callback function that will be called for each node in the tree
|
|
556
|
+
* during the level listing process.
|
|
557
|
+
* @param beginRoot - The `beginRoot` parameter is used to specify the starting point for listing the
|
|
558
|
+
* levels of a binary tree. It can be either a key, a node, or an entry in the binary tree. If not
|
|
559
|
+
* provided, the root of the binary tree is used as the starting point.
|
|
560
|
+
* @param iterationType - The `iterationType` parameter is used to specify the type of iteration to
|
|
561
|
+
* be performed on the tree. It determines the order in which the nodes are visited during the
|
|
562
|
+
* iteration.
|
|
563
|
+
* @returns The method is returning a two-dimensional array of the return type of the callback
|
|
564
|
+
* function.
|
|
565
|
+
*/
|
|
566
|
+
listLevels(callback = this._defaultOneParamCallback, beginRoot = this.root, iterationType = this.iterationType) {
|
|
567
|
+
return super.listLevels(callback, beginRoot, iterationType, false);
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Time Complexity: O(n log n)
|
|
571
|
+
* Space Complexity: O(n)
|
|
572
|
+
* Adding each element individually in a balanced tree. Additional space is required for the sorted array.
|
|
573
|
+
*/
|
|
574
|
+
/**
|
|
575
|
+
* Time Complexity: O(n log n)
|
|
576
|
+
* Space Complexity: O(n)
|
|
577
|
+
*
|
|
578
|
+
* The `lastKey` function returns the key of the rightmost node in a binary tree, or the key of the
|
|
579
|
+
* leftmost node if the comparison result is greater than.
|
|
580
|
+
* @param {K | N | undefined} beginRoot - The `beginRoot` parameter is optional and can be of
|
|
581
|
+
* type `K`, `N`, or `undefined`. It represents the starting point for finding the last key in
|
|
582
|
+
* the binary tree. If not provided, it defaults to the root of the binary tree (`this.root`).
|
|
583
|
+
* @returns the key of the rightmost node in the binary tree if the comparison result is less than,
|
|
584
|
+
* the key of the leftmost node if the comparison result is greater than, and the key of the
|
|
585
|
+
* rightmost node otherwise. If no node is found, it returns 0.
|
|
586
|
+
*/
|
|
587
|
+
lastKey(beginRoot = this.root) {
|
|
588
|
+
let current = this.ensureNode(beginRoot);
|
|
589
|
+
if (!current)
|
|
590
|
+
return undefined;
|
|
591
|
+
if (this._variant === BSTVariant.STANDARD) {
|
|
592
|
+
// For BSTVariant.MIN, find the rightmost node
|
|
593
|
+
while (current.right !== undefined) {
|
|
594
|
+
current = current.right;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
else {
|
|
598
|
+
// For BSTVariant.MAX, find the leftmost node
|
|
599
|
+
while (current.left !== undefined) {
|
|
600
|
+
current = current.left;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
return current.key;
|
|
604
|
+
}
|
|
520
605
|
/**
|
|
521
606
|
* Time Complexity: O(log n)
|
|
522
607
|
* Space Complexity: O(log n)
|