public void add(long time) { // May need to store a new time offset int n = offsets.length; if (n == 0 || time - offsets[n - 1] > Integer.MAX_VALUE) { // Grow offset and indices arrays and store new offset offsets = Arrays.copyOf(offsets, n + 1); offsets[n] = time; indices = Arrays.copyOf(indices, n + 1); indices[n] = size; } // May need to extend the array size if (rtimes.length == size) { rtimes = (int[]) extendArray(rtimes); } // Store the time rtimes[size] = (int) (time - offsets[offsets.length - 1]); size++; }