Skip to content

Instantly share code, notes, and snippets.

@197291
Created June 12, 2018 06:58
Show Gist options
  • Save 197291/e7a7bf20fd5fbcb160ff1a968ebf215c to your computer and use it in GitHub Desktop.
Save 197291/e7a7bf20fd5fbcb160ff1a968ebf215c to your computer and use it in GitHub Desktop.
Queue
function Queue () {
collection = [];
this.print = function() {
console.log(collection);
};
this.enqueue = function(element) {
collection.push(element);
};
this.dequeue = function() {
return collection.shift();
};
this.front = function() {
return collection[0];
};
this.size = function() {
return collection.length;
};
this.isEmpty = function() {
return (collection.length === 0);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment