data-structure-typed 1.52.0 → 1.52.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/CHANGELOG.md +1 -1
- package/README.md +128 -41
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +11 -11
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +6 -6
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +11 -11
- package/dist/cjs/data-structures/binary-tree/avl-tree.js +6 -6
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +97 -97
- package/dist/cjs/data-structures/binary-tree/binary-tree.js +50 -50
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/bst.d.ts +35 -35
- package/dist/cjs/data-structures/binary-tree/bst.js +15 -15
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +8 -8
- package/dist/cjs/data-structures/binary-tree/rb-tree.js +6 -6
- package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +10 -10
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +5 -5
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
- package/dist/cjs/data-structures/graph/directed-graph.js +2 -1
- package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
- package/dist/cjs/data-structures/queue/deque.d.ts +7 -0
- package/dist/cjs/data-structures/queue/deque.js +16 -1
- package/dist/cjs/data-structures/queue/deque.js.map +1 -1
- package/dist/cjs/data-structures/queue/queue.d.ts +0 -1
- package/dist/cjs/data-structures/queue/queue.js +0 -1
- package/dist/cjs/data-structures/queue/queue.js.map +1 -1
- package/dist/cjs/interfaces/binary-tree.d.ts +3 -3
- package/dist/cjs/types/common.d.ts +1 -22
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +18 -1
- package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +3 -0
- package/dist/cjs/types/data-structures/queue/deque.d.ts +1 -0
- package/dist/cjs/utils/number.js +1 -2
- package/dist/cjs/utils/number.js.map +1 -1
- package/dist/cjs/utils/utils.js +2 -2
- package/dist/cjs/utils/utils.js.map +1 -1
- package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +11 -11
- package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +6 -6
- package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +11 -11
- package/dist/mjs/data-structures/binary-tree/avl-tree.js +6 -6
- package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +97 -97
- package/dist/mjs/data-structures/binary-tree/binary-tree.js +50 -50
- package/dist/mjs/data-structures/binary-tree/bst.d.ts +35 -35
- package/dist/mjs/data-structures/binary-tree/bst.js +15 -15
- package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +8 -8
- package/dist/mjs/data-structures/binary-tree/rb-tree.js +6 -6
- package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +10 -10
- package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +5 -5
- package/dist/mjs/data-structures/graph/directed-graph.js +2 -1
- package/dist/mjs/data-structures/queue/deque.d.ts +7 -0
- package/dist/mjs/data-structures/queue/deque.js +16 -1
- package/dist/mjs/data-structures/queue/queue.d.ts +0 -1
- package/dist/mjs/data-structures/queue/queue.js +0 -1
- package/dist/mjs/interfaces/binary-tree.d.ts +3 -3
- package/dist/mjs/types/common.d.ts +1 -22
- package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +18 -1
- package/dist/mjs/types/data-structures/binary-tree/bst.d.ts +3 -0
- package/dist/mjs/types/data-structures/queue/deque.d.ts +1 -0
- package/dist/umd/data-structure-typed.js +105 -91
- package/dist/umd/data-structure-typed.min.js +2 -2
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +7 -7
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +12 -12
- package/src/data-structures/binary-tree/avl-tree.ts +11 -11
- package/src/data-structures/binary-tree/binary-tree.ts +151 -147
- package/src/data-structures/binary-tree/bst.ts +44 -41
- package/src/data-structures/binary-tree/rb-tree.ts +10 -10
- package/src/data-structures/binary-tree/tree-multi-map.ts +10 -10
- package/src/data-structures/graph/directed-graph.ts +2 -1
- package/src/data-structures/queue/deque.ts +15 -1
- package/src/data-structures/queue/queue.ts +0 -1
- package/src/interfaces/binary-tree.ts +3 -3
- package/src/types/common.ts +2 -24
- package/src/types/data-structures/binary-tree/binary-tree.ts +21 -1
- package/src/types/data-structures/binary-tree/bst.ts +7 -0
- package/src/types/data-structures/queue/deque.ts +4 -1
- package/test/unit/data-structures/graph/directed-graph.test.ts +28 -0
- package/test/unit/data-structures/heap/heap.test.ts +20 -0
- package/test/unit/data-structures/queue/deque.test.ts +19 -0
|
@@ -3634,7 +3634,6 @@ var dataStructureTyped = (() => {
|
|
|
3634
3634
|
*
|
|
3635
3635
|
* The function "fromArray" creates a new Queue object from an array of elements.Creates a queue from an existing array.
|
|
3636
3636
|
* @public
|
|
3637
|
-
* @static
|
|
3638
3637
|
* @param {E[]} elements - The "elements" parameter is an array of elements of type E.
|
|
3639
3638
|
* @returns The method is returning a new instance of the Queue class, initialized with the elements from the input
|
|
3640
3639
|
* array.
|
|
@@ -3863,6 +3862,7 @@ var dataStructureTyped = (() => {
|
|
|
3863
3862
|
constructor(elements = [], options) {
|
|
3864
3863
|
super(options);
|
|
3865
3864
|
__publicField(this, "_bucketSize", 1 << 12);
|
|
3865
|
+
__publicField(this, "_maxLen", -1);
|
|
3866
3866
|
__publicField(this, "_bucketFirst", 0);
|
|
3867
3867
|
__publicField(this, "_firstInBucket", 0);
|
|
3868
3868
|
__publicField(this, "_bucketLast", 0);
|
|
@@ -3871,9 +3871,11 @@ var dataStructureTyped = (() => {
|
|
|
3871
3871
|
__publicField(this, "_buckets", []);
|
|
3872
3872
|
__publicField(this, "_size", 0);
|
|
3873
3873
|
if (options) {
|
|
3874
|
-
const { bucketSize } = options;
|
|
3874
|
+
const { bucketSize, maxLen } = options;
|
|
3875
3875
|
if (typeof bucketSize === "number")
|
|
3876
3876
|
this._bucketSize = bucketSize;
|
|
3877
|
+
if (typeof maxLen === "number" && maxLen > 0 && maxLen % 1 === 0)
|
|
3878
|
+
this._maxLen = maxLen;
|
|
3877
3879
|
}
|
|
3878
3880
|
let _size;
|
|
3879
3881
|
if ("length" in elements) {
|
|
@@ -3910,6 +3912,14 @@ var dataStructureTyped = (() => {
|
|
|
3910
3912
|
get bucketSize() {
|
|
3911
3913
|
return this._bucketSize;
|
|
3912
3914
|
}
|
|
3915
|
+
/**
|
|
3916
|
+
* The maxLen function returns the max length of the deque.
|
|
3917
|
+
*
|
|
3918
|
+
* @return The max length of the deque
|
|
3919
|
+
*/
|
|
3920
|
+
get maxLen() {
|
|
3921
|
+
return this._maxLen;
|
|
3922
|
+
}
|
|
3913
3923
|
/**
|
|
3914
3924
|
* The function returns the value of the protected variable `_bucketFirst`.
|
|
3915
3925
|
* @returns The value of the `_bucketFirst` property.
|
|
@@ -4009,6 +4019,8 @@ var dataStructureTyped = (() => {
|
|
|
4009
4019
|
}
|
|
4010
4020
|
this._size += 1;
|
|
4011
4021
|
this._buckets[this._bucketLast][this._lastInBucket] = element;
|
|
4022
|
+
if (this._maxLen > 0 && this._size > this._maxLen)
|
|
4023
|
+
this.shift();
|
|
4012
4024
|
return true;
|
|
4013
4025
|
}
|
|
4014
4026
|
/**
|
|
@@ -4071,6 +4083,8 @@ var dataStructureTyped = (() => {
|
|
|
4071
4083
|
}
|
|
4072
4084
|
this._size += 1;
|
|
4073
4085
|
this._buckets[this._bucketFirst][this._firstInBucket] = element;
|
|
4086
|
+
if (this._maxLen > 0 && this._size > this._maxLen)
|
|
4087
|
+
this.pop();
|
|
4074
4088
|
return true;
|
|
4075
4089
|
}
|
|
4076
4090
|
/**
|
|
@@ -6710,7 +6724,7 @@ var dataStructureTyped = (() => {
|
|
|
6710
6724
|
if (vertex) {
|
|
6711
6725
|
const neighbors = this.getNeighbors(vertex);
|
|
6712
6726
|
for (const neighbor of neighbors) {
|
|
6713
|
-
this.
|
|
6727
|
+
this.deleteEdgeSrcToDest(vertex, neighbor);
|
|
6714
6728
|
}
|
|
6715
6729
|
this._outEdgeMap.delete(vertex);
|
|
6716
6730
|
this._inEdgeMap.delete(vertex);
|
|
@@ -7791,7 +7805,7 @@ var dataStructureTyped = (() => {
|
|
|
7791
7805
|
}
|
|
7792
7806
|
/**
|
|
7793
7807
|
* The function sets the left child of a node and updates its parent reference.
|
|
7794
|
-
* @param {NODE
|
|
7808
|
+
* @param {OptBTNOrNull<NODE>} v - The parameter `v` can be of type `NODE`, `null`, or
|
|
7795
7809
|
* `undefined`.
|
|
7796
7810
|
*/
|
|
7797
7811
|
set left(v) {
|
|
@@ -7810,7 +7824,7 @@ var dataStructureTyped = (() => {
|
|
|
7810
7824
|
}
|
|
7811
7825
|
/**
|
|
7812
7826
|
* The function sets the right child of a node and updates its parent.
|
|
7813
|
-
* @param {NODE
|
|
7827
|
+
* @param {OptBTNOrNull<NODE>} v - The parameter `v` can be of type `NODE`, `null`, or
|
|
7814
7828
|
* `undefined`.
|
|
7815
7829
|
*/
|
|
7816
7830
|
set right(v) {
|
|
@@ -7839,7 +7853,7 @@ var dataStructureTyped = (() => {
|
|
|
7839
7853
|
var BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
7840
7854
|
/**
|
|
7841
7855
|
* The constructor function initializes a binary tree object with optional keysOrNodesOrEntriesOrRawElements and options.
|
|
7842
|
-
* @param [keysOrNodesOrEntriesOrRawElements] - Optional iterable of
|
|
7856
|
+
* @param [keysOrNodesOrEntriesOrRawElements] - Optional iterable of BTNKeyOrNodeOrEntry objects. These objects represent the
|
|
7843
7857
|
* nodes to be added to the binary tree.
|
|
7844
7858
|
* @param [options] - The `options` parameter is an optional object that can contain additional
|
|
7845
7859
|
* configuration options for the binary tree. In this case, it is of type
|
|
@@ -7917,8 +7931,8 @@ var dataStructureTyped = (() => {
|
|
|
7917
7931
|
/**
|
|
7918
7932
|
* The function `keyValueOrEntryOrRawElementToNode` converts a key-value pair, entry, or raw element
|
|
7919
7933
|
* into a node object.
|
|
7920
|
-
* @param {R |
|
|
7921
|
-
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `
|
|
7934
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
7935
|
+
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
7922
7936
|
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the
|
|
7923
7937
|
* `keyValueOrEntryOrRawElementToNode` function. It represents the value associated with a key in a
|
|
7924
7938
|
* key-value pair. If provided, it will be used to create a node with the specified key and value.
|
|
@@ -7962,8 +7976,8 @@ var dataStructureTyped = (() => {
|
|
|
7962
7976
|
*
|
|
7963
7977
|
* The `ensureNode` function checks if the input is a valid node and returns it, or converts it to a
|
|
7964
7978
|
* node if it is a key or entry.
|
|
7965
|
-
* @param {R |
|
|
7966
|
-
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R`, `
|
|
7979
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
7980
|
+
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R`, `BTNKeyOrNodeOrEntry<K, V, NODE>`, or
|
|
7967
7981
|
* a raw element.
|
|
7968
7982
|
* @param {IterationType} [iterationType=ITERATIVE] - The `iterationType` parameter is an optional
|
|
7969
7983
|
* parameter that specifies the type of iteration to be used when searching for a node. It has a
|
|
@@ -7998,8 +8012,8 @@ var dataStructureTyped = (() => {
|
|
|
7998
8012
|
}
|
|
7999
8013
|
/**
|
|
8000
8014
|
* The function checks if the input is an instance of the BinaryTreeNode class.
|
|
8001
|
-
* @param {R |
|
|
8002
|
-
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `
|
|
8015
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
8016
|
+
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
8003
8017
|
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
|
|
8004
8018
|
* an instance of the `BinaryTreeNode` class.
|
|
8005
8019
|
*/
|
|
@@ -8008,8 +8022,8 @@ var dataStructureTyped = (() => {
|
|
|
8008
8022
|
}
|
|
8009
8023
|
/**
|
|
8010
8024
|
* The function checks if a given node is a valid node in a binary search tree.
|
|
8011
|
-
* @param {R |
|
|
8012
|
-
* `
|
|
8025
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} node - The parameter `node` can be of type `R` or
|
|
8026
|
+
* `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
8013
8027
|
* @returns a boolean value.
|
|
8014
8028
|
*/
|
|
8015
8029
|
isRealNode(node) {
|
|
@@ -8019,8 +8033,8 @@ var dataStructureTyped = (() => {
|
|
|
8019
8033
|
}
|
|
8020
8034
|
/**
|
|
8021
8035
|
* The function checks if a given node is a real node or null.
|
|
8022
|
-
* @param {R |
|
|
8023
|
-
* `
|
|
8036
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} node - The parameter `node` can be of type `R` or
|
|
8037
|
+
* `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
8024
8038
|
* @returns a boolean value.
|
|
8025
8039
|
*/
|
|
8026
8040
|
isNodeOrNull(node) {
|
|
@@ -8028,8 +8042,8 @@ var dataStructureTyped = (() => {
|
|
|
8028
8042
|
}
|
|
8029
8043
|
/**
|
|
8030
8044
|
* The function checks if a given node is equal to the NIL value.
|
|
8031
|
-
* @param {R |
|
|
8032
|
-
* `
|
|
8045
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} node - The parameter `node` can be of type `R` or
|
|
8046
|
+
* `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
8033
8047
|
* @returns a boolean value.
|
|
8034
8048
|
*/
|
|
8035
8049
|
isNIL(node) {
|
|
@@ -8038,8 +8052,8 @@ var dataStructureTyped = (() => {
|
|
|
8038
8052
|
/**
|
|
8039
8053
|
* The function checks if the input is an array with two elements, indicating it is a binary tree
|
|
8040
8054
|
* node entry.
|
|
8041
|
-
* @param {R |
|
|
8042
|
-
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `
|
|
8055
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
8056
|
+
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
8043
8057
|
* @returns a boolean value.
|
|
8044
8058
|
*/
|
|
8045
8059
|
isEntry(keyOrNodeOrEntryOrRawElement) {
|
|
@@ -8087,10 +8101,10 @@ var dataStructureTyped = (() => {
|
|
|
8087
8101
|
*
|
|
8088
8102
|
* The `add` function is used to insert a new node into a binary tree, checking for duplicate keys
|
|
8089
8103
|
* and finding the appropriate insertion position.
|
|
8090
|
-
* @param {R |
|
|
8104
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
|
|
8091
8105
|
* `keyOrNodeOrEntryOrRawElement` parameter can accept a value of type `R`, which represents the key,
|
|
8092
8106
|
* node, entry, or raw element to be added to the tree. It can also accept a value of type
|
|
8093
|
-
* `
|
|
8107
|
+
* `BTNKeyOrNodeOrEntry<K, V, NODE>
|
|
8094
8108
|
* @param {V} [value] - The `value` parameter is an optional value that can be associated with the
|
|
8095
8109
|
* key being added to the tree. It represents the value that will be stored in the tree for the given
|
|
8096
8110
|
* key.
|
|
@@ -8185,7 +8199,7 @@ var dataStructureTyped = (() => {
|
|
|
8185
8199
|
*
|
|
8186
8200
|
* The `refill` function clears the current data and adds new data to the collection.
|
|
8187
8201
|
* @param keysOrNodesOrEntriesOrRawElements - An iterable collection of keys, nodes, entries, or raw
|
|
8188
|
-
* elements. These can be of any type (R) or a specific type (
|
|
8202
|
+
* elements. These can be of any type (R) or a specific type (BTNKeyOrNodeOrEntry<K, V, NODE>).
|
|
8189
8203
|
* @param [values] - The `values` parameter is an optional iterable of values that will be associated
|
|
8190
8204
|
* with the keys or nodes being added. If provided, the values will be assigned to the corresponding
|
|
8191
8205
|
* keys or nodes. If not provided, the values will be set to `undefined`.
|
|
@@ -8276,7 +8290,7 @@ var dataStructureTyped = (() => {
|
|
|
8276
8290
|
* the identifier or all nodes that match the identifier. If set to true, only the first matching
|
|
8277
8291
|
* node will be returned. If set to false, all matching nodes will be returned. The default value is
|
|
8278
8292
|
* false.
|
|
8279
|
-
* @param {R |
|
|
8293
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
8280
8294
|
* point for the search. It can be either a node object, a key-value pair, or a key. If it is not
|
|
8281
8295
|
* provided, the `root` of the data structure is used as the starting point.
|
|
8282
8296
|
* @param {IterationType} iterationType - The `iterationType` parameter determines the type of
|
|
@@ -8334,7 +8348,7 @@ var dataStructureTyped = (() => {
|
|
|
8334
8348
|
* the `C` callback function, or it can be `null` or `undefined`.
|
|
8335
8349
|
* @param {C} callback - The `callback` parameter is a function that will be used to determine if a
|
|
8336
8350
|
* node matches the desired criteria. It should return a value that can be used to identify the node.
|
|
8337
|
-
* @param {R |
|
|
8351
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
8338
8352
|
* point for searching nodes in a tree structure. It can be either a root node, a key-value pair, or
|
|
8339
8353
|
* a node entry. If not provided, the search will start from the root of the tree.
|
|
8340
8354
|
* @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type
|
|
@@ -8379,7 +8393,7 @@ var dataStructureTyped = (() => {
|
|
|
8379
8393
|
* callback function `C`. It can also be `null` or `undefined` if no identifier is provided.
|
|
8380
8394
|
* @param {C} callback - The `callback` parameter is a function that will be used to determine if a
|
|
8381
8395
|
* node matches the given identifier. It is optional and defaults to `this._DEFAULT_CALLBACK`.
|
|
8382
|
-
* @param {R |
|
|
8396
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
8383
8397
|
* point for the search in the binary tree. It can be either a root node of the tree or a key, node,
|
|
8384
8398
|
* or entry object that exists in the tree. If no specific starting point is provided, the search
|
|
8385
8399
|
* will begin from the root of the
|
|
@@ -8410,7 +8424,7 @@ var dataStructureTyped = (() => {
|
|
|
8410
8424
|
* @param {C} callback - The `callback` parameter is a function that will be used to determine
|
|
8411
8425
|
* whether a node should be included in the result or not. It is of type `C`, which extends the
|
|
8412
8426
|
* `BTNCallback<NODE>` type.
|
|
8413
|
-
* @param {R |
|
|
8427
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
8414
8428
|
* point for the iteration in the data structure. It can be either a root node, a key-value pair, or
|
|
8415
8429
|
* a node entry. If not specified, it defaults to the root of the data structure.
|
|
8416
8430
|
* @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type
|
|
@@ -8459,10 +8473,10 @@ var dataStructureTyped = (() => {
|
|
|
8459
8473
|
*
|
|
8460
8474
|
* The function checks if a binary tree is perfectly balanced by comparing the minimum height and the
|
|
8461
8475
|
* height of the tree.
|
|
8462
|
-
* @param {R |
|
|
8476
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The parameter `beginRoot` is optional and
|
|
8463
8477
|
* has a default value of `this.root`. It represents the starting point for checking if the tree is
|
|
8464
8478
|
* perfectly balanced. It can be either a root node (`R`), a key or node or entry
|
|
8465
|
-
* (`
|
|
8479
|
+
* (`BTNKeyOrNodeOrEntry<K, V, NODE
|
|
8466
8480
|
* @returns a boolean value.
|
|
8467
8481
|
*/
|
|
8468
8482
|
isPerfectlyBalanced(beginRoot = this.root) {
|
|
@@ -8477,7 +8491,7 @@ var dataStructureTyped = (() => {
|
|
|
8477
8491
|
* Space Complexity: O(1)
|
|
8478
8492
|
*
|
|
8479
8493
|
* The function `isBST` checks if a binary search tree is valid, either recursively or iteratively.
|
|
8480
|
-
* @param {R |
|
|
8494
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
|
|
8481
8495
|
* starting point for checking if a binary search tree (BST) is valid. It can be either a root node
|
|
8482
8496
|
* of the BST, a key value of a node in the BST, or an entry object containing both the key and value
|
|
8483
8497
|
* of a node in the BST
|
|
@@ -8534,10 +8548,10 @@ var dataStructureTyped = (() => {
|
|
|
8534
8548
|
* Space Complexity: O(1)
|
|
8535
8549
|
*
|
|
8536
8550
|
* The function calculates the depth of a given node or key in a tree-like data structure.
|
|
8537
|
-
* @param {R |
|
|
8538
|
-
* (representing a root node), or a `
|
|
8551
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} dist - The `dist` parameter can be either a `R`
|
|
8552
|
+
* (representing a root node), or a `BTNKeyOrNodeOrEntry<K, V, NODE>` (representing a key, node, or
|
|
8539
8553
|
* entry).
|
|
8540
|
-
* @param {R |
|
|
8554
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is optional and
|
|
8541
8555
|
* represents the starting point from which to calculate the depth. It can be either a reference to a
|
|
8542
8556
|
* node in the tree or a key-value pair or an entry object. If not provided, the default value is
|
|
8543
8557
|
* `this.root`, which refers to the root node
|
|
@@ -8566,9 +8580,9 @@ var dataStructureTyped = (() => {
|
|
|
8566
8580
|
*
|
|
8567
8581
|
* The `getHeight` function calculates the maximum height of a binary tree using either a recursive
|
|
8568
8582
|
* or iterative approach.
|
|
8569
|
-
* @param {R |
|
|
8583
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
|
|
8570
8584
|
* starting point for calculating the height of a tree. It can be either a root node (`R`), a key or
|
|
8571
|
-
* node or entry (`
|
|
8585
|
+
* node or entry (`BTNKeyOrNodeOrEntry<K, V, NODE>`), or it defaults to the root of the current tree.
|
|
8572
8586
|
* @param {IterationType} iterationType - The `iterationType` parameter determines the type of
|
|
8573
8587
|
* iteration used to calculate the height of the tree. It can have two possible values:
|
|
8574
8588
|
* @returns the maximum height of the binary tree.
|
|
@@ -8610,9 +8624,9 @@ var dataStructureTyped = (() => {
|
|
|
8610
8624
|
*
|
|
8611
8625
|
* The `getMinHeight` function calculates the minimum height of a binary tree using either a
|
|
8612
8626
|
* recursive or iterative approach.
|
|
8613
|
-
* @param {R |
|
|
8627
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
|
|
8614
8628
|
* starting point for calculating the minimum height of a tree. It can be either a root node (`R`), a
|
|
8615
|
-
* key or node or entry (`
|
|
8629
|
+
* key or node or entry (`BTNKeyOrNodeOrEntry<K, V, NODE>`), or it defaults to the root of the current
|
|
8616
8630
|
* tree.
|
|
8617
8631
|
* @param {IterationType} iterationType - The `iterationType` parameter determines the type of
|
|
8618
8632
|
* iteration to be used when calculating the minimum height of the tree. It can have two possible
|
|
@@ -8672,8 +8686,8 @@ var dataStructureTyped = (() => {
|
|
|
8672
8686
|
*
|
|
8673
8687
|
* The function `getPathToRoot` returns an array of nodes starting from a given node and traversing
|
|
8674
8688
|
* up to the root node, with an option to reverse the order of the nodes.
|
|
8675
|
-
* @param {R |
|
|
8676
|
-
* type `R` or `
|
|
8689
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginNode - The `beginNode` parameter can be either of
|
|
8690
|
+
* type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
8677
8691
|
* @param [isReverse=true] - The `isReverse` parameter is a boolean flag that determines whether the
|
|
8678
8692
|
* resulting path should be reversed or not. If `isReverse` is set to `true`, the path will be
|
|
8679
8693
|
* reversed before returning it. If `isReverse` is set to `false` or not provided, the path will
|
|
@@ -8701,9 +8715,9 @@ var dataStructureTyped = (() => {
|
|
|
8701
8715
|
*
|
|
8702
8716
|
* The `getLeftMost` function returns the leftmost node in a binary tree, either using recursive or
|
|
8703
8717
|
* iterative traversal.
|
|
8704
|
-
* @param {R |
|
|
8718
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
|
|
8705
8719
|
* starting point for finding the leftmost node in a binary tree. It can be either a root node (`R`),
|
|
8706
|
-
* a key or node or entry (`
|
|
8720
|
+
* a key or node or entry (`BTNKeyOrNodeOrEntry<K, V, NODE>`), or `null` or `undefined`.
|
|
8707
8721
|
* @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type
|
|
8708
8722
|
* of iteration to be performed. It can have two possible values:
|
|
8709
8723
|
* @returns The function `getLeftMost` returns the leftmost node in a binary tree.
|
|
@@ -8740,9 +8754,9 @@ var dataStructureTyped = (() => {
|
|
|
8740
8754
|
*
|
|
8741
8755
|
* The `getRightMost` function returns the rightmost node in a binary tree, either recursively or
|
|
8742
8756
|
* iteratively.
|
|
8743
|
-
* @param {R |
|
|
8757
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
|
|
8744
8758
|
* starting point for finding the rightmost node in a binary tree. It can be either a root node
|
|
8745
|
-
* (`R`), a key or node or entry (`
|
|
8759
|
+
* (`R`), a key or node or entry (`BTNKeyOrNodeOrEntry<K, V, NODE>`), or `null` or `undefined`.
|
|
8746
8760
|
* @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type
|
|
8747
8761
|
* of iteration to be performed when finding the rightmost node in a binary tree. It can have two
|
|
8748
8762
|
* possible values:
|
|
@@ -8838,7 +8852,7 @@ var dataStructureTyped = (() => {
|
|
|
8838
8852
|
* return type of the callback function is determined by the generic type `C`.
|
|
8839
8853
|
* @param {DFSOrderPattern} [pattern=IN] - The `pattern` parameter determines the order in which the
|
|
8840
8854
|
* nodes are visited during the depth-first search. It can have one of the following values:
|
|
8841
|
-
* @param {R |
|
|
8855
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
8842
8856
|
* point of the depth-first search. It can be either a node object, a key-value pair, or a key. If it
|
|
8843
8857
|
* is a key or key-value pair, the method will find the corresponding node in the tree and start the
|
|
8844
8858
|
* search from there.
|
|
@@ -8962,7 +8976,7 @@ var dataStructureTyped = (() => {
|
|
|
8962
8976
|
* @param {C} callback - The `callback` parameter is a function that will be called for each node in
|
|
8963
8977
|
* the breadth-first search traversal. It takes a single argument, which is the current node being
|
|
8964
8978
|
* visited, and returns a value of any type.
|
|
8965
|
-
* @param {R |
|
|
8979
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
|
|
8966
8980
|
* starting point of the breadth-first search. It can be either a root node of a tree or a key, node,
|
|
8967
8981
|
* or entry object. If no value is provided, the `root` property of the class is used as the default
|
|
8968
8982
|
* starting point.
|
|
@@ -9037,7 +9051,7 @@ var dataStructureTyped = (() => {
|
|
|
9037
9051
|
* @param {C} callback - The `callback` parameter is a function that will be called for each node in
|
|
9038
9052
|
* the tree. It takes a node as an argument and returns a value. The return type of the callback
|
|
9039
9053
|
* function is determined by the generic type `C` which extends `BTNCallback<NODE | null>`.
|
|
9040
|
-
* @param {R |
|
|
9054
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter represents the
|
|
9041
9055
|
* starting point for traversing the tree. It can be either a root node, a key-value pair, or a node
|
|
9042
9056
|
* entry. If no value is provided, the `root` property of the class is used as the default starting
|
|
9043
9057
|
* point.
|
|
@@ -9112,7 +9126,7 @@ var dataStructureTyped = (() => {
|
|
|
9112
9126
|
* @param {DFSOrderPattern} [pattern=IN] - The `pattern` parameter in the `morris` function is used
|
|
9113
9127
|
* to specify the order in which the nodes of a binary tree are traversed. It can take one of the
|
|
9114
9128
|
* following values:
|
|
9115
|
-
* @param {R |
|
|
9129
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
9116
9130
|
* point for the traversal. It can be either a node object, a key, or an entry object. If no value is
|
|
9117
9131
|
* provided, the `root` of the tree is used as the starting point.
|
|
9118
9132
|
* @returns The function `morris` returns an array of values that are the return values of the
|
|
@@ -9299,7 +9313,7 @@ var dataStructureTyped = (() => {
|
|
|
9299
9313
|
* Space Complexity: O(n)
|
|
9300
9314
|
*
|
|
9301
9315
|
* The `print` function in TypeScript prints the binary tree structure with customizable options.
|
|
9302
|
-
* @param {R |
|
|
9316
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
9303
9317
|
* point for printing the binary tree. It can be either a node of the binary tree or a key or entry
|
|
9304
9318
|
* that exists in the binary tree. If no value is provided, the root of the binary tree will be used
|
|
9305
9319
|
* as the starting point.
|
|
@@ -9381,7 +9395,7 @@ var dataStructureTyped = (() => {
|
|
|
9381
9395
|
*
|
|
9382
9396
|
* The `_displayAux` function is responsible for generating the display layout of a binary tree node,
|
|
9383
9397
|
* taking into account various options such as whether to show null, undefined, or NaN nodes.
|
|
9384
|
-
* @param {NODE
|
|
9398
|
+
* @param {OptBTNOrNull<NODE>} node - The `node` parameter represents a node in a binary tree.
|
|
9385
9399
|
* It can be of type `NODE`, `null`, or `undefined`.
|
|
9386
9400
|
* @param {BinaryTreePrintOptions} options - The `options` parameter is an object that contains the
|
|
9387
9401
|
* following properties:
|
|
@@ -9441,10 +9455,10 @@ var dataStructureTyped = (() => {
|
|
|
9441
9455
|
* Space Complexity: O(1)
|
|
9442
9456
|
*
|
|
9443
9457
|
* The function `_swapProperties` swaps the key-value properties between two nodes.
|
|
9444
|
-
* @param {R |
|
|
9458
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} srcNode - The source node that will be swapped with the
|
|
9445
9459
|
* destination node. It can be either an instance of the class `R`, or an object of type
|
|
9446
|
-
* `
|
|
9447
|
-
* @param {R |
|
|
9460
|
+
* `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
9461
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} destNode - The `destNode` parameter is the node where
|
|
9448
9462
|
* the properties will be swapped with the `srcNode`.
|
|
9449
9463
|
* @returns either the `destNode` object with its properties swapped with the `srcNode` object's
|
|
9450
9464
|
* properties, or `undefined` if either `srcNode` or `destNode` is falsy.
|
|
@@ -9507,7 +9521,7 @@ var dataStructureTyped = (() => {
|
|
|
9507
9521
|
*
|
|
9508
9522
|
* The function sets the root property of an object to the provided value, and also updates the
|
|
9509
9523
|
* parent property of the new root.
|
|
9510
|
-
* @param {NODE
|
|
9524
|
+
* @param {OptBTNOrNull<NODE>} v - The parameter `v` is of type `OptBTNOrNull<NODE>`. This
|
|
9511
9525
|
* means that it can accept a value of type `NODE`, `null`, or `undefined`.
|
|
9512
9526
|
*/
|
|
9513
9527
|
_setRoot(v) {
|
|
@@ -9561,7 +9575,7 @@ var dataStructureTyped = (() => {
|
|
|
9561
9575
|
}
|
|
9562
9576
|
/**
|
|
9563
9577
|
* The function sets the left child of a node and updates the parent reference of the child.
|
|
9564
|
-
* @param {NODE
|
|
9578
|
+
* @param {OptBSTN<NODE>} v - The parameter `v` is of type `OptBSTN<NODE>`. It can either be an
|
|
9565
9579
|
* instance of the `NODE` class or `undefined`.
|
|
9566
9580
|
*/
|
|
9567
9581
|
set left(v) {
|
|
@@ -9580,7 +9594,7 @@ var dataStructureTyped = (() => {
|
|
|
9580
9594
|
}
|
|
9581
9595
|
/**
|
|
9582
9596
|
* The function sets the right child of a node and updates the parent reference of the child.
|
|
9583
|
-
* @param {NODE
|
|
9597
|
+
* @param {OptBSTN<NODE>} v - The parameter `v` is of type `OptBSTN<NODE>`. It can either be a
|
|
9584
9598
|
* `NODE` object or `undefined`.
|
|
9585
9599
|
*/
|
|
9586
9600
|
set right(v) {
|
|
@@ -9656,8 +9670,8 @@ var dataStructureTyped = (() => {
|
|
|
9656
9670
|
}
|
|
9657
9671
|
/**
|
|
9658
9672
|
* The function overrides a method and converts a key, value pair or entry or raw element to a node.
|
|
9659
|
-
* @param {R |
|
|
9660
|
-
* type R or
|
|
9673
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - A variable that can be of
|
|
9674
|
+
* type R or BTNKeyOrNodeOrEntry<K, V, NODE>. It represents either a key, a node, an entry, or a raw
|
|
9661
9675
|
* element.
|
|
9662
9676
|
* @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the
|
|
9663
9677
|
* value associated with a key in a key-value pair.
|
|
@@ -9673,7 +9687,7 @@ var dataStructureTyped = (() => {
|
|
|
9673
9687
|
*
|
|
9674
9688
|
* The function ensures the existence of a node in a data structure and returns it, or undefined if
|
|
9675
9689
|
* it doesn't exist.
|
|
9676
|
-
* @param {R |
|
|
9690
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
9677
9691
|
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R`, which represents the key, node,
|
|
9678
9692
|
* entry, or raw element that needs to be ensured in the tree.
|
|
9679
9693
|
* @param {IterationType} [iterationType=ITERATIVE] - The `iterationType` parameter is an optional
|
|
@@ -9688,8 +9702,8 @@ var dataStructureTyped = (() => {
|
|
|
9688
9702
|
}
|
|
9689
9703
|
/**
|
|
9690
9704
|
* The function checks if the input is an instance of the BSTNode class.
|
|
9691
|
-
* @param {R |
|
|
9692
|
-
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `
|
|
9705
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
9706
|
+
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
9693
9707
|
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
|
|
9694
9708
|
* an instance of the `BSTNode` class.
|
|
9695
9709
|
*/
|
|
@@ -9701,8 +9715,8 @@ var dataStructureTyped = (() => {
|
|
|
9701
9715
|
* Space Complexity: O(1)
|
|
9702
9716
|
*
|
|
9703
9717
|
* The `add` function in TypeScript adds a new node to a binary search tree based on the key value.
|
|
9704
|
-
* @param {R |
|
|
9705
|
-
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `
|
|
9718
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
9719
|
+
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
9706
9720
|
* @param {V} [value] - The `value` parameter is an optional value that can be associated with the
|
|
9707
9721
|
* key in the binary search tree. If provided, it will be stored in the node along with the key.
|
|
9708
9722
|
* @returns a boolean value.
|
|
@@ -9861,7 +9875,7 @@ var dataStructureTyped = (() => {
|
|
|
9861
9875
|
* @param [onlyOne=false] - A boolean value indicating whether to return only the first matching node
|
|
9862
9876
|
* or all matching nodes. If set to true, only the first matching node will be returned. If set to
|
|
9863
9877
|
* false, all matching nodes will be returned. The default value is false.
|
|
9864
|
-
* @param {R |
|
|
9878
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
9865
9879
|
* point for the search in the binary tree. It can be either a node object, a key-value pair, or an
|
|
9866
9880
|
* entry object. If it is not provided, the `root` of the binary tree is used as the starting point.
|
|
9867
9881
|
* @param {IterationType} iterationType - The `iterationType` parameter determines the type of
|
|
@@ -9983,7 +9997,7 @@ var dataStructureTyped = (() => {
|
|
|
9983
9997
|
* @param {DFSOrderPattern} [pattern=IN] - The "pattern" parameter in the code snippet refers to the
|
|
9984
9998
|
* order in which the Depth-First Search (DFS) algorithm visits the nodes in a tree or graph. It can
|
|
9985
9999
|
* take one of the following values:
|
|
9986
|
-
* @param {R |
|
|
10000
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
9987
10001
|
* point for the depth-first search traversal. It can be either a root node, a key-value pair, or a
|
|
9988
10002
|
* node entry. If not specified, the default value is the root of the tree.
|
|
9989
10003
|
* @param {IterationType} [iterationType=ITERATIVE] - The `iterationType` parameter specifies the
|
|
@@ -10007,7 +10021,7 @@ var dataStructureTyped = (() => {
|
|
|
10007
10021
|
* @param {C} callback - The `callback` parameter is a function that will be called for each node
|
|
10008
10022
|
* visited during the breadth-first search. It should take a single argument, which is the current
|
|
10009
10023
|
* node being visited, and it can return a value of any type.
|
|
10010
|
-
* @param {R |
|
|
10024
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
10011
10025
|
* point for the breadth-first search. It can be either a root node, a key-value pair, or an entry
|
|
10012
10026
|
* object. If no value is provided, the default value is the root of the tree.
|
|
10013
10027
|
* @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type
|
|
@@ -10031,7 +10045,7 @@ var dataStructureTyped = (() => {
|
|
|
10031
10045
|
* @param {C} callback - The `callback` parameter is a generic type `C` that extends
|
|
10032
10046
|
* `BTNCallback<NODE>`. It represents a callback function that will be called for each node in the
|
|
10033
10047
|
* tree during the iteration process.
|
|
10034
|
-
* @param {R |
|
|
10048
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
10035
10049
|
* point for listing the levels of the binary tree. It can be either a root node of the tree, a
|
|
10036
10050
|
* key-value pair representing a node in the tree, or a key representing a node in the tree. If no
|
|
10037
10051
|
* value is provided, the root of
|
|
@@ -10059,7 +10073,7 @@ var dataStructureTyped = (() => {
|
|
|
10059
10073
|
* @param {CP} lesserOrGreater - The `lesserOrGreater` parameter is used to determine whether to
|
|
10060
10074
|
* traverse nodes that are lesser, greater, or both than the `targetNode`. It accepts the values -1,
|
|
10061
10075
|
* 0, or 1, where:
|
|
10062
|
-
* @param {R |
|
|
10076
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} targetNode - The `targetNode` parameter is the node in
|
|
10063
10077
|
* the binary tree that you want to start traversing from. It can be specified either by providing
|
|
10064
10078
|
* the key of the node, the node itself, or an entry containing the key and value of the node. If no
|
|
10065
10079
|
* `targetNode` is provided,
|
|
@@ -10229,7 +10243,7 @@ var dataStructureTyped = (() => {
|
|
|
10229
10243
|
/**
|
|
10230
10244
|
* The function sets the root of a tree-like structure and updates the parent property of the new
|
|
10231
10245
|
* root.
|
|
10232
|
-
* @param {NODE
|
|
10246
|
+
* @param {OptBSTN<NODE>} v - v is a parameter of type NODE or undefined.
|
|
10233
10247
|
*/
|
|
10234
10248
|
_setRoot(v) {
|
|
10235
10249
|
if (v) {
|
|
@@ -10879,8 +10893,8 @@ var dataStructureTyped = (() => {
|
|
|
10879
10893
|
}
|
|
10880
10894
|
/**
|
|
10881
10895
|
* The function checks if the input is an instance of AVLTreeNode.
|
|
10882
|
-
* @param {R |
|
|
10883
|
-
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `
|
|
10896
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
10897
|
+
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
10884
10898
|
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
|
|
10885
10899
|
* an instance of the `AVLTreeNode` class.
|
|
10886
10900
|
*/
|
|
@@ -10898,8 +10912,8 @@ var dataStructureTyped = (() => {
|
|
|
10898
10912
|
*
|
|
10899
10913
|
* The function overrides the add method of a class and inserts a key-value pair into a data
|
|
10900
10914
|
* structure, then balances the path.
|
|
10901
|
-
* @param {R |
|
|
10902
|
-
* `keyOrNodeOrEntryOrRawElement` can accept values of type `R`, `
|
|
10915
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
10916
|
+
* `keyOrNodeOrEntryOrRawElement` can accept values of type `R`, `BTNKeyOrNodeOrEntry<K, V, NODE>`, or
|
|
10903
10917
|
* `RawElement`.
|
|
10904
10918
|
* @param {V} [value] - The `value` parameter is an optional value that you want to associate with
|
|
10905
10919
|
* the key or node being added to the data structure.
|
|
@@ -11218,8 +11232,8 @@ var dataStructureTyped = (() => {
|
|
|
11218
11232
|
*
|
|
11219
11233
|
* The `_balancePath` function is used to update the heights of nodes and perform rotation operations
|
|
11220
11234
|
* to restore balance in an AVL tree after inserting a node.
|
|
11221
|
-
* @param {R |
|
|
11222
|
-
* `
|
|
11235
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} node - The `node` parameter can be of type `R` or
|
|
11236
|
+
* `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
11223
11237
|
*/
|
|
11224
11238
|
_balancePath(node) {
|
|
11225
11239
|
node = this.ensureNode(node);
|
|
@@ -11367,8 +11381,8 @@ var dataStructureTyped = (() => {
|
|
|
11367
11381
|
* Space Complexity: O(1)
|
|
11368
11382
|
*
|
|
11369
11383
|
* The function checks if the input is an instance of the RedBlackTreeNode class.
|
|
11370
|
-
* @param {R |
|
|
11371
|
-
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `
|
|
11384
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
11385
|
+
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
11372
11386
|
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
|
|
11373
11387
|
* an instance of the `RedBlackTreeNode` class.
|
|
11374
11388
|
*/
|
|
@@ -11386,11 +11400,11 @@ var dataStructureTyped = (() => {
|
|
|
11386
11400
|
// *
|
|
11387
11401
|
// * The function `keyValueOrEntryOrRawElementToNode` takes a key, value, or entry and returns a node if it is
|
|
11388
11402
|
// * valid, otherwise it returns undefined.
|
|
11389
|
-
// * @param {
|
|
11403
|
+
// * @param {BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The key, value, or entry to convert.
|
|
11390
11404
|
// * @param {V} [value] - The value associated with the key (if `keyOrNodeOrEntryOrRawElement` is a key).
|
|
11391
11405
|
// * @returns {NODE | undefined} - The corresponding Red-Black Tree node, or `undefined` if conversion fails.
|
|
11392
11406
|
// */
|
|
11393
|
-
// override keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R |
|
|
11407
|
+
// override keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): NODE | undefined {
|
|
11394
11408
|
//
|
|
11395
11409
|
// if (keyOrNodeOrEntryOrRawElement === null || keyOrNodeOrEntryOrRawElement === undefined) return;
|
|
11396
11410
|
// if (this.isNode(keyOrNodeOrEntryOrRawElement)) return keyOrNodeOrEntryOrRawElement;
|
|
@@ -11435,8 +11449,8 @@ var dataStructureTyped = (() => {
|
|
|
11435
11449
|
*
|
|
11436
11450
|
* The function adds a new node to a binary search tree and returns true if the node was successfully
|
|
11437
11451
|
* added.
|
|
11438
|
-
* @param {R |
|
|
11439
|
-
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `
|
|
11452
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
11453
|
+
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
11440
11454
|
* @param {V} [value] - The `value` parameter is an optional value that you want to associate with
|
|
11441
11455
|
* the key in the data structure. It represents the value that you want to add or update in the data
|
|
11442
11456
|
* structure.
|
|
@@ -11942,8 +11956,8 @@ var dataStructureTyped = (() => {
|
|
|
11942
11956
|
}
|
|
11943
11957
|
/**
|
|
11944
11958
|
* The function checks if the input is an instance of AVLTreeMultiMapNode.
|
|
11945
|
-
* @param {R |
|
|
11946
|
-
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `
|
|
11959
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
11960
|
+
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
11947
11961
|
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
|
|
11948
11962
|
* an instance of the `AVLTreeMultiMapNode` class.
|
|
11949
11963
|
*/
|
|
@@ -11953,8 +11967,8 @@ var dataStructureTyped = (() => {
|
|
|
11953
11967
|
/**
|
|
11954
11968
|
* The function `keyValueOrEntryOrRawElementToNode` converts a key, value, entry, or raw element into
|
|
11955
11969
|
* a node object.
|
|
11956
|
-
* @param {R |
|
|
11957
|
-
* `keyOrNodeOrEntryOrRawElement` parameter can be of type `R` or `
|
|
11970
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
|
|
11971
|
+
* `keyOrNodeOrEntryOrRawElement` parameter can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
11958
11972
|
* @param {V} [value] - The `value` parameter is an optional value that can be passed to the
|
|
11959
11973
|
* `override` function. It represents the value associated with the key in the data structure. If no
|
|
11960
11974
|
* value is provided, it will default to `undefined`.
|
|
@@ -11993,9 +12007,9 @@ var dataStructureTyped = (() => {
|
|
|
11993
12007
|
*
|
|
11994
12008
|
* The function overrides the add method of a TypeScript class to add a new node to a data structure
|
|
11995
12009
|
* and update the count.
|
|
11996
|
-
* @param {R |
|
|
12010
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
|
|
11997
12011
|
* `keyOrNodeOrEntryOrRawElement` parameter can accept a value of type `R`, which can be any type. It
|
|
11998
|
-
* can also accept a value of type `
|
|
12012
|
+
* can also accept a value of type `BTNKeyOrNodeOrEntry<K, V, NODE>`, which represents a key, node,
|
|
11999
12013
|
* entry, or raw element
|
|
12000
12014
|
* @param {V} [value] - The `value` parameter represents the value associated with the key in the
|
|
12001
12015
|
* data structure. It is an optional parameter, so it can be omitted if not needed.
|
|
@@ -12340,8 +12354,8 @@ var dataStructureTyped = (() => {
|
|
|
12340
12354
|
/**
|
|
12341
12355
|
* The function `keyValueOrEntryOrRawElementToNode` takes in a key, value, and count and returns a
|
|
12342
12356
|
* node based on the input.
|
|
12343
|
-
* @param {R |
|
|
12344
|
-
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `
|
|
12357
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
12358
|
+
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
12345
12359
|
* @param {V} [value] - The `value` parameter is an optional value that represents the value
|
|
12346
12360
|
* associated with the key in the node. It is used when creating a new node or updating the value of
|
|
12347
12361
|
* an existing node.
|
|
@@ -12372,8 +12386,8 @@ var dataStructureTyped = (() => {
|
|
|
12372
12386
|
}
|
|
12373
12387
|
/**
|
|
12374
12388
|
* The function checks if the input is an instance of the TreeMultiMapNode class.
|
|
12375
|
-
* @param {R |
|
|
12376
|
-
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `
|
|
12389
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
12390
|
+
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
12377
12391
|
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
|
|
12378
12392
|
* an instance of the `TreeMultiMapNode` class.
|
|
12379
12393
|
*/
|
|
@@ -12390,7 +12404,7 @@ var dataStructureTyped = (() => {
|
|
|
12390
12404
|
*
|
|
12391
12405
|
* The function overrides the add method of a class and adds a new node to a data structure, updating
|
|
12392
12406
|
* the count and returning a boolean indicating success.
|
|
12393
|
-
* @param {R |
|
|
12407
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
|
|
12394
12408
|
* `keyOrNodeOrEntryOrRawElement` parameter can accept one of the following types:
|
|
12395
12409
|
* @param {V} [value] - The `value` parameter represents the value associated with the key in the
|
|
12396
12410
|
* data structure. It is an optional parameter, so it can be omitted if not needed.
|