Created
June 12, 2018 06:58
-
-
Save 197291/e7a7bf20fd5fbcb160ff1a968ebf215c to your computer and use it in GitHub Desktop.
Queue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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