21 lines
302 B
JavaScript
21 lines
302 B
JavaScript
class Queue {
|
|
constructor() {
|
|
this.store = [];
|
|
}
|
|
|
|
size() {
|
|
return this.store.length
|
|
}
|
|
|
|
enqueue(node) {
|
|
this.store.push(node);
|
|
}
|
|
|
|
dequeue() {
|
|
if (this.size() > 0) {
|
|
return this.store.shift();
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = Queue; |