0.0.0 • Published 10 years ago
linked-list.js v0.0.0
linked-list.js
linked-list.js is an implementation of the linked list data structure in JavaScript.
Linked lists are useful in several circumstances because they allow for the addition or removal of nodes at both ends of the list without having to reallocate the other nodes in the list.
Testing
$ karma start
Usage
Create a linked list
Create a new LinkedList
object:
var ll = new LinkedList();
.push
Adds item to the tail of the list:
ll.push(123);
// 123
.shift
Adds item to the head of the list:
ll.shift(456);
// 456
.pop
Removes item from the tail of the list:
ll.pop();
// 123
.unshift
Removes item from the head of the list:
ll.unshift();
// 456
0.0.0
10 years ago