Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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');
.add('AVL', () => {
const tree = new AVLTree();
for (let i = 0; i < N; i++) tree.insert(rvalues[i]);
})
.run();