private int[] doIntersection(int[] c2){
  int[] result=new int[chars.length + c2.length];
  int i=0;
  int j=0;
  int oldI;
  int oldJ;
  int index=0;
  while (i < chars.length && j < c2.length) {
    if (i < chars.length && i % 2 == 0) {
      while (j < c2.length && c2[j] < chars[i]) {
        ++j;
      }
      if (j < c2.length && j % 2 == 0 && c2[j] == chars[i]) {
        ++j;
      }
    }
    oldI=i;
    while (j % 2 == 1 && i < chars.length && chars[i] <= c2[j]) {
      ++i;
    }
    for (int k=oldI; k < i; k++) {
      result[index++]=chars[k];
    }
    oldJ=j;
    while (i % 2 == 1 && j < c2.length && c2[j] <= chars[i]) {
      ++j;
    }
    for (int k=oldJ; k < j; k++) {
      result[index++]=c2[k];
    }
    if (j < c2.length && j % 2 == 0) {
      while (i < chars.length && chars[i] < c2[j]) {
        ++i;
      }
      if (i < chars.length && i % 2 == 0 && c2[j] == chars[i]) {
        ++i;
      }
    }
  }
  if (result.length > index) {
    int[] tmpbuf=new int[index];
    System.arraycopy(result,0,tmpbuf,0,index);
    return tmpbuf;
  }
  return result;
}

private int [ ] doIntersection ( int [ ] c2 ) { int [ ] result = new int [ chars . length + c2 . length ] ; int i = 0 ; int j = 0 ; int oldI ; int oldJ ; int index = 0 ; while ( i < chars . length && j < c2 . length ) { if ( i < chars . length && i % 2 == 0 ) { while ( j < c2 . length && c2 [ j ] < chars [ i ] ) { ++ j ; } if ( j < c2 . length && j % 2 == 0 && c2 [ j ] == chars [ i ] ) { ++ j ; } } oldI = i ; while ( j % 2 == 1 && i < chars . length && chars [ i ] <= c2 [ j ] ) { ++ i ; } for ( int k = oldI ; k < i ; k ++ ) { result [ index ++ ] = chars [ k ] ; } oldJ = j ; while ( i % 2 == 1 && j < c2 . length && c2 [ j ] <= chars [ i ] ) { ++ j ; } for ( int k = oldJ ; k < j ; k ++ ) { result [ index ++ ] = c2 [ k ] ; } if ( j < c2 . length && j % 2 == 0 ) { while ( i < chars . length && chars [ i ] < c2 [ j ] ) { ++ i ; } if ( i < chars . length && i % 2 == 0 && c2 [ j ] == chars [ i ] ) { ++ i ; } } } if ( result . length > index ) { int [ ] tmpbuf = new int [ index ] ; System . arraycopy ( result , 0 , tmpbuf , 0 , index ) ; return tmpbuf ; } return result ; }
the internal implementation of the two intersection functions
