@Override public int compare(EncoderState state1, EncoderState state2) { ByteStringBuilder bytes1 = state1.getBuffer(); ByteStringBuilder bytes2 = state2.getBuffer(); ByteIterator bi1 = bytes1.iterate(); ByteIterator bi2 = bytes2.iterate(); // Scan the two encodings from left to right until a difference is found int diff; while (bi1.hasNext() && bi2.hasNext()) { diff = (bi1.next() & 0xff) - (bi2.next() & 0xff); if (diff != 0) { return diff; } } // The longer encoding is considered to be the bigger-valued encoding return bytes1.length() - bytes2.length(); } }
@Override public int compare(EncoderState state1, EncoderState state2) { ByteStringBuilder bytes1 = state1.getBuffer(); ByteStringBuilder bytes2 = state2.getBuffer(); ByteIterator bi1 = bytes1.iterate(); ByteIterator bi2 = bytes2.iterate(); // Scan the two encodings from left to right until a difference is found int diff; while (bi1.hasNext() && bi2.hasNext()) { diff = (bi1.next() & 0xff) - (bi2.next() & 0xff); if (diff != 0) { return diff; } } // The longer encoding is considered to be the bigger-valued encoding return bytes1.length() - bytes2.length(); } }
@Override public int compare(EncoderState state1, EncoderState state2) { ByteStringBuilder bytes1 = state1.getBuffer(); ByteStringBuilder bytes2 = state2.getBuffer(); ByteIterator bi1 = bytes1.iterate(); ByteIterator bi2 = bytes2.iterate(); // Scan the two encodings from left to right until a difference is found int diff; while (bi1.hasNext() && bi2.hasNext()) { diff = (bi1.next() & 0xff) - (bi2.next() & 0xff); if (diff != 0) { return diff; } } // The longer encoding is considered to be the bigger-valued encoding return bytes1.length() - bytes2.length(); } }
@Override public int compare(EncoderState state1, EncoderState state2) { ByteStringBuilder bytes1 = state1.getBuffer(); ByteStringBuilder bytes2 = state2.getBuffer(); ByteIterator bi1 = bytes1.iterate(); ByteIterator bi2 = bytes2.iterate(); // Scan the two encodings from left to right until a difference is found int diff; while (bi1.hasNext() && bi2.hasNext()) { diff = (bi1.next() & 0xff) - (bi2.next() & 0xff); if (diff != 0) { return diff; } } // The longer encoding is considered to be the bigger-valued encoding return bytes1.length() - bytes2.length(); } }