public T pop() {
        if (isEmpty()) {
            throw new RuntimeException("Ring buffer underflow");
        }
        T item = buffer[indexOut];
        buffer[indexOut] = null;                  // to help with garbage collection
        count--;
        indexOut = (indexOut + 1) % buffer.length; // wrap-around
        return item;
    }
Ring buffer (fixed size queue) implementation using a circular array (array
with wrap-around).
jme3-android/src/main/java/com/jme3/util/RingBuffer.java