Improve JSDocs in Stack.js (#203)

The functions' comments were copied from Queue.js, but some words were not replaced.
I also made some changes to the wording for clarification.
This commit is contained in:
Vinicius 2018-09-08 16:35:24 -03:00 committed by Oleksii Trekhleb
parent 6f27113993
commit 1a62078f26

View File

@ -2,8 +2,8 @@ import LinkedList from '../linked-list/LinkedList';
export default class Stack {
constructor() {
// We're going to implement Queue based on LinkedList since this
// structures a quite similar. Compare push/pop operations of the Stack
// We're going to implement Stack based on LinkedList since these
// structures are quite similar. Compare push/pop operations of the Stack
// with append/deleteTail operations of LinkedList.
this.linkedList = new LinkedList();
}
@ -12,7 +12,7 @@ export default class Stack {
* @return {boolean}
*/
isEmpty() {
// The queue is empty in case if its linked list don't have tail.
// The stack is empty if its linked list doesn't have a tail.
return !this.linkedList.tail;
}
@ -21,7 +21,7 @@ export default class Stack {
*/
peek() {
if (this.isEmpty()) {
// If linked list is empty then there is nothing to peek from.
// If the linked list is empty then there is nothing to peek from.
return null;
}
@ -34,7 +34,7 @@ export default class Stack {
*/
push(value) {
// Pushing means to lay the value on top of the stack. Therefore let's just add
// new value at the end of the linked list.
// the new value at the end of the linked list.
this.linkedList.append(value);
}
@ -42,8 +42,8 @@ export default class Stack {
* @return {*}
*/
pop() {
// Let's try to delete the last node from linked list (the tail).
// If there is no tail in linked list (it is empty) just return null.
// Let's try to delete the last node (the tail) from the linked list.
// If there is no tail (the linked list is empty) just return null.
const removedTail = this.linkedList.deleteTail();
return removedTail ? removedTail.value : null;
}