https://github.com/ceejbot/skiplist
a skiplist implementation in javascript
https://github.com/ceejbot/skiplist
Last synced: 9 months ago
JSON representation
a skiplist implementation in javascript
- Host: GitHub
- URL: https://github.com/ceejbot/skiplist
- Owner: ceejbot
- Created: 2013-03-16T03:59:27.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2016-03-01T18:32:28.000Z (over 10 years ago)
- Last Synced: 2024-11-07T19:54:10.572Z (over 1 year ago)
- Language: JavaScript
- Size: 18.6 KB
- Stars: 38
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# A skiplist implementation in javascript
Because I wanted to understand skip lists.
[](https://www.npmjs.org/package/skiplist) [](http://travis-ci.org/ceejbot/skiplist) [](https://coveralls.io/github/ceejbot/skiplist?branch=master) [](https://david-dm.org/ceejbot/skiplist)
##
```javascript
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](https://en.wikipedia.org/wiki/Skip_list).
[A Python implementation](http://infohost.nmt.edu/tcc/help/lang/python/examples/pyskip/web/index.html). [Another one](http://pythonsweetness.tumblr.com/post/45227295342/fast-pypy-compatible-ordered-map-in-89-lines-of-python).