class CircularDeque < T > { k : number ; size : number ; data : Array < T > ; constructor ( k ) { this . k = k ; this . size = 0 ; this . data = new Array ( ) ; } public insertFront ( item ) { if ( this . size === this . k ) { return false ; } else { this . size ++ ; this . data . unshift ( item ) ; return true ; } } public insertLast ( item ) { if ( this . size === this . k ) { return false ; } else { this . size ++ ; this . data . push ( item ) ; return true ; } } public deleteFront ( ) { if ( this . size === 0 ) { return false ; } else { this . size -- ; this . data . shift ( ) ; return true ; } } public deleteLast ( ) { if ( this . size === 0 ) { return false ; } else { this . size -- ; this . data . pop ( ) ; return true ; } } public getFront ( ) { if ( this . size === 0 ) { return - 1 ; } else { return this . data [ 0 ] ; } } public getRear ( ) { if ( this . size === 0 ) { return - 1 ; } else { return this . data [ this . size - 1 ] ; } } public isEmpty ( ) { return this . size === 0 ? true : false ; } public isFull ( ) { return this . size === this . k ? true : false ; } } export default CircularDeque ;