Last active
September 7, 2018 15:25
-
-
Save frentsel/6b8db1eb739e2855c315200663311407 to your computer and use it in GitHub Desktop.
Data structure - Queue (javascript)
This file contains 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() { | |
var collection = []; | |
this.dequeue = () => collection.shift(); | |
this.enqueue = (el) => collection.push(el); | |
this.peek = () => collection[0]; | |
this.size = () => collection.length; | |
this.get = () => collection.slice(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment