public void push ( long x ) { if ( this . queueSize == this . maxSize ) { assert this . last == this . first ; this . sumOfQueue -= this . elems . get ( this . last ) ; if ( ( ++ this . last ) == this . maxSize ) this . last = 0 ; } else this . queueSize ++ ; this . sumOfQueue += x ; this . elems . set ( this . first , x ) ; if ( ( ++ this . first ) == this . maxSize ) { this . first = 0 ; this . last = 0 ; } }
Pushes a new element to the queue .