Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Queue {
- constructor() {
- this._start = 0;
- this._end = 0;
- this._storage = {};
- }
- enqueue(value) {
- this._storage[this._end] = value;
- this._end ++;
- }
- dequeue() {
- if (this._size()) {
- var dequeued = this._storage[this._start];
- delete this._storage[this._start];
- this._start ++;
- return dequeued;
- }
- return 'The Queue is empty';
- }
- _size() {
- return this._end - this._start;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement