Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save psiborg/8433724 to your computer and use it in GitHub Desktop.
Save psiborg/8433724 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