Quick singly-linked list.
var qslist = require('qslist');
var q = new qslist.SList();
q.push(1);
var x = q.shift();
// => 1
q = new qslist.SList();
Add the item to the end of the list. The item may be any data type. Also aliased
as enqueue
and append
. Note that undefined
may be stored as an item, but can
also be returned from an empty list by peek
or shift
; use isEmpty
to distinguish.
Remove and return the first item at the front of the list. Returns undefined
if
the list is empty. Also aliased as dequeue
.
Add the item to the front of the list. Also aliased as prepend
.
Test whether the list contains no items.
Return the item at the front of the list, but without removing it. Returns undefined if the list is empty.
The length
property is set to the number of items on the list.
Do not modify this field.
var qslist = require('qslist');
Qslist internally is a function library that operates on an external linked list.
Factory that returns an empty linked list with with fields head, tail and length.
Append the object to the end of the list. The object's _next
property will be
used for linkage.
Remove and return the first object at the front of the list. The _next
field of
the object is not cleared, and may contain unspecified data.
Prepend the object to the front of the list.
Test whether the list contains no objects.
Return the first object at the front of the list, but without removing the object.
- rename head/tail/length to _head/_tail/_length to piggy-back better