Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

A JavaScript implementation of the [AVL tree](http://www.growingwiththeweb.com/data-structures/avl-tree/overview/) data structure.

Note that the primary purpose of this library is education, but it should work in a production environment as well. It's certainly not as performant as it could be as it optimises for readability, abstraction and safety over raw performance.
For a typescript version, please check out [https://github.com/gwtw/ts-avl-tree](https://github.com/gwtw/ts-avl-tree).

![](http://www.growingwiththeweb.com/images/data-structures/avl-tree/avl-tree.svg)

## Features
Expand All @@ -22,7 +25,7 @@ npm install --save @tyriar/avl-tree

```javascript
// Import npm module
var AvlTree = require('@tyriar/avl-tree');
var AvlTree = require('@tyriar/avl-tree').AvlTree;
Comment on lines 27 to +28
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This uses ts-avl-tree, it would be best to rewrite install and this to something like:

Install

git clone https://github.com/gwtw/js-avl-tree

Usage

// Import npm module
var AvlTree = require('./js-avl-tree/src/avl-tree');

Then moving the ts-avl-tree note into the install section


// Construct AvlTree
var tree = new AvlTree();
Expand All @@ -33,7 +36,7 @@ tree.insert(2);
tree.insert(3);
tree.insert(4);
tree.insert(5);
console.log('size: ' + tree.size());
console.log('size: ' + tree.size);
console.log('contains 2: ' + tree.contains(2));
console.log('contains 7: ' + tree.contains(7));
// > size: 5
Expand All @@ -42,7 +45,7 @@ console.log('contains 7: ' + tree.contains(7));

// Delete a key
tree.delete(2);
console.log('size: ' + tree.size());
console.log('size: ' + tree.size);
console.log('contains 2: ' + tree.contains(2));
// > size: 4
// > contains 2: false
Expand Down