Skip to content

Instantly share code, notes, and snippets.

@anotheremily
Created March 12, 2010 21:31
Show Gist options
  • Save anotheremily/330815 to your computer and use it in GitHub Desktop.
Save anotheremily/330815 to your computer and use it in GitHub Desktop.
function Queue() {
this.reset();
}
Queue.prototype.dequeue = function () {
if (this.empty() !== true) {
this.length -= 1;
return this.items.shift();
}
return undefined;
};
Queue.prototype.enqueue = function (item) {
this.items.push(item);
this.length += 1;
return true;
};
Queue.prototype.empty = Stack.prototype.empty;
Queue.prototype.reset = Stack.prototype.reset;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment