File tree 1 file changed +16
-0
lines changed
src/data-structures/queue
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -5,10 +5,16 @@ export default class Queue {
5
5
this . linkedList = new LinkedList ( ) ;
6
6
}
7
7
8
+ /**
9
+ * @return {boolean }
10
+ */
8
11
isEmpty ( ) {
9
12
return ! this . linkedList . tail ;
10
13
}
11
14
15
+ /**
16
+ * @return {* }
17
+ */
12
18
peek ( ) {
13
19
if ( ! this . linkedList . head ) {
14
20
return null ;
@@ -17,15 +23,25 @@ export default class Queue {
17
23
return this . linkedList . head . value ;
18
24
}
19
25
26
+ /**
27
+ * @param {* } value
28
+ */
20
29
enqueue ( value ) {
21
30
this . linkedList . append ( value ) ;
22
31
}
23
32
33
+ /**
34
+ * @return {* }
35
+ */
24
36
dequeue ( ) {
25
37
const removedHead = this . linkedList . deleteHead ( ) ;
26
38
return removedHead ? removedHead . value : null ;
27
39
}
28
40
41
+ /**
42
+ * @param [callback]
43
+ * @return {string }
44
+ */
29
45
toString ( callback ) {
30
46
return this . linkedList . toString ( callback ) ;
31
47
}
You can’t perform that action at this time.
0 commit comments