Add annotations to Queue.

This commit is contained in:
Oleksii Trekhleb 2018-08-17 17:47:29 +03:00
parent 260f24b2cb
commit 5eea37837f

View File

@ -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);
}