protected void expandFor(int index,double d){
  if (index < size)   return;
  int oldSize=size, capacity=vector.length;
  size=index + 1;
  if (capacity >= size)   return;
  while (capacity < size)   capacity*=2;
  double[] t=new double[capacity];
  System.arraycopy(vector,0,t,0,oldSize);
  if (d != 0)   Arrays.fill(t,oldSize,size,d);
  vector=t;
}

protected void expandFor ( int index , double d ) { if ( index < size ) return ; int oldSize = size , capacity = vector . length ; size = index + 1 ; if ( capacity >= size ) return ; while ( capacity < size ) capacity *= 2 ; double [ ] t = new double [ capacity ] ; System . arraycopy ( vector , 0 , t , 0 , oldSize ) ; if ( d != 0 ) Arrays . fill ( t , oldSize , size , d ) ; vector = t ; }
makes sure the capacity and size of the vector can accomodate the given index . the capacity of the vector is simply doubled until it can accomodate its size .
