red-black-tree-typed
Advanced tools
Comparing version 1.51.5 to 1.51.7
@@ -202,2 +202,3 @@ "use strict"; | ||
return deletedResult; | ||
callback = this._ensureCallback(identifier, callback); | ||
const curr = (_a = this.getNode(identifier, callback)) !== null && _a !== void 0 ? _a : undefined; | ||
@@ -204,0 +205,0 @@ if (!curr) |
@@ -141,4 +141,2 @@ "use strict"; | ||
delete(identifier, callback = this._DEFAULT_CALLBACK) { | ||
if (identifier instanceof AVLTreeNode) | ||
callback = (node => node); | ||
const deletedResults = super.delete(identifier, callback); | ||
@@ -145,0 +143,0 @@ for (const { needBalanced } of deletedResults) { |
@@ -257,3 +257,3 @@ /** | ||
*/ | ||
getNodeByKey(key: K, iterationType?: IterationType): NODE | undefined; | ||
getNodeByKey(key: K, iterationType?: IterationType): NODE | null | undefined; | ||
get<C extends BTNCallback<NODE, K>>(identifier: K, callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): V | undefined; | ||
@@ -610,2 +610,3 @@ get<C extends BTNCallback<NODE, NODE>>(identifier: NODE | null | undefined, callback?: C, beginRoot?: KeyOrNodeOrEntry<K, V, NODE>, iterationType?: IterationType): V | undefined; | ||
protected _setRoot(v: NODE | null | undefined): void; | ||
protected _ensureCallback<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | null | undefined, callback?: C): C; | ||
} |
@@ -166,21 +166,2 @@ /** | ||
* Time Complexity: O(log n) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(log n) | ||
* Space Complexity: O(1) | ||
* | ||
* The function `getNodeByKey` searches for a node in a binary tree based on a given key, using | ||
* either recursive or iterative methods. | ||
* @param {K} key - The `key` parameter is the key value that we are searching for in the tree. | ||
* It is used to identify the node that we want to retrieve. | ||
* @param iterationType - The `iterationType` parameter is an optional parameter that specifies the | ||
* type of iteration to use when searching for a node in the binary tree. It can have two possible | ||
* values: | ||
* @returns The function `getNodeByKey` returns a node (`NODE`) if a node with the specified key is | ||
* found in the binary tree. If no node is found, it returns `undefined`. | ||
*/ | ||
getNodeByKey(key: K, iterationType?: IterationType): NODE | undefined; | ||
/** | ||
* Time Complexity: O(log n) | ||
* Space Complexity: O(k + log n) | ||
@@ -240,2 +221,21 @@ * / | ||
/** | ||
* Time Complexity: O(log n) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(log n) | ||
* Space Complexity: O(1) | ||
* | ||
* The function `getNodeByKey` searches for a node in a binary tree based on a given key, using | ||
* either recursive or iterative methods. | ||
* @param {K} key - The `key` parameter is the key value that we are searching for in the tree. | ||
* It is used to identify the node that we want to retrieve. | ||
* @param iterationType - The `iterationType` parameter is an optional parameter that specifies the | ||
* type of iteration to use when searching for a node in the binary tree. It can have two possible | ||
* values: | ||
* @returns The function `getNodeByKey` returns a node (`NODE`) if a node with the specified key is | ||
* found in the binary tree. If no node is found, it returns `undefined`. | ||
*/ | ||
getNodeByKey(key: K, iterationType?: IterationType): NODE | undefined; | ||
/** | ||
* Time complexity: O(n) | ||
@@ -242,0 +242,0 @@ * Space complexity: O(n) |
@@ -168,15 +168,17 @@ "use strict"; | ||
ensureNode(keyOrNodeOrEntry, iterationType = 'ITERATIVE') { | ||
if (keyOrNodeOrEntry === this.NIL) | ||
return; | ||
if (this.isRealNode(keyOrNodeOrEntry)) { | ||
return keyOrNodeOrEntry; | ||
} | ||
else if (this.isEntry(keyOrNodeOrEntry)) { | ||
if (keyOrNodeOrEntry[0] === null || keyOrNodeOrEntry[0] === undefined) | ||
if (this.isEntry(keyOrNodeOrEntry)) { | ||
const key = keyOrNodeOrEntry[0]; | ||
if (key === null || key === undefined) | ||
return; | ||
return this.getNodeByKey(keyOrNodeOrEntry[0], iterationType); | ||
return this.getNodeByKey(key, iterationType); | ||
} | ||
else { | ||
if (keyOrNodeOrEntry === null || keyOrNodeOrEntry === undefined) | ||
return; | ||
return this.getNodeByKey(keyOrNodeOrEntry, iterationType); | ||
} | ||
const key = keyOrNodeOrEntry; | ||
if (key === null || key === undefined) | ||
return; | ||
return this.getNodeByKey(key, iterationType); | ||
} | ||
@@ -348,52 +350,2 @@ /** | ||
* Time Complexity: O(log n) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(log n) | ||
* Space Complexity: O(1) | ||
* | ||
* The function `getNodeByKey` searches for a node in a binary tree based on a given key, using | ||
* either recursive or iterative methods. | ||
* @param {K} key - The `key` parameter is the key value that we are searching for in the tree. | ||
* It is used to identify the node that we want to retrieve. | ||
* @param iterationType - The `iterationType` parameter is an optional parameter that specifies the | ||
* type of iteration to use when searching for a node in the binary tree. It can have two possible | ||
* values: | ||
* @returns The function `getNodeByKey` returns a node (`NODE`) if a node with the specified key is | ||
* found in the binary tree. If no node is found, it returns `undefined`. | ||
*/ | ||
getNodeByKey(key, iterationType = 'ITERATIVE') { | ||
// return this.getNodes(key, this._DEFAULT_CALLBACK, true, this.root, iterationType)[0]; | ||
if (!this.isRealNode(this.root)) | ||
return; | ||
if (iterationType === 'RECURSIVE') { | ||
const dfs = (cur) => { | ||
if (cur.key === key) | ||
return cur; | ||
if (!this.isRealNode(cur.left) && !this.isRealNode(cur.right)) | ||
return; | ||
if (this.isRealNode(cur.left) && this._compare(cur.key, key) === 'GT') | ||
return dfs(cur.left); | ||
if (this.isRealNode(cur.right) && this._compare(cur.key, key) === 'LT') | ||
return dfs(cur.right); | ||
}; | ||
return dfs(this.root); | ||
} | ||
else { | ||
const stack = [this.root]; | ||
while (stack.length > 0) { | ||
const cur = stack.pop(); | ||
if (this.isRealNode(cur)) { | ||
if (this._compare(cur.key, key) === 'EQ') | ||
return cur; | ||
if (this.isRealNode(cur.left) && this._compare(cur.key, key) === 'GT') | ||
stack.push(cur.left); | ||
if (this.isRealNode(cur.right) && this._compare(cur.key, key) === 'LT') | ||
stack.push(cur.right); | ||
} | ||
} | ||
} | ||
} | ||
/** | ||
* Time Complexity: O(log n) | ||
* Space Complexity: O(k + log n) | ||
@@ -429,2 +381,3 @@ * / | ||
return []; | ||
callback = this._ensureCallback(identifier, callback); | ||
const ans = []; | ||
@@ -459,27 +412,25 @@ if (iterationType === 'RECURSIVE') { | ||
const cur = stack.pop(); | ||
if (this.isRealNode(cur)) { | ||
const callbackResult = callback(cur); | ||
if (callbackResult === identifier) { | ||
ans.push(cur); | ||
if (onlyOne) | ||
return ans; | ||
} | ||
// TODO potential bug | ||
if (callback === this._DEFAULT_CALLBACK) { | ||
if (this.isRealNode(cur.right) && this._compare(cur.key, identifier) === 'LT') | ||
stack.push(cur.right); | ||
if (this.isRealNode(cur.left) && this._compare(cur.key, identifier) === 'GT') | ||
stack.push(cur.left); | ||
// if (this.isRealNode(cur.right) && this._lt(cur.key, identifier as K)) stack.push(cur.right); | ||
// if (this.isRealNode(cur.left) && this._gt(cur.key, identifier as K)) stack.push(cur.left); | ||
// // @ts-ignore | ||
// if (this.isRealNode(cur.right) && cur.key > identifier) stack.push(cur.right); | ||
// // @ts-ignore | ||
// if (this.isRealNode(cur.left) && cur.key < identifier) stack.push(cur.left); | ||
} | ||
else { | ||
this.isRealNode(cur.right) && stack.push(cur.right); | ||
this.isRealNode(cur.left) && stack.push(cur.left); | ||
} | ||
const callbackResult = callback(cur); | ||
if (callbackResult === identifier) { | ||
ans.push(cur); | ||
if (onlyOne) | ||
return ans; | ||
} | ||
// TODO potential bug | ||
if (callback === this._DEFAULT_CALLBACK) { | ||
if (this.isRealNode(cur.right) && this._compare(cur.key, identifier) === 'LT') | ||
stack.push(cur.right); | ||
if (this.isRealNode(cur.left) && this._compare(cur.key, identifier) === 'GT') | ||
stack.push(cur.left); | ||
// if (this.isRealNode(cur.right) && this._lt(cur.key, identifier as K)) stack.push(cur.right); | ||
// if (this.isRealNode(cur.left) && this._gt(cur.key, identifier as K)) stack.push(cur.left); | ||
// // @ts-ignore | ||
// if (this.isRealNode(cur.right) && cur.key > identifier) stack.push(cur.right); | ||
// // @ts-ignore | ||
// if (this.isRealNode(cur.left) && cur.key < identifier) stack.push(cur.left); | ||
} | ||
else { | ||
this.isRealNode(cur.right) && stack.push(cur.right); | ||
this.isRealNode(cur.left) && stack.push(cur.left); | ||
} | ||
} | ||
@@ -519,2 +470,23 @@ } | ||
/** | ||
* Time Complexity: O(log n) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(log n) | ||
* Space Complexity: O(1) | ||
* | ||
* The function `getNodeByKey` searches for a node in a binary tree based on a given key, using | ||
* either recursive or iterative methods. | ||
* @param {K} key - The `key` parameter is the key value that we are searching for in the tree. | ||
* It is used to identify the node that we want to retrieve. | ||
* @param iterationType - The `iterationType` parameter is an optional parameter that specifies the | ||
* type of iteration to use when searching for a node in the binary tree. It can have two possible | ||
* values: | ||
* @returns The function `getNodeByKey` returns a node (`NODE`) if a node with the specified key is | ||
* found in the binary tree. If no node is found, it returns `undefined`. | ||
*/ | ||
getNodeByKey(key, iterationType = 'ITERATIVE') { | ||
return this.getNode(key, this._DEFAULT_CALLBACK, this.root, iterationType); | ||
} | ||
/** | ||
* Time complexity: O(n) | ||
@@ -834,3 +806,7 @@ * Space complexity: O(n) | ||
const compared = this.variant === 'STANDARD' ? extractedA - extractedB : extractedB - extractedA; | ||
return compared > 0 ? 'GT' : compared < 0 ? 'LT' : 'EQ'; | ||
if (compared > 0) | ||
return 'GT'; | ||
if (compared < 0) | ||
return 'LT'; | ||
return 'EQ'; | ||
} | ||
@@ -849,6 +825,3 @@ /** | ||
const extractedB = this.extractor(b); | ||
// return this.variant === BSTVariant.STANDARD ? extractedA < extractedB : extractedA > extractedB; | ||
return this.variant === 'STANDARD' ? extractedA < extractedB : extractedA > extractedB; | ||
// return extractedA < extractedB; | ||
// return a < b; | ||
} | ||
@@ -866,8 +839,5 @@ /** | ||
const extractedB = this.extractor(b); | ||
// return this.variant === BSTVariant.STANDARD ? extractedA > extractedB : extractedA < extractedB; | ||
return this.variant === 'STANDARD' ? extractedA > extractedB : extractedA < extractedB; | ||
// return extractedA > extractedB; | ||
// return a > b; | ||
} | ||
} | ||
exports.BST = BST; |
import type { BinaryTreeDeleteResult, BTNCallback, KeyOrNodeOrEntry, RBTreeOptions, RedBlackTreeNested, RedBlackTreeNodeNested } from '../../types'; | ||
import { CRUD, RBTNColor } from '../../types'; | ||
import { CP, CRUD, RBTNColor } from '../../types'; | ||
import { BST, BSTNode } from './bst'; | ||
@@ -258,2 +258,11 @@ import { IBinaryTree } from '../../interfaces'; | ||
protected _rightRotate(y: NODE | undefined): void; | ||
/** | ||
* The function compares two values using a comparator function and returns whether the first value | ||
* is greater than, less than, or equal to the second value. | ||
* @param {K} a - The parameter "a" is of type K. | ||
* @param {K} b - The parameter "b" in the above code represents a K. | ||
* @returns a value of type CP (ComparisonResult). The possible return values are 'GT' (greater | ||
* than), 'LT' (less than), or 'EQ' (equal). | ||
*/ | ||
protected _compare(a: K, b: K): CP; | ||
} |
@@ -217,2 +217,3 @@ "use strict"; | ||
const results = []; | ||
callback = this._ensureCallback(identifier, callback); | ||
const nodeToDelete = this.isRealNode(identifier) ? identifier : this.getNode(identifier, callback); | ||
@@ -602,3 +603,21 @@ if (!nodeToDelete) { | ||
} | ||
/** | ||
* The function compares two values using a comparator function and returns whether the first value | ||
* is greater than, less than, or equal to the second value. | ||
* @param {K} a - The parameter "a" is of type K. | ||
* @param {K} b - The parameter "b" in the above code represents a K. | ||
* @returns a value of type CP (ComparisonResult). The possible return values are 'GT' (greater | ||
* than), 'LT' (less than), or 'EQ' (equal). | ||
*/ | ||
_compare(a, b) { | ||
const extractedA = this.extractor(a); | ||
const extractedB = this.extractor(b); | ||
const compared = extractedA - extractedB; | ||
if (compared > 0) | ||
return 'GT'; | ||
if (compared < 0) | ||
return 'LT'; | ||
return 'EQ'; | ||
} | ||
} | ||
exports.RedBlackTree = RedBlackTree; |
@@ -213,2 +213,3 @@ "use strict"; | ||
const results = []; | ||
callback = this._ensureCallback(identifier, callback); | ||
const nodeToDelete = this.isRealNode(identifier) ? identifier : this.getNode(identifier, callback); | ||
@@ -215,0 +216,0 @@ if (!nodeToDelete) { |
{ | ||
"name": "red-black-tree-typed", | ||
"version": "1.51.5", | ||
"version": "1.51.7", | ||
"description": "RedBlackTree. Javascript & Typescript Data Structure.", | ||
@@ -145,4 +145,4 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"data-structure-typed": "^1.51.5" | ||
"data-structure-typed": "^1.51.7" | ||
} | ||
} |
@@ -248,2 +248,3 @@ /** | ||
if (!this.root) return deletedResult; | ||
callback = this._ensureCallback(identifier, callback); | ||
@@ -250,0 +251,0 @@ const curr: NODE | undefined = this.getNode(identifier, callback) ?? undefined; |
@@ -175,3 +175,2 @@ /** | ||
): BinaryTreeDeleteResult<NODE>[] { | ||
if ((identifier as any) instanceof AVLTreeNode) callback = (node => node) as C; | ||
const deletedResults = super.delete(identifier, callback); | ||
@@ -178,0 +177,0 @@ for (const { needBalanced } of deletedResults) { |
@@ -217,11 +217,16 @@ /** | ||
): NODE | undefined { | ||
if (keyOrNodeOrEntry === this.NIL) return; | ||
if (this.isRealNode(keyOrNodeOrEntry)) { | ||
return keyOrNodeOrEntry; | ||
} else if (this.isEntry(keyOrNodeOrEntry)) { | ||
if (keyOrNodeOrEntry[0] === null || keyOrNodeOrEntry[0] === undefined) return; | ||
return this.getNodeByKey(keyOrNodeOrEntry[0], iterationType); | ||
} else { | ||
if (keyOrNodeOrEntry === null || keyOrNodeOrEntry === undefined) return; | ||
return this.getNodeByKey(keyOrNodeOrEntry, iterationType); | ||
} | ||
if (this.isEntry(keyOrNodeOrEntry)) { | ||
const key = keyOrNodeOrEntry[0]; | ||
if (key === null || key === undefined) return; | ||
return this.getNodeByKey(key, iterationType); | ||
} | ||
const key = keyOrNodeOrEntry; | ||
if (key === null || key === undefined) return; | ||
return this.getNodeByKey(key, iterationType); | ||
} | ||
@@ -412,47 +417,2 @@ | ||
* Time Complexity: O(log n) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(log n) | ||
* Space Complexity: O(1) | ||
* | ||
* The function `getNodeByKey` searches for a node in a binary tree based on a given key, using | ||
* either recursive or iterative methods. | ||
* @param {K} key - The `key` parameter is the key value that we are searching for in the tree. | ||
* It is used to identify the node that we want to retrieve. | ||
* @param iterationType - The `iterationType` parameter is an optional parameter that specifies the | ||
* type of iteration to use when searching for a node in the binary tree. It can have two possible | ||
* values: | ||
* @returns The function `getNodeByKey` returns a node (`NODE`) if a node with the specified key is | ||
* found in the binary tree. If no node is found, it returns `undefined`. | ||
*/ | ||
override getNodeByKey(key: K, iterationType: IterationType = 'ITERATIVE'): NODE | undefined { | ||
// return this.getNodes(key, this._DEFAULT_CALLBACK, true, this.root, iterationType)[0]; | ||
if (!this.isRealNode(this.root)) return; | ||
if (iterationType === 'RECURSIVE') { | ||
const dfs = (cur: NODE): NODE | undefined => { | ||
if (cur.key === key) return cur; | ||
if (!this.isRealNode(cur.left) && !this.isRealNode(cur.right)) return; | ||
if (this.isRealNode(cur.left) && this._compare(cur.key, key) === 'GT') return dfs(cur.left); | ||
if (this.isRealNode(cur.right) && this._compare(cur.key, key) === 'LT') return dfs(cur.right); | ||
}; | ||
return dfs(this.root); | ||
} else { | ||
const stack = [this.root]; | ||
while (stack.length > 0) { | ||
const cur = stack.pop(); | ||
if (this.isRealNode(cur)) { | ||
if (this._compare(cur.key, key) === 'EQ') return cur; | ||
if (this.isRealNode(cur.left) && this._compare(cur.key, key) === 'GT') stack.push(cur.left); | ||
if (this.isRealNode(cur.right) && this._compare(cur.key, key) === 'LT') stack.push(cur.right); | ||
} | ||
} | ||
} | ||
} | ||
/** | ||
* Time Complexity: O(log n) | ||
* Space Complexity: O(k + log n) | ||
@@ -493,2 +453,3 @@ * / | ||
if (!beginRoot) return []; | ||
callback = this._ensureCallback(identifier, callback); | ||
const ans: NODE[] = []; | ||
@@ -519,25 +480,23 @@ | ||
while (stack.length > 0) { | ||
const cur = stack.pop(); | ||
if (this.isRealNode(cur)) { | ||
const callbackResult = callback(cur); | ||
if (callbackResult === identifier) { | ||
ans.push(cur); | ||
if (onlyOne) return ans; | ||
} | ||
// TODO potential bug | ||
if (callback === this._DEFAULT_CALLBACK) { | ||
if (this.isRealNode(cur.right) && this._compare(cur.key, identifier as K) === 'LT') stack.push(cur.right); | ||
if (this.isRealNode(cur.left) && this._compare(cur.key, identifier as K) === 'GT') stack.push(cur.left); | ||
const cur = stack.pop()!; | ||
const callbackResult = callback(cur); | ||
if (callbackResult === identifier) { | ||
ans.push(cur); | ||
if (onlyOne) return ans; | ||
} | ||
// TODO potential bug | ||
if (callback === this._DEFAULT_CALLBACK) { | ||
if (this.isRealNode(cur.right) && this._compare(cur.key, identifier as K) === 'LT') stack.push(cur.right); | ||
if (this.isRealNode(cur.left) && this._compare(cur.key, identifier as K) === 'GT') stack.push(cur.left); | ||
// if (this.isRealNode(cur.right) && this._lt(cur.key, identifier as K)) stack.push(cur.right); | ||
// if (this.isRealNode(cur.left) && this._gt(cur.key, identifier as K)) stack.push(cur.left); | ||
// if (this.isRealNode(cur.right) && this._lt(cur.key, identifier as K)) stack.push(cur.right); | ||
// if (this.isRealNode(cur.left) && this._gt(cur.key, identifier as K)) stack.push(cur.left); | ||
// // @ts-ignore | ||
// if (this.isRealNode(cur.right) && cur.key > identifier) stack.push(cur.right); | ||
// // @ts-ignore | ||
// if (this.isRealNode(cur.left) && cur.key < identifier) stack.push(cur.left); | ||
} else { | ||
this.isRealNode(cur.right) && stack.push(cur.right); | ||
this.isRealNode(cur.left) && stack.push(cur.left); | ||
} | ||
// // @ts-ignore | ||
// if (this.isRealNode(cur.right) && cur.key > identifier) stack.push(cur.right); | ||
// // @ts-ignore | ||
// if (this.isRealNode(cur.left) && cur.key < identifier) stack.push(cur.left); | ||
} else { | ||
this.isRealNode(cur.right) && stack.push(cur.right); | ||
this.isRealNode(cur.left) && stack.push(cur.left); | ||
} | ||
@@ -586,2 +545,25 @@ } | ||
/** | ||
* Time Complexity: O(log n) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(log n) | ||
* Space Complexity: O(1) | ||
* | ||
* The function `getNodeByKey` searches for a node in a binary tree based on a given key, using | ||
* either recursive or iterative methods. | ||
* @param {K} key - The `key` parameter is the key value that we are searching for in the tree. | ||
* It is used to identify the node that we want to retrieve. | ||
* @param iterationType - The `iterationType` parameter is an optional parameter that specifies the | ||
* type of iteration to use when searching for a node in the binary tree. It can have two possible | ||
* values: | ||
* @returns The function `getNodeByKey` returns a node (`NODE`) if a node with the specified key is | ||
* found in the binary tree. If no node is found, it returns `undefined`. | ||
*/ | ||
override getNodeByKey(key: K, iterationType: IterationType = 'ITERATIVE'): NODE | undefined { | ||
return this.getNode(key, this._DEFAULT_CALLBACK, this.root, iterationType); | ||
} | ||
/** | ||
* Time complexity: O(n) | ||
@@ -928,3 +910,5 @@ * Space complexity: O(n) | ||
return compared > 0 ? 'GT' : compared < 0 ? 'LT' : 'EQ'; | ||
if (compared > 0) return 'GT'; | ||
if (compared < 0) return 'LT'; | ||
return 'EQ'; | ||
} | ||
@@ -944,6 +928,3 @@ | ||
const extractedB = this.extractor(b); | ||
// return this.variant === BSTVariant.STANDARD ? extractedA < extractedB : extractedA > extractedB; | ||
return this.variant === 'STANDARD' ? extractedA < extractedB : extractedA > extractedB; | ||
// return extractedA < extractedB; | ||
// return a < b; | ||
} | ||
@@ -962,7 +943,4 @@ | ||
const extractedB = this.extractor(b); | ||
// return this.variant === BSTVariant.STANDARD ? extractedA > extractedB : extractedA < extractedB; | ||
return this.variant === 'STANDARD' ? extractedA > extractedB : extractedA < extractedB; | ||
// return extractedA > extractedB; | ||
// return a > b; | ||
} | ||
} |
@@ -9,3 +9,3 @@ import type { | ||
} from '../../types'; | ||
import { CRUD, RBTNColor } from '../../types'; | ||
import { CP, CRUD, RBTNColor } from '../../types'; | ||
import { BST, BSTNode } from './bst'; | ||
@@ -256,3 +256,3 @@ import { IBinaryTree } from '../../interfaces'; | ||
const results: BinaryTreeDeleteResult<NODE>[] = []; | ||
callback = this._ensureCallback(identifier, callback); | ||
const nodeToDelete = this.isRealNode(identifier) ? identifier : this.getNode(identifier, callback); | ||
@@ -661,2 +661,19 @@ | ||
} | ||
/** | ||
* The function compares two values using a comparator function and returns whether the first value | ||
* is greater than, less than, or equal to the second value. | ||
* @param {K} a - The parameter "a" is of type K. | ||
* @param {K} b - The parameter "b" in the above code represents a K. | ||
* @returns a value of type CP (ComparisonResult). The possible return values are 'GT' (greater | ||
* than), 'LT' (less than), or 'EQ' (equal). | ||
*/ | ||
protected override _compare(a: K, b: K): CP { | ||
const extractedA = this.extractor(a); | ||
const extractedB = this.extractor(b); | ||
const compared = extractedA - extractedB; | ||
if (compared > 0) return 'GT'; | ||
if (compared < 0) return 'LT'; | ||
return 'EQ'; | ||
} | ||
} |
@@ -260,2 +260,3 @@ /** | ||
const results: BinaryTreeDeleteResult<NODE>[] = []; | ||
callback = this._ensureCallback(identifier, callback); | ||
@@ -262,0 +263,0 @@ const nodeToDelete = this.isRealNode(identifier) ? identifier : this.getNode(identifier, callback); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2094433
39820
Updateddata-structure-typed@^1.51.7