[rbtree] extracted RBTNColor to types

This commit is contained in:
Revone 2023-11-01 11:52:44 +08:00
parent 82168eb4a2
commit ea3ab1283e
5 changed files with 39 additions and 39 deletions

View file

@ -8,10 +8,11 @@ All notable changes to this project will be documented in this file.
- [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
- [`auto-changelog`](https://github.com/CookPete/auto-changelog)
## [v1.40.0](https://github.com/zrwusa/data-structure-typed/compare/v1.35.0...main) (upcoming)
## [v1.41.0](https://github.com/zrwusa/data-structure-typed/compare/v1.35.0...main) (upcoming)
### Changes
- Rbtree [`#31`](https://github.com/zrwusa/data-structure-typed/pull/31)
- [graph test] edge cases enriched [`#30`](https://github.com/zrwusa/data-structure-typed/pull/30)
- [graph] Modify the data structure design of the graph to change the g… [`#29`](https://github.com/zrwusa/data-structure-typed/pull/29)
- Optimization [`#23`](https://github.com/zrwusa/data-structure-typed/pull/23)

50
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "data-structure-typed",
"version": "1.40.0",
"version": "1.41.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "data-structure-typed",
"version": "1.40.0",
"version": "1.41.0",
"license": "MIT",
"devDependencies": {
"@types/benchmark": "^2.1.3",
@ -15,17 +15,17 @@
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"auto-changelog": "^2.4.0",
"avl-tree-typed": "^1.39.6",
"avl-tree-typed": "^1.40.0",
"benchmark": "^2.1.4",
"binary-tree-typed": "^1.39.6",
"bst-typed": "^1.39.6",
"binary-tree-typed": "^1.40.0",
"bst-typed": "^1.40.0",
"dependency-cruiser": "^14.1.0",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.28.1",
"heap-typed": "^1.39.6",
"heap-typed": "^1.40.0",
"istanbul-badges-readme": "^1.8.5",
"jest": "^29.7.0",
"prettier": "^3.0.3",
@ -2728,12 +2728,12 @@
}
},
"node_modules/avl-tree-typed": {
"version": "1.39.6",
"resolved": "https://registry.npmjs.org/avl-tree-typed/-/avl-tree-typed-1.39.6.tgz",
"integrity": "sha512-Yejek2E2+TvXMfCTBjZ9vXYucbOi7sRKo9TJLTvN5FbZ82pnG5MRsik98IvluU0ZY9lEFwu7iFVnPSe2BFdWqQ==",
"version": "1.40.0",
"resolved": "https://registry.npmjs.org/avl-tree-typed/-/avl-tree-typed-1.40.0.tgz",
"integrity": "sha512-Nw2sLCkPmXQWZRJXhQ6BacyWNdX199sjifhdZUOJPLyq9ha+gFzyq2yQCG3+7QrMRCo9JsPIXXSw8PPKPAK2CA==",
"dev": true,
"dependencies": {
"data-structure-typed": "^1.39.6"
"data-structure-typed": "^1.40.0"
}
},
"node_modules/babel-jest": {
@ -2927,12 +2927,12 @@
}
},
"node_modules/binary-tree-typed": {
"version": "1.39.6",
"resolved": "https://registry.npmjs.org/binary-tree-typed/-/binary-tree-typed-1.39.6.tgz",
"integrity": "sha512-IkiWRDA+wni3ye5A1l+ogIxfvGflcBKmagU599GIffmkeuLlLVjP2tQyvqpCzEwVRtRO64zEBtL/p30RsNbeew==",
"version": "1.40.0",
"resolved": "https://registry.npmjs.org/binary-tree-typed/-/binary-tree-typed-1.40.0.tgz",
"integrity": "sha512-j459EByswkZFuN4bte7PV8cwwtOFB+37Zwsh2gQJ4k+He/9wSpURaZDXebB4Z4l2Lu+BM/gt4542DEwEykaGaQ==",
"dev": true,
"dependencies": {
"data-structure-typed": "^1.39.6"
"data-structure-typed": "^1.40.0"
}
},
"node_modules/brace-expansion": {
@ -3011,12 +3011,12 @@
}
},
"node_modules/bst-typed": {
"version": "1.39.6",
"resolved": "https://registry.npmjs.org/bst-typed/-/bst-typed-1.39.6.tgz",
"integrity": "sha512-cP9BvJAlEZwLt3lgZFC1PdklD+nzG4ZqxNqEdSxNxvxlbc8RuhlLo6J2bCywnJN+zH/FyDQpM9iBEq07gEixWA==",
"version": "1.40.0",
"resolved": "https://registry.npmjs.org/bst-typed/-/bst-typed-1.40.0.tgz",
"integrity": "sha512-PxM2LtwQOyhytsjtE4dN7XN6GfFHiUfs++jdHVSpkGOqDFNWBM3CYar/nlTjUsTIKzBSSt7BfSIBwo1Lejhwhw==",
"dev": true,
"dependencies": {
"data-structure-typed": "^1.39.6"
"data-structure-typed": "^1.40.0"
}
},
"node_modules/buffer-from": {
@ -3413,9 +3413,9 @@
}
},
"node_modules/data-structure-typed": {
"version": "1.39.6",
"resolved": "https://registry.npmjs.org/data-structure-typed/-/data-structure-typed-1.39.6.tgz",
"integrity": "sha512-u9wQfa/7gHiW6Q1SxltLS+EoK8CQwuG7fdcMMrn4FdNgW6rPYfEqy2yNSDlJcbaEZANDQ58cjYLzbjXYQxlQvA==",
"version": "1.40.0",
"resolved": "https://registry.npmjs.org/data-structure-typed/-/data-structure-typed-1.40.0.tgz",
"integrity": "sha512-QW3lgqczAA5pKcjfxVH3+kFUi7vKRbOGcPTuFuhGK756E01GiEcl0WJGf0AXCXmTLbqjvLWGKT7K0qFR9RDPgw==",
"dev": true
},
"node_modules/debug": {
@ -4771,12 +4771,12 @@
}
},
"node_modules/heap-typed": {
"version": "1.39.6",
"resolved": "https://registry.npmjs.org/heap-typed/-/heap-typed-1.39.6.tgz",
"integrity": "sha512-Qi7NbDUnlCS5JSGfemizcJwtFMfGXsSUUZt+h9COTLlGvU4oTQ9t45G60cp4jEywSzXDNUBA/lLkjN8R2uvXJw==",
"version": "1.40.0",
"resolved": "https://registry.npmjs.org/heap-typed/-/heap-typed-1.40.0.tgz",
"integrity": "sha512-wEdbSCeI3DpHtCNU4rboi6AEZfxRt1CHRAKG6wtA1+X3aX4IyrGC7lugH06ltrNa0kjZF98r2YFSirFzhWFpkA==",
"dev": true,
"dependencies": {
"data-structure-typed": "^1.39.6"
"data-structure-typed": "^1.40.0"
}
},
"node_modules/html-escaper": {

View file

@ -1,6 +1,6 @@
{
"name": "data-structure-typed",
"version": "1.40.0",
"version": "1.41.0",
"description": "Data Structures of Javascript & TypeScript. Binary Tree, BST, Graph, Heap, Priority Queue, Linked List, Queue, Deque, Stack, AVL Tree, Tree Multiset, Trie, Directed Graph, Undirected Graph, Singly Linked List, Doubly Linked List, Max Heap, Max Priority Queue, Min Heap, Min Priority Queue.",
"main": "dist/cjs/index.js",
"module": "dist/mjs/index.js",
@ -61,17 +61,17 @@
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"auto-changelog": "^2.4.0",
"avl-tree-typed": "^1.39.6",
"avl-tree-typed": "^1.40.0",
"benchmark": "^2.1.4",
"binary-tree-typed": "^1.39.6",
"bst-typed": "^1.39.6",
"binary-tree-typed": "^1.40.0",
"bst-typed": "^1.40.0",
"dependency-cruiser": "^14.1.0",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.28.1",
"heap-typed": "^1.39.6",
"heap-typed": "^1.40.0",
"istanbul-badges-readme": "^1.8.5",
"jest": "^29.7.0",
"prettier": "^3.0.3",

View file

@ -1,4 +1,4 @@
export enum RBTNColor {BLACK, RED}
import {RBTNColor} from "../../types";
export class RBTreeNode {
key: number = 0;
@ -110,7 +110,6 @@ export class RedBlackTree {
}
if (z === this.NIL) {
console.log("Couldn't find key in the tree");
return;
}

View file

@ -1,8 +1,8 @@
import {BinaryTreeOptions} from './binary-tree';
import {RBTreeNode} from '../../../data-structures';
// import {BinaryTreeOptions} from './binary-tree';
// import {RBTreeNode} from '../../../data-structures';
export enum RBColor { RED = 'RED', BLACK = 'BLACK'}
export enum RBTNColor { RED = 1, BLACK = 0}
export type RBTreeNodeNested<T> = RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
export type RBTreeOptions = BinaryTreeOptions & {}
// export type RBTreeNodeNested<T> = RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, RBTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//
// export type RBTreeOptions = BinaryTreeOptions & {}