algojs-collections
v0.5.0
Published
Fundamental data structures in Javascript.
Downloads
6
Readme
algojs-collections
Fundamental data structures in Javascript.
API docs
API docs published here.
List
An highly optimized immutable linked list which grows by prepending elements.
var algojs = require('algojs-collections');
var list1 = new algojs.List();
var list3 = new algojs.List('is', 'nice');
// prepend an element
var list4 = list3.cons('bike');
var list2 = list1.cons('a').cons('Riding');
// prepend a prefix list
var list5 = list4.concat(list2);
var println = function(elem) { console.log(elem); };
list5.foreach(println);
Stack
A mutable stack which grows like a linked list
var algojs = require('algojs-collections');
var stack = new algojs.Stack();
stack.push('hello');
stack.push('folks');
var folks = stack.pop();