data-structure-typed
Advanced tools
Comparing version 1.52.5 to 1.52.6
@@ -11,3 +11,3 @@ # Changelog | ||
## [v1.52.5](https://github.com/zrwusa/data-structure-typed/compare/v1.51.5...main) (upcoming) | ||
## [v1.52.6](https://github.com/zrwusa/data-structure-typed/compare/v1.51.5...main) (upcoming) | ||
@@ -14,0 +14,0 @@ ### Changes |
@@ -18,2 +18,4 @@ "use strict"; | ||
this._value = value || undefined; | ||
if (children) | ||
this._children = children; | ||
} | ||
@@ -20,0 +22,0 @@ /** |
@@ -15,2 +15,4 @@ export class TreeNode { | ||
this._value = value || undefined; | ||
if (children) | ||
this._children = children; | ||
} | ||
@@ -17,0 +19,0 @@ _key; |
{ | ||
"name": "data-structure-typed", | ||
"version": "1.52.5", | ||
"version": "1.52.6", | ||
"description": "Javascript Data Structure. Heap, Binary Tree, Red Black Tree, Linked List, Deque, Trie, HashMap, Directed Graph, Undirected Graph, Binary Search Tree(BST), AVL Tree, Priority Queue, Graph, Queue, Tree Multiset, Singly Linked List, Doubly Linked List, Max Heap, Max Priority Queue, Min Heap, Min Priority Queue, Stack. Benchmark compared with C++ STL. API aligned with ES6 and Java.util. Usability is comparable to Python", | ||
@@ -69,7 +69,7 @@ "main": "dist/cjs/index.js", | ||
"auto-changelog": "^2.4.0", | ||
"avl-tree-typed": "^1.52.4", | ||
"avl-tree-typed": "^1.52.5", | ||
"benchmark": "^2.1.4", | ||
"binary-tree-typed": "^1.52.4", | ||
"bst-typed": "^1.52.4", | ||
"data-structure-typed": "^1.52.4", | ||
"binary-tree-typed": "^1.52.5", | ||
"bst-typed": "^1.52.5", | ||
"data-structure-typed": "^1.52.5", | ||
"dependency-cruiser": "^14.1.0", | ||
@@ -83,3 +83,3 @@ "doctoc": "^2.2.1", | ||
"fast-glob": "^3.3.1", | ||
"heap-typed": "^1.52.4", | ||
"heap-typed": "^1.52.5", | ||
"istanbul-badges-readme": "^1.8.5", | ||
@@ -86,0 +86,0 @@ "jest": "^29.7.0", |
@@ -39,3 +39,3 @@ import { AVLTree } from 'avl-tree-typed'; | ||
const node15 = tree.getNode(15); | ||
const getMinNodeBySpecificNode = node15 && tree.getLeftMost(node15); | ||
const getMinNodeBySpecificNode = node15 && tree.getLeftMost(node => node, node15); | ||
expect(getMinNodeBySpecificNode?.key).toBe(12); | ||
@@ -42,0 +42,0 @@ |
@@ -33,3 +33,3 @@ import { BST, BSTNode } from 'bst-typed'; | ||
const node15 = bst.getNode(15); | ||
const minNodeBySpecificNode = node15 && bst.getLeftMost(node15); | ||
const minNodeBySpecificNode = node15 && bst.getLeftMost(node => node, node15); | ||
expect(minNodeBySpecificNode?.key).toBe(12); | ||
@@ -234,3 +234,3 @@ | ||
}); | ||
const minNodeBySpecificNode = node15 && objBST.getLeftMost(node15); | ||
const minNodeBySpecificNode = node15 && objBST.getLeftMost(node => node, node15); | ||
expect(minNodeBySpecificNode?.key).toBe(12); | ||
@@ -237,0 +237,0 @@ |
@@ -851,106 +851,109 @@ import { BinaryTree, BinaryTreeNode, BTNEntry } from '../../../../src'; | ||
describe('BinaryTree traversals', () => { | ||
const tree = new BinaryTree<number>(); | ||
it('traversals', () => { | ||
const tree = new BinaryTree<number>(); | ||
const arr = [35, 20, 40, 15, 29, null, 50, null, 16, 28, 30, 45, 55]; | ||
tree.refill(arr); | ||
expect(tree.bfs(node => node, tree.root, 'ITERATIVE', true).map(node => (node ? node.key : null))).toEqual([ | ||
35, | ||
20, | ||
40, | ||
15, | ||
29, | ||
null, | ||
50, | ||
null, | ||
16, | ||
28, | ||
30, | ||
45, | ||
55 | ||
]); | ||
expect(tree.bfs(node => node, tree.root, 'RECURSIVE', true).map(node => (node ? node.key : null))).toEqual([ | ||
35, | ||
20, | ||
40, | ||
15, | ||
29, | ||
null, | ||
50, | ||
null, | ||
16, | ||
28, | ||
30, | ||
45, | ||
55 | ||
]); | ||
expect(tree.bfs(node => node, tree.root, 'ITERATIVE').map(node => (node === null ? null : node.key))).toEqual([ | ||
35, 20, 40, 15, 29, 50, 16, 28, 30, 45, 55 | ||
]); | ||
expect(tree.bfs(node => node, tree.root, 'RECURSIVE').map(node => (node === null ? null : node.key))).toEqual([ | ||
35, 20, 40, 15, 29, 50, 16, 28, 30, 45, 55 | ||
]); | ||
const arr = [35, 20, 40, 15, 29, null, 50, null, 16, 28, 30, 45, 55]; | ||
tree.refill(arr); | ||
expect(tree.bfs(node => node, tree.root, 'ITERATIVE', true).map(node => (node ? node.key : null))).toEqual([ | ||
35, | ||
20, | ||
40, | ||
15, | ||
29, | ||
null, | ||
50, | ||
null, | ||
16, | ||
28, | ||
30, | ||
45, | ||
55 | ||
]); | ||
expect(tree.bfs(node => node, tree.root, 'RECURSIVE', true).map(node => (node ? node.key : null))).toEqual([ | ||
35, | ||
20, | ||
40, | ||
15, | ||
29, | ||
null, | ||
50, | ||
null, | ||
16, | ||
28, | ||
30, | ||
45, | ||
55 | ||
]); | ||
expect(tree.bfs(node => node, tree.root, 'ITERATIVE').map(node => (node === null ? null : node.key))).toEqual([ | ||
35, 20, 40, 15, 29, 50, 16, 28, 30, 45, 55 | ||
]); | ||
expect(tree.bfs(node => node, tree.root, 'RECURSIVE').map(node => (node === null ? null : node.key))).toEqual([ | ||
35, 20, 40, 15, 29, 50, 16, 28, 30, 45, 55 | ||
]); | ||
expect(tree.dfs(node => node.key, 'PRE')).toEqual([35, 20, 15, 16, 29, 28, 30, 40, 50, 45, 55]); | ||
expect(tree.dfs(node => node.key, 'PRE', tree.root, 'RECURSIVE')).toEqual([ | ||
35, 20, 15, 16, 29, 28, 30, 40, 50, 45, 55 | ||
]); | ||
expect(tree.dfs(node => node, 'PRE', tree.root, 'ITERATIVE', true).map(node => (node ? node.key : null))).toEqual([ | ||
35, | ||
20, | ||
15, | ||
null, | ||
16, | ||
29, | ||
28, | ||
30, | ||
40, | ||
null, | ||
50, | ||
45, | ||
55 | ||
]); | ||
expect(tree.dfs(node => node, 'PRE', tree.root, 'RECURSIVE', true).map(node => (node ? node.key : null))).toEqual([ | ||
35, | ||
20, | ||
15, | ||
null, | ||
16, | ||
29, | ||
28, | ||
30, | ||
40, | ||
null, | ||
50, | ||
45, | ||
55 | ||
]); | ||
expect(tree.dfs(node => node.key, 'PRE')).toEqual([35, 20, 15, 16, 29, 28, 30, 40, 50, 45, 55]); | ||
expect(tree.dfs(node => node.key, 'PRE', tree.root, 'RECURSIVE')).toEqual([ | ||
35, 20, 15, 16, 29, 28, 30, 40, 50, 45, 55 | ||
]); | ||
expect(tree.dfs(node => node, 'PRE', tree.root, 'ITERATIVE', true).map(node => (node === null ? null : node.key))).toEqual([ | ||
35, | ||
20, | ||
15, | ||
null, | ||
16, | ||
29, | ||
28, | ||
30, | ||
40, | ||
null, | ||
50, | ||
45, | ||
55 | ||
]); | ||
expect(tree.dfs(node => node, 'PRE', tree.root, 'RECURSIVE', true).map(node => (node ? node.key : null))).toEqual([ | ||
35, | ||
20, | ||
15, | ||
null, | ||
16, | ||
29, | ||
28, | ||
30, | ||
40, | ||
null, | ||
50, | ||
45, | ||
55 | ||
]); | ||
expect(tree.dfs(node => node.key, 'IN')).toEqual([15, 16, 20, 28, 29, 30, 35, 40, 45, 50, 55]); | ||
expect(tree.dfs(node => node.key, 'POST')).toEqual([16, 15, 28, 30, 29, 20, 45, 55, 50, 40, 35]); | ||
expect(tree.dfs(node => node.key, 'POST', tree.root, 'RECURSIVE')).toEqual([ | ||
16, 15, 28, 30, 29, 20, 45, 55, 50, 40, 35 | ||
]); | ||
expect(tree.bfs(node => node.key, tree.root, 'RECURSIVE')).toEqual([35, 20, 40, 15, 29, 50, 16, 28, 30, 45, 55]); | ||
expect(tree.bfs(node => node.key, tree.root, 'ITERATIVE')).toEqual([35, 20, 40, 15, 29, 50, 16, 28, 30, 45, 55]); | ||
expect(tree.dfs(node => node.key, 'IN')).toEqual([15, 16, 20, 28, 29, 30, 35, 40, 45, 50, 55]); | ||
expect(tree.dfs(node => node.key, 'POST')).toEqual([16, 15, 28, 30, 29, 20, 45, 55, 50, 40, 35]); | ||
expect(tree.dfs(node => node.key, 'POST', tree.root, 'RECURSIVE')).toEqual([ | ||
16, 15, 28, 30, 29, 20, 45, 55, 50, 40, 35 | ||
]); | ||
expect(tree.bfs(node => node.key, tree.root, 'RECURSIVE')).toEqual([35, 20, 40, 15, 29, 50, 16, 28, 30, 45, 55]); | ||
expect(tree.bfs(node => node.key, tree.root, 'ITERATIVE')).toEqual([35, 20, 40, 15, 29, 50, 16, 28, 30, 45, 55]); | ||
expect(tree.listLevels(node => node.key)).toEqual([[35], [20, 40], [15, 29, 50], [16, 28, 30, 45, 55]]); | ||
expect(tree.listLevels(node => node.key)).toEqual([[35], [20, 40], [15, 29, 50], [16, 28, 30, 45, 55]]); | ||
expect(tree.listLevels(node => node.key, tree.root, 'RECURSIVE')).toEqual([ | ||
[35], | ||
[20, 40], | ||
[15, 29, 50], | ||
[16, 28, 30, 45, 55] | ||
]); | ||
expect(tree.listLevels(node => (node ? node.key : null), tree.root, 'ITERATIVE', true)).toEqual([ | ||
[35], | ||
[20, 40], | ||
[15, 29, null, 50], | ||
[null, 16, 28, 30, 45, 55] | ||
]); | ||
expect(tree.listLevels(node => (node ? node.key : null), tree.root, 'RECURSIVE', true)).toEqual([ | ||
[35], | ||
[20, 40], | ||
[15, 29, null, 50], | ||
[null, 16, 28, 30, 45, 55] | ||
]); | ||
expect(tree.listLevels(node => node.key, tree.root, 'RECURSIVE')).toEqual([ | ||
[35], | ||
[20, 40], | ||
[15, 29, 50], | ||
[16, 28, 30, 45, 55] | ||
]); | ||
expect(tree.listLevels(node => (node ? node.key : null), tree.root, 'ITERATIVE', true)).toEqual([ | ||
[35], | ||
[20, 40], | ||
[15, 29, null, 50], | ||
[null, 16, 28, 30, 45, 55] | ||
]); | ||
expect(tree.listLevels(node => (node ? node.key : null), tree.root, 'RECURSIVE', true)).toEqual([ | ||
[35], | ||
[20, 40], | ||
[15, 29, null, 50], | ||
[null, 16, 28, 30, 45, 55] | ||
]); | ||
}) | ||
}); | ||
@@ -957,0 +960,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
5034371
91370