File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
src/data-structures/queue Expand file tree Collapse file tree 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 {
55 this . linkedList = new LinkedList ( ) ;
66 }
77
8+ /**
9+ * @return {boolean }
10+ */
811 isEmpty ( ) {
912 return ! this . linkedList . tail ;
1013 }
1114
15+ /**
16+ * @return {* }
17+ */
1218 peek ( ) {
1319 if ( ! this . linkedList . head ) {
1420 return null ;
@@ -17,15 +23,25 @@ export default class Queue {
1723 return this . linkedList . head . value ;
1824 }
1925
26+ /**
27+ * @param {* } value
28+ */
2029 enqueue ( value ) {
2130 this . linkedList . append ( value ) ;
2231 }
2332
33+ /**
34+ * @return {* }
35+ */
2436 dequeue ( ) {
2537 const removedHead = this . linkedList . deleteHead ( ) ;
2638 return removedHead ? removedHead . value : null ;
2739 }
2840
41+ /**
42+ * @param [callback]
43+ * @return {string }
44+ */
2945 toString ( callback ) {
3046 return this . linkedList . toString ( callback ) ;
3147 }
You can’t perform that action at this time.
0 commit comments