int[] newBuffer = new int[pageSize]; size++; capacity += pageSize; bufferArrayList.add(newBuffer); newBuffer[0] = i;
int n = ((int_array.length + size) >> exp) + (((int_array.length + size) &r) > 0 ? 1 : 0) -  (capacity >> exp);     System.arraycopy(int_array, 0, lastBuffer, size& r, capacity - size);  for (int i = 0; i < n; i++) { int[] newBuffer = new int[pageSize]; if (i < n - 1) {  System.arraycopy( int_array, pageSize * i + capacity - size, newBuffer, 0, pageSize); } else {  System.arraycopy( int_array, pageSize * i + capacity - size, newBuffer, 0, int_array.length + this.size - capacity - pageSize*i); } bufferArrayList.add(newBuffer); }  size += int_array.length;  capacity += n * pageSize;
public void append(int i) {    int[] lastBuffer;    if (bufferArrayList.size() == 0) {        lastBuffer = new int[pageSize];        bufferArrayList.add(lastBuffer);        capacity = pageSize;    } else {        lastBuffer = (int[]) bufferArrayList.get(bufferArrayList.size() - 1);    }    if ((this.size + 1) <= this.capacity) {        //get the last buffer from the bufferListArray        //obtain the starting offset in that buffer to which the data is to be copied        //update length        //System.arraycopy(long_array, 0, lastBuffer, size % pageSize, long_array.length);        lastBuffer[size & r] = i;//        lastBuffer[size % pageSize] = i;        size += 1;    } else // new buffers needed        {        int[] newBuffer = new int[pageSize];        size++;        capacity += pageSize;        bufferArrayList.add(newBuffer);        newBuffer[0] = i;    }}