ravl
v0.2.0
Published
aRray AVL Implementation
Downloads
3
Readme
Table of Contents
ravl
A fast, lightweight, persistent AVL tree implementation written typescript.
Installation
npm install ravl
Usage
Create a tree
const {Tree} = require('ravl');
let a = new Tree();
Use a custom comparator
function compare({key: a}, {key: b}) {
if (a < b) return -1;
if (a > b) return 1;
return 0;
}
let a = new Tree({compare})
Insert elements
a = a.add({key: 'a', value: 1});
a = a.add({key: 'b', value: 2});
Test membership, retrieve values
a.has({key: 'b'}) // {key: 'a', value: 2}
a.has({key: 'c'}) // false
Remove an item
a = a.remove({key: 'b'});
Take an item
let [{value}, newA] = a.take({key: 'c'});
TODO
More APIs
More documentation
Tests
Contributing
PRs welcome
README.md
Write in the org file. Export to markdown.