protected static int[] insert(int[] old,int oldSize,int pos,int x){
  int[] result;
  if (old != null && old.length > oldSize) {
    result=old;
  }
 else {
    result=new int[oldSize + 1 + COPY_THRESHOLD];
    if (pos > 0 && old != null) {
      System.arraycopy(old,0,result,0,pos);
    }
  }
  if (old != null && oldSize - pos > 0) {
    System.arraycopy(old,pos,result,pos + 1,oldSize - pos);
  }
  result[pos]=x;
  return result;
}

protected static int [ ] insert ( int [ ] old , int oldSize , int pos , int x ) { int [ ] result ; if ( old != null && old . length > oldSize ) { result = old ; } else { result = new int [ oldSize + 1 + COPY_THRESHOLD ] ; if ( pos > 0 && old != null ) { System . arraycopy ( old , 0 , result , 0 , pos ) ; } } if ( old != null && oldSize - pos > 0 ) { System . arraycopy ( old , pos , result , pos + 1 , oldSize - pos ) ; } result [ pos ] = x ; return result ; }
insert a value in an array . a new array is created if required .
