From 5eea37837f1e7f7b0160fe2f50c48298555d4465 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Fri, 17 Aug 2018 17:47:29 +0300 Subject: [PATCH] Add annotations to Queue. --- src/data-structures/queue/Queue.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/data-structures/queue/Queue.js b/src/data-structures/queue/Queue.js index 49332400..74cf7095 100644 --- a/src/data-structures/queue/Queue.js +++ b/src/data-structures/queue/Queue.js @@ -5,10 +5,16 @@ export default class Queue { this.linkedList = new LinkedList(); } + /** + * @return {boolean} + */ isEmpty() { return !this.linkedList.tail; } + /** + * @return {*} + */ peek() { if (!this.linkedList.head) { return null; @@ -17,15 +23,25 @@ export default class Queue { return this.linkedList.head.value; } + /** + * @param {*} value + */ enqueue(value) { this.linkedList.append(value); } + /** + * @return {*} + */ dequeue() { const removedHead = this.linkedList.deleteHead(); return removedHead ? removedHead.value : null; } + /** + * @param [callback] + * @return {string} + */ toString(callback) { return this.linkedList.toString(callback); }