lastBuffer[size & r] = i; size += 1;
if (this.size + long_array.length< ((lastBufferIndex+1)<<exp)){ System.arraycopy(long_array, 0, lastBuffer, size & r, long_array.length); } else { int offset = pageSize -(size&r);  System.arraycopy(long_array, 0, lastBuffer, size & r, offset);  int l = long_array.length - offset; int k = (l)>> exp; int z; for (z=1;z<=k;z++){ System.arraycopy(long_array,offset,(long[]) bufferArrayList.get(lastBufferIndex+z), 0, pageSize); offset += pageSize; }  System.arraycopy(long_array,offset,(long[]) bufferArrayList.get(lastBufferIndex+z), 0, l & r); } size += long_array.length; return;
public void append(long i) {   long[] lastBuffer;    if (bufferArrayList.size() == 0) {        lastBuffer = new long[pageSize];        bufferArrayList.add(lastBuffer);        capacity = pageSize;    } else {        lastBuffer = (long[]) bufferArrayList.get(bufferArrayList.size() - 1);    }    if (this.size  < 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 % pageSize] = i;        lastBuffer[size & r] = i;        size += 1;    } else // new buffers needed        {        long[] newBuffer = new long[pageSize];        size++;        capacity += pageSize;        bufferArrayList.add(newBuffer);        newBuffer[0] = i;    }}