lastBuffer = (int[]) bufferArrayList.get(bufferArrayList.size() - 1);
lastBufferIndex = Math.min((size>>exp), bufferArrayList.size() - 1); lastBuffer = (int[]) bufferArrayList.get(lastBufferIndex);
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;    }}