Sample 1. Bitwise comparison of objects , compareTo Implementation
public int compareTo(Object other) {
Buffer right = ((Buffer) other);
byte[] lb = this.get();
byte[] rb = right.get();
for (int i = 0; i < count && i < right.count; i++) {
int a = (lb[i] & 0xff);
int b = (rb[i] & 0xff);
if (a != b) {
return a - b;
}
}
return count - right.count;
}