Skip to content

ceejbot/skiplist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A skiplist implementation in javascript

Because I wanted to understand skip lists.

npm Tests Coverage Status Dependencies

var assert = require('assert');
var Skiplist = require('skiplist');

var list = new Skiplist();
list.insert('cat', 'Cats are the best animal.');
list.insert('dog', 'Dogs are obviously inferior.');
list.insert('coati', 'Coatis have long tails.');

var value = list.match('cat');
assert(value === 'Cats are the best animal.');

var result = list.find('co');
assert(result.length === 2);
assert(result[0][0] === 'coati');
assert(result[1][0] === 'dog');

var wasRemoved = list.remove('dog');
assert(list.length() === 2);

See also

The Wikipedia entry on skip lists.

A Python implementation. Another one.

About

a skiplist implementation in javascript

Resources

Stars

Watchers

Forks

Packages

No packages published