public void push(T item) {
        if (count == buffer.length) {
            throw new RuntimeException("Ring buffer overflow");
        }
        buffer[indexIn] = item;
        indexIn = (indexIn + 1) % buffer.length;     // wrap-around
        count++;
    }
Ring buffer (fixed size queue) implementation using a circular array (array
with wrap-around).
jme3-ios/src/main/java/com/jme3/util/RingBuffer.java