private void mergeHi(int base1,int len1,int base2,int len2){
  T[] a=this.a;
  T[] tmp=ensureCapacity(len2);
  int tmpBase=this.tmpBase;
  System.arraycopy(a,base2,tmp,tmpBase,len2);
  int cursor1=base1 + len1 - 1;
  int cursor2=tmpBase + len2 - 1;
  int dest=base2 + len2 - 1;
  a[dest--]=a[cursor1--];
  if (--len1 == 0) {
    System.arraycopy(tmp,tmpBase,a,dest - (len2 - 1),len2);
    return;
  }
  if (len2 == 1) {
    dest-=len1;
    cursor1-=len1;
    System.arraycopy(a,cursor1 + 1,a,dest + 1,len1);
    a[dest]=tmp[cursor2];
    return;
  }
  Comparator<? super T> c=this.c;
  int minGallop=this.minGallop;
  outer:   while (true) {
    int count1=0;
    int count2=0;
    do {
      if (c.compare(tmp[cursor2],a[cursor1]) < 0) {
        a[dest--]=a[cursor1--];
        count1++;
        count2=0;
        if (--len1 == 0)         break outer;
      }
 else {
        a[dest--]=tmp[cursor2--];
        count2++;
        count1=0;
        if (--len2 == 1)         break outer;
      }
    }
 while ((count1 | count2) < minGallop);
    do {
      count1=len1 - gallopRight(tmp[cursor2],a,base1,len1,len1 - 1,c);
      if (count1 != 0) {
        dest-=count1;
        cursor1-=count1;
        len1-=count1;
        System.arraycopy(a,cursor1 + 1,a,dest + 1,count1);
        if (len1 == 0)         break outer;
      }
      a[dest--]=tmp[cursor2--];
      if (--len2 == 1)       break outer;
      count2=len2 - gallopLeft(a[cursor1],tmp,tmpBase,len2,len2 - 1,c);
      if (count2 != 0) {
        dest-=count2;
        cursor2-=count2;
        len2-=count2;
        System.arraycopy(tmp,cursor2 + 1,a,dest + 1,count2);
        if (len2 <= 1)         break outer;
      }
      a[dest--]=a[cursor1--];
      if (--len1 == 0)       break outer;
      minGallop--;
    }
 while (count1 >= MIN_GALLOP | count2 >= MIN_GALLOP);
    if (minGallop < 0)     minGallop=0;
    minGallop+=2;
  }
  this.minGallop=minGallop < 1 ? 1 : minGallop;
  if (len2 == 1) {
    dest-=len1;
    cursor1-=len1;
    System.arraycopy(a,cursor1 + 1,a,dest + 1,len1);
    a[dest]=tmp[cursor2];
  }
 else   if (len2 == 0) {
    throw new IllegalArgumentException("Comparison method violates its general contract!");
  }
 else {
    System.arraycopy(tmp,tmpBase,a,dest - (len2 - 1),len2);
  }
}

private void mergeHi ( int base1 , int len1 , int base2 , int len2 ) { T [ ] a = this . a ; T [ ] tmp = ensureCapacity ( len2 ) ; int tmpBase = this . tmpBase ; System . arraycopy ( a , base2 , tmp , tmpBase , len2 ) ; int cursor1 = base1 + len1 - 1 ; int cursor2 = tmpBase + len2 - 1 ; int dest = base2 + len2 - 1 ; a [ dest -- ] = a [ cursor1 -- ] ; if ( -- len1 == 0 ) { System . arraycopy ( tmp , tmpBase , a , dest - ( len2 - 1 ) , len2 ) ; return ; } if ( len2 == 1 ) { dest -= len1 ; cursor1 -= len1 ; System . arraycopy ( a , cursor1 + 1 , a , dest + 1 , len1 ) ; a [ dest ] = tmp [ cursor2 ] ; return ; } Comparator < ? super T > c = this . c ; int minGallop = this . minGallop ; outer : while ( true ) { int count1 = 0 ; int count2 = 0 ; do { if ( c . compare ( tmp [ cursor2 ] , a [ cursor1 ] ) < 0 ) { a [ dest -- ] = a [ cursor1 -- ] ; count1 ++ ; count2 = 0 ; if ( -- len1 == 0 ) break outer ; } else { a [ dest -- ] = tmp [ cursor2 -- ] ; count2 ++ ; count1 = 0 ; if ( -- len2 == 1 ) break outer ; } } while ( ( count1 | count2 ) < minGallop ) ; do { count1 = len1 - gallopRight ( tmp [ cursor2 ] , a , base1 , len1 , len1 - 1 , c ) ; if ( count1 != 0 ) { dest -= count1 ; cursor1 -= count1 ; len1 -= count1 ; System . arraycopy ( a , cursor1 + 1 , a , dest + 1 , count1 ) ; if ( len1 == 0 ) break outer ; } a [ dest -- ] = tmp [ cursor2 -- ] ; if ( -- len2 == 1 ) break outer ; count2 = len2 - gallopLeft ( a [ cursor1 ] , tmp , tmpBase , len2 , len2 - 1 , c ) ; if ( count2 != 0 ) { dest -= count2 ; cursor2 -= count2 ; len2 -= count2 ; System . arraycopy ( tmp , cursor2 + 1 , a , dest + 1 , count2 ) ; if ( len2 <= 1 ) break outer ; } a [ dest -- ] = a [ cursor1 -- ] ; if ( -- len1 == 0 ) break outer ; minGallop -- ; } while ( count1 >= MIN_GALLOP | count2 >= MIN_GALLOP ) ; if ( minGallop < 0 ) minGallop = 0 ; minGallop += 2 ; } this . minGallop = minGallop < 1 ? 1 : minGallop ; if ( len2 == 1 ) { dest -= len1 ; cursor1 -= len1 ; System . arraycopy ( a , cursor1 + 1 , a , dest + 1 , len1 ) ; a [ dest ] = tmp [ cursor2 ] ; } else if ( len2 == 0 ) { throw new IllegalArgumentException ( "Comparison method violates its general contract!" ) ; } else { System . arraycopy ( tmp , tmpBase , a , dest - ( len2 - 1 ) , len2 ) ; } }
like mergelo , except that this method should be called only if len1 > = len2 ; mergelo should be called if len1 < = len2 . ( either method may be called if len1 = = len2 . )
