type Entity = { title?: string; id: number };
const tree = new RedBlackTree<Entity>((a, b) => a.id - b.id);
tree.add({ id: 10 });
tree.add({ id: 9 });
tree.add({ id: 8 });
// find
const ent: Entity = { title: 'some obj', id: 9 };
console.log(tree.find(ent)); // { value:{id: 9}, color:'B', left:{...}, right:{...} } ;
// iterators also works
console.log([...tree]); // [ {id: 8}, { id: 9}, {id: 10} ]
// inorder by nodes:
for (const node of tree.inorder()) {
console.log(node.color);
}
-
Notifications
You must be signed in to change notification settings - Fork 0
License
o-panikarovskiy/redblacktree
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published