int compare ( byte [ ] b1 , int offset1 , byte [ ] b2 , int offset2 , int length ) { int r ; for ( int i = 0 ; i < length ; i ++ ) { // Unsigned comparison mimics bitwise comparison. r = ( b1 [ offset1 + i ] & 0xFF ) - ( b2 [ offset2 + i ] & 0xFF ) ; if ( r != 0 ) { return r ; } } return 0 ; }
Compares two byte arrays from the given offsets using lexicographic bitwise comparison .