Skip to content

Instantly share code, notes, and snippets.

@giovanisleite
Created July 25, 2021 20:52
Show Gist options
  • Save giovanisleite/48ea9cace3f7da22a4485337ae429817 to your computer and use it in GitHub Desktop.
Save giovanisleite/48ea9cace3f7da22a4485337ae429817 to your computer and use it in GitHub Desktop.
Data Structure: Queue
class Queue {
constructor() {
this.queue = []
}
get length() {
return this.queue.length;
}
enqueue(el) {
this.queue.push(el)
}
dequeue() {
return this.queue.shift()
}
peek() {
return this.queue[0]
}
isEmpty() {
return this.length === 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment