dijkstra-backend/helpers/queue.js

21 lines
302 B
JavaScript
Raw Normal View History

2020-02-08 18:59:51 +00:00
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;