diff options
1 files changed, 0 insertions, 51 deletions
| -rw-r--r-- | homework/45180/input.js | 51 |
diff --git a/homework/45180/input.js b/homework/45180/input.js deleted file mode 100644 index 6974019..0000000 --- a/homework/45180/input.js +++ /dev/null @@ -1,51 +0,0 @@ -export default class Queue { - constructor() { - this._firstNode = null; - this._lastNode = null; - } - - dequeue() { - if (!this._firstNode) { - return this._firstNode; - } - - const payload = this._firstNode.payload; - - this._firstNode = this._firstNode.next; - - return payload; - } - - enqueue(item) { - const newNode = { - payload: item, - next: null - }; - - if (this._firstNode === null) { - this._firstNode = newNode; - this._lastNode = newNode; - - } else { - this._lastNode.next = newNode; - this._lastNode = newNode; - } - } - - clear() { - this._firstNode = null; - this._lastNode = null; - } - - top() { - if (!this._firstNode) { - return this._firstNode; - } - - return this._firstNode.payload; - } - - isEmpty() { - return !this._firstNode; - } -} |
