Movatterモバイル変換


[0]ホーム

URL:


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

Commit1a62078

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 parent6f27113 commit1a62078

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
exportdefaultclassStack{
44
constructor(){
5-
// We're going to implementQueue based on LinkedList sincethis
6-
// structuresa quite similar. Compare push/pop operations of the Stack
5+
// We're going to implementStack based on LinkedList sincethese
6+
// structuresare quite similar. Compare push/pop operations of the Stack
77
// with append/deleteTail operations of LinkedList.
88
this.linkedList=newLinkedList();
99
}
@@ -12,7 +12,7 @@ export default class Stack {
1212
*@return {boolean}
1313
*/
1414
isEmpty(){
15-
// Thequeue is emptyin caseif its linked listdon't have tail.
15+
// Thestack is empty if its linked listdoesn'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+
// Ifthelinked list is empty then there is nothing to peek from.
2525
returnnull;
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+
//thenew 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 nodefrom linked list(the tail).
46-
// If there is no tailin 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
constremovedTail=this.linkedList.deleteTail();
4848
returnremovedTail ?removedTail.value :null;
4949
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp