public int compareTo(ShortBuffer otherBuffer){
  int compareRemaining=(remaining() < otherBuffer.remaining()) ? remaining() : otherBuffer.remaining();
  int thisPos=position;
  int otherPos=otherBuffer.position;
  short thisByte, otherByte;
  while (compareRemaining > 0) {
    thisByte=get(thisPos);
    otherByte=otherBuffer.get(otherPos);
    if (thisByte != otherByte) {
      return thisByte < otherByte ? -1 : 1;
    }
    thisPos++;
    otherPos++;
    compareRemaining--;
  }
  return remaining() - otherBuffer.remaining();
}

public int compareTo ( ShortBuffer otherBuffer ) { int compareRemaining = ( remaining ( ) < otherBuffer . remaining ( ) ) ? remaining ( ) : otherBuffer . remaining ( ) ; int thisPos = position ; int otherPos = otherBuffer . position ; short thisByte , otherByte ; while ( compareRemaining > 0 ) { thisByte = get ( thisPos ) ; otherByte = otherBuffer . get ( otherPos ) ; if ( thisByte != otherByte ) { return thisByte < otherByte ? - 1 : 1 ; } thisPos ++ ; otherPos ++ ; compareRemaining -- ; } return remaining ( ) - otherBuffer . remaining ( ) ; }
compare the remaining shorts of this buffer to another short buffer ' s remaining shorts .
