ravl
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

Table of Contents

  1. ravl
    1. Installation
    2. Usage
      1. Create a tree
      2. Use a custom comparator
      3. Insert elements
      4. Test membership, retrieve values
      5. Remove an item
      6. Take an item
    3. TODO
      1. More APIs
      2. More documentation
      3. Tests
    4. Contributing
      1. PRs welcome
      2. README.md

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.

Readme

Keywords

none

Package Sidebar

Install

npm i ravl

Weekly Downloads

0

Version

0.2.0

License

ISC

Unpacked Size

27.4 kB

Total Files

8

Last publish

Collaborators

  • fauxsoup