Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1a62078

Browse files
vilanztrekhleb
authored andcommitted
Improve JSDocs in Stack.js (trekhleb#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.
1 parent 6f27113 commit 1a62078

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

‎src/data-structures/stack/Stack.js‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import LinkedList from '../linked-list/LinkedList';
22

33
export default class Stack {
44
constructor() {
5-
// We're going to implement Queue based on LinkedList since this
6-
// structures a quite similar. Compare push/pop operations of the Stack
5+
// We're going to implement Stack based on LinkedList since these
6+
// structures are quite similar. Compare push/pop operations of the Stack
77
// with append/deleteTail operations of LinkedList.
88
this.linkedList = new LinkedList();
99
}
@@ -12,7 +12,7 @@ export default class Stack {
1212
* @return {boolean}
1313
*/
1414
isEmpty() {
15-
// The queue is empty in case if its linked list don't have tail.
15+
// The stack is empty if its linked list doesn't have a tail.
1616
return !this.linkedList.tail;
1717
}
1818

@@ -21,7 +21,7 @@ export default class Stack {
2121
*/
2222
peek() {
2323
if (this.isEmpty()) {
24-
// If linked list is empty then there is nothing to peek from.
24+
// If the linked list is empty then there is nothing to peek from.
2525
return null;
2626
}
2727

@@ -34,16 +34,16 @@ export default class Stack {
3434
*/
3535
push(value) {
3636
// Pushing means to lay the value on top of the stack. Therefore let's just add
37-
// new value at the end of the linked list.
37+
// the new value at the end of the linked list.
3838
this.linkedList.append(value);
3939
}
4040

4141
/**
4242
* @return {*}
4343
*/
4444
pop() {
45-
// Let's try to delete the last node from linked list (the tail).
46-
// If there is no tail in linked list (it is empty) just return null.
45+
// Let's try to delete the last node (the tail) from the linked list.
46+
// If there is no tail (the linked list is empty) just return null.
4747
const removedTail = this.linkedList.deleteTail();
4848
return removedTail ? removedTail.value : null;
4949
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /