System.arraycopy(long_array,0,(int[]) bufferArrayList.get(lastBufferIndex+z), 0, pageSize);
System.arraycopy(long_array,offset,(long[]) bufferArrayList.get(lastBufferIndex+z), 0, pageSize); offset += pageSize;
public void append(long[] long_array) {  if (long_array == null) {        throw new NullPointerException();    }    // no additional buffer space needed    int lastBufferIndex;    long[] lastBuffer;    if (bufferArrayList.size() == 0) {        lastBuffer = new long[pageSize];        bufferArrayList.add(lastBuffer);        lastBufferIndex = 0;        capacity = pageSize;    } else {        lastBufferIndex = Math.min((size>>exp),//+(((size&r)==0)? 0:1),                 bufferArrayList.size() - 1);        lastBuffer = (long[]) bufferArrayList.get(lastBufferIndex);    }    if ((this.size + long_array.length) < 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        if (this.size + long_array.length< ((lastBufferIndex+1)<<exp)){            System.arraycopy(long_array, 0, lastBuffer, size & r, long_array.length);        }        else {            // copy the first part            System.arraycopy(long_array, 0, lastBuffer, size & r, pageSize-(size &r));            // copy the middle part            int l = long_array.length - (pageSize - (size&r));            int k = (l)>> exp;            int z;            for (z=1;z<=k;z++){                System.arraycopy(long_array,0,(int[]) bufferArrayList.get(lastBufferIndex+z), 0, pageSize);            }            // copy the last part            System.arraycopy(long_array,0,(int[]) bufferArrayList.get(lastBufferIndex+z), 0, l & r);        }        size += long_array.length;        return;    } else // new buffers needed        {        // compute the number of additional buffers needed//        int n =//            ((int) ((long_array.length + size) / pageSize))//                + (((long_array.length + size) % pageSize) > 0 ? 1 : 0)//                - (int) (capacity / pageSize);    	int n =    		    ((long_array.length + size) >> exp)                + (((long_array.length + size)&r) > 0 ? 1 : 0)                -  (capacity >> exp);        // create these buffers        // add to bufferArrayList        //System.arraycopy(long_array, 0, lastBuffer, size % pageSize, capacity - size);        System.arraycopy(long_array, 0, lastBuffer, size & r, capacity - size);        for (int i = 0; i < n; i++) {            long[] newBuffer = new long[pageSize];            if (i < n - 1) {                // full copy                 System.arraycopy(                    long_array,                    pageSize * i + capacity - size,                    newBuffer,                    0,                    pageSize);            } else {                // last page                System.arraycopy(                    long_array,                    pageSize * i + capacity - size,                    newBuffer,                    0,                    long_array.length+ size - pageSize*i - capacity);            }            bufferArrayList.add(newBuffer);        }        // update length        size += long_array.length;        // update capacity        capacity += n * pageSize;        // update    }}