How to use avl - 2 common examples

To help you get started, we’ve selected a few avl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github w8r / splay-tree / bench / benchmark.js View on Github external
if (!map[v]) {
      map[v] = true;
      res.push(v);
      i++;
    }
  }
  return res;
}

const N = 1000;
const rvalues = generateRValues(N);
const values = new Array(N).fill(0).map((n, i) => i);

const comparator = (a, b) => a - b;

const prefilledAVL = new AVLTree();
rvalues.forEach((v) => prefilledAVL.insert(v));

const prefilledRB = new RBTree(comparator);
rvalues.forEach((v) => prefilledRB.insert(v));

const prefilledSplay = new Splay(comparator);
rvalues.forEach((v) => prefilledSplay.insert(v));

const options = {
  onStart (event) { console.log(this.name); },
  onError (event) { console.log(event.target.error); },
  onCycle (event) {
    console.log(' -', String(event.target), `mean ${(event.target.stats.mean * 1000).toFixed(3)}ms`);
  },
  onComplete() {
    console.log('- Fastest is ' + this.filter('fastest').map('name') + '\n');
github w8r / splay-tree / bench / benchmark.js View on Github external
.add('AVL', () => {
    const tree = new AVLTree();
    for (let i = 0; i < N; i++) tree.insert(rvalues[i]);
  })
  .run();

avl

Fast AVL tree for Node and browser

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Popular avl functions