queue
///funcational classing
var Queue = function() {
var instance = {},
head = 0,
tail = 0;
}
instance.enqueue = function(value) {
storage[tail] = value;
tail += 1;
};
instance.dequeue = function() {
if (tail > start) { ///check if the queue is empty
var result = storage[start];
delete storage[head];
head += 1;
return result;
};
instance.size = function() {
return end - start;
};
This Gist was automatically created by Carbide, a free online programming environment.