@ Override public boolean add ( final E element ) { if ( null == element ) { throw new NullPointerException ( "Attempted to add null object to queue" ) ; } if ( isAtFullCapacity ( ) ) { remove ( ) ; } elements [ end ++ ] = element ; if ( end >= maxElements ) { end = 0 ; } if ( end == start ) { full = true ; } return true ; }
Adds the given element to this queue . If the queue is full the least recently added element is discarded so that a new element can be inserted .