private Object[] ensureCapacity(int minCapacity){
  if (tmp.length < minCapacity) {
    int newSize=minCapacity;
    newSize|=newSize >> 1;
    newSize|=newSize >> 2;
    newSize|=newSize >> 4;
    newSize|=newSize >> 8;
    newSize|=newSize >> 16;
    newSize++;
    if (newSize < 0)     newSize=minCapacity;
 else     newSize=Math.min(newSize,a.length >>> 1);
    Object[] newArray=new Object[newSize];
    tmp=newArray;
  }
  return tmp;
}

private Object [ ] ensureCapacity ( int minCapacity ) { if ( tmp . length < minCapacity ) { int newSize = minCapacity ; newSize |= newSize > > 1 ; newSize |= newSize > > 2 ; newSize |= newSize > > 4 ; newSize |= newSize > > 8 ; newSize |= newSize > > 16 ; newSize ++ ; if ( newSize < 0 ) newSize = minCapacity ; else newSize = Math . min ( newSize , a . length > > > 1 ) ; Object [ ] newArray = new Object [ newSize ] ; tmp = newArray ; } return tmp ; }
ensures that the external array tmp has at least the specified number of elements , increasing its size if necessary . the size increases exponentially to ensure amortized linear time complexity .
