Skip to content

Instantly share code, notes, and snippets.

@frentsel
Last active September 7, 2018 15:25
Show Gist options
  • Save frentsel/6b8db1eb739e2855c315200663311407 to your computer and use it in GitHub Desktop.
Save frentsel/6b8db1eb739e2855c315200663311407 to your computer and use it in GitHub Desktop.
Data structure - Queue (javascript)
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