File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -109,21 +109,31 @@ class BFltArrayQueue {
109109 if ( isFull ( ) ) {
110110 throw new Error ( 'Enqueue attempted on a full queue.' ) ;
111111 } else {
112- this . rear = ( this . rear + 1 ) % queue . length ;
113- queue [ this . rear ] = data ;
112+ this . rear = ( this . rear + 1 ) % this . queue . length ;
113+ this . queue [ this . rear ] = data ;
114114 this . length ++ ;
115115 }
116116 }
117117
118118 dequeue ( ) {
119119 if ( isEmpty ( ) ) {
120120 throw new Error ( 'Dequeue attempted on empty queue.' ) ;
121+ } else {
122+ const toReturn = this . queue [ this . front ] ;
123+ this . queue [ this . front ] = null ;
124+ this . front = ( this . front + 1 ) % this . queue . length ;
125+ this . length -- ;
126+ return toReturn ;
121127 }
122128 }
123129
124- peek ( ) { }
130+ peek ( ) {
131+ return this . queue [ this . front ] ;
132+ }
125133
126- length ( ) { }
134+ length ( ) {
135+ return this . length ;
136+ }
127137}
128138
129139/**
You can’t perform that action at this time.
0 commit comments