public void extendTo(long newMax){
  if (newMax < mCurrentLength) {
    throw new IllegalArgumentException("" + newMax + " is less than current length of: "+ mCurrentLength);
  }
  while (mTotalSize < newMax) {
    final long i=mTotalSize >>> mBits;
    if (i >= mData.length) {
      final long newSize=(mData.length + 1) * 2;
      if (newSize > Integer.MAX_VALUE) {
        throw new RuntimeException("Attempting to allocate too large a chunk array. newSize=" + newSize);
      }
      mData=Arrays.copyOf(mData,(int)newSize);
    }
    final int ii=(int)i;
    if (mData[ii] == null) {
      mData[ii]=new byte[mChunkSize];
      mTotalSize+=mChunkSize;
    }
 else {
      final byte[] newSubArray=new byte[mChunkSize];
      final byte[] arr=mData[ii];
      final int lenArr=arr.length;
      System.arraycopy(arr,0,newSubArray,0,lenArr);
      mTotalSize+=mChunkSize - lenArr;
      mData[ii]=newSubArray;
    }
  }
  mCurrentLength=newMax;
}

public void extendTo ( long newMax ) { if ( newMax < mCurrentLength ) { throw new IllegalArgumentException ( "" + newMax + " is less than current length of: " + mCurrentLength ) ; } while ( mTotalSize < newMax ) { final long i = mTotalSize > > > mBits ; if ( i >= mData . length ) { final long newSize = ( mData . length + 1 ) * 2 ; if ( newSize > Integer . MAX_VALUE ) { throw new RuntimeException ( "Attempting to allocate too large a chunk array. newSize=" + newSize ) ; } mData = Arrays . copyOf ( mData , ( int ) newSize ) ; } final int ii = ( int ) i ; if ( mData [ ii ] == null ) { mData [ ii ] = new byte [ mChunkSize ] ; mTotalSize += mChunkSize ; } else { final byte [ ] newSubArray = new byte [ mChunkSize ] ; final byte [ ] arr = mData [ ii ] ; final int lenArr = arr . length ; System . arraycopy ( arr , 0 , newSubArray , 0 , lenArr ) ; mTotalSize += mChunkSize - lenArr ; mData [ ii ] = newSubArray ; } } mCurrentLength = newMax ; }
ensure there is enough space to store at least given number of entries . internally there may be room for more .
