doubly-linked-list-js
v0.1.8
Published
A DoublyLinkedList JavaScript Universal Module
Downloads
79
Readme
doubly-linked-list-js
A DoublyLinkedList
Javascript Universal Module.
Installation
You may install this package using bower
or npm
:
bower install doubly-linked-list-js --save
npm install doubly-linked-list-js --save
Usage
Node.js
var
DoublyLinkedList = require('doubly-linked-list-js');
var
list = new DoublyLinkedList();
API
forge()
forgeCircular()
add(data)
forEach(iterator, fromData, context)
forEachReverse(iterator, fromData, context)
getAt(index)
getFirst()
getIndexOf(data)
getLast()
getRandom()
getLastIndexOf(data)
getLength()
getNext(data)
getPrevious(data)
isCircular()
isEmpty()
makeCircular()
makeLinear()
removeAt(index)
toArray()
toString()
forge
var
list = DoublyLinkedList.forge();
forgeCircular
var
list = DoublyLinkedList.forgeCircular();
add
list
.add('a')
.add('b')
.add('c');
forEach
var
array = [];
list.forEach(function (data) {
array.push(data);
}, 'b');
console.log(array.toString()); // b,c
list
.makeCircular()
.forEach(function (data) {
array.push(data);
}, 'b');
console.log(array.toString()); // b,c,a
forEachReverse
var
array = [];
list.forEachReverse(function (data) {
array.push(data);
}, 'b');
console.log(array.toString()); // b,a
list
.makeCircular()
.forEachReverse(function (data) {
array.push(data);
}, 'b');
console.log(array.toString()); // b,a,c