undirected-graph-typed
Advanced tools
Comparing version 1.41.7 to 1.41.8
@@ -29,2 +29,4 @@ /** | ||
get root(): RBTreeNode; | ||
protected _size: number; | ||
get size(): number; | ||
/** | ||
@@ -37,7 +39,7 @@ * The `insert` function inserts a new node with a given key into a red-black tree and fixes any | ||
*/ | ||
insert(key: number): void; | ||
add(key: number): void; | ||
/** | ||
* The `delete` function in TypeScript is used to remove a node with a specific key from a red-black | ||
* tree. | ||
* @param {RBTreeNode} node - The `node` parameter is of type `RBTreeNode` and represents the current | ||
* @param {number} key - The `node` parameter is of type `RBTreeNode` and represents the current | ||
* node being processed in the delete operation. | ||
@@ -85,2 +87,3 @@ * @returns The `delete` function does not return anything. It has a return type of `void`. | ||
getPredecessor(x: RBTreeNode): RBTreeNode; | ||
clear(): void; | ||
print(beginRoot?: RBTreeNode): void; | ||
@@ -87,0 +90,0 @@ /** |
@@ -33,2 +33,3 @@ "use strict"; | ||
constructor() { | ||
this._size = 0; | ||
this._root = exports.NIL; | ||
@@ -39,2 +40,5 @@ } | ||
} | ||
get size() { | ||
return this._size; | ||
} | ||
/** | ||
@@ -47,3 +51,3 @@ * The `insert` function inserts a new node with a given key into a red-black tree and fixes any | ||
*/ | ||
insert(key) { | ||
add(key) { | ||
const node = new RBTreeNode(key, types_1.RBTNColor.RED); | ||
@@ -75,8 +79,11 @@ node.left = exports.NIL; | ||
node.color = types_1.RBTNColor.BLACK; | ||
this._size++; | ||
return; | ||
} | ||
if (node.parent.parent === null) { | ||
this._size++; | ||
return; | ||
} | ||
this._fixInsert(node); | ||
this._size++; | ||
} | ||
@@ -86,3 +93,3 @@ /** | ||
* tree. | ||
* @param {RBTreeNode} node - The `node` parameter is of type `RBTreeNode` and represents the current | ||
* @param {number} key - The `node` parameter is of type `RBTreeNode` and represents the current | ||
* node being processed in the delete operation. | ||
@@ -107,2 +114,3 @@ * @returns The `delete` function does not return anything. It has a return type of `void`. | ||
if (z === exports.NIL) { | ||
this._size--; | ||
return; | ||
@@ -140,2 +148,3 @@ } | ||
} | ||
this._size--; | ||
}; | ||
@@ -229,2 +238,6 @@ helper(this.root); | ||
} | ||
clear() { | ||
this._root = exports.NIL; | ||
this._size = 0; | ||
} | ||
print(beginRoot = this.root) { | ||
@@ -231,0 +244,0 @@ const display = (root) => { |
{ | ||
"name": "undirected-graph-typed", | ||
"version": "1.41.7", | ||
"version": "1.41.8", | ||
"description": "Undirected Graph. Javascript & Typescript Data Structure.", | ||
@@ -148,4 +148,4 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"data-structure-typed": "^1.41.7" | ||
"data-structure-typed": "^1.41.8" | ||
} | ||
} |
@@ -145,3 +145,3 @@ /** | ||
protected defaultOneParamCallback = (node: N) => node.key; | ||
/** | ||
@@ -148,0 +148,0 @@ * Creates a new instance of BinaryTreeNode with the given key and value. |
@@ -39,3 +39,3 @@ /** | ||
} | ||
/** | ||
@@ -42,0 +42,0 @@ * The function creates a new binary search tree node with the given key and value. |
@@ -47,2 +47,8 @@ /** | ||
protected _size: number = 0; | ||
get size(): number { | ||
return this._size; | ||
} | ||
/** | ||
@@ -55,3 +61,3 @@ * The `insert` function inserts a new node with a given key into a red-black tree and fixes any | ||
*/ | ||
insert(key: number): void { | ||
add(key: number): void { | ||
const node: RBTreeNode = new RBTreeNode(key, RBTNColor.RED); | ||
@@ -84,2 +90,3 @@ node.left = NIL; | ||
node.color = RBTNColor.BLACK; | ||
this._size++; | ||
return; | ||
@@ -89,2 +96,3 @@ } | ||
if (node.parent.parent === null) { | ||
this._size++; | ||
return; | ||
@@ -94,2 +102,3 @@ } | ||
this._fixInsert(node); | ||
this._size++; | ||
} | ||
@@ -100,3 +109,3 @@ | ||
* tree. | ||
* @param {RBTreeNode} node - The `node` parameter is of type `RBTreeNode` and represents the current | ||
* @param {number} key - The `node` parameter is of type `RBTreeNode` and represents the current | ||
* node being processed in the delete operation. | ||
@@ -122,2 +131,3 @@ * @returns The `delete` function does not return anything. It has a return type of `void`. | ||
if (z === NIL) { | ||
this._size--; | ||
return; | ||
@@ -154,2 +164,3 @@ } | ||
} | ||
this._size--; | ||
}; | ||
@@ -252,2 +263,7 @@ helper(this.root); | ||
clear() { | ||
this._root = NIL; | ||
this._size = 0; | ||
} | ||
print(beginRoot: RBTreeNode = this.root) { | ||
@@ -254,0 +270,0 @@ const display = (root: RBTreeNode | null): void => { |
1434633
25506
Updateddata-structure-typed@^1.41.8