public final class UnsignedByteBuffer
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static int |
compare(java.nio.ByteBuffer a,
java.nio.ByteBuffer b) |
static java.util.Comparator<java.nio.ByteBuffer> |
lexicographicalComparator()
Returns a comparator that compares two
java.nio.ByteBuffer s
lexicographically. |
public static int compare(java.nio.ByteBuffer a, java.nio.ByteBuffer b)
public static java.util.Comparator<java.nio.ByteBuffer> lexicographicalComparator()
java.nio.ByteBuffer
s
lexicographically. That is, it compares, using
UnsignedBytes.compare(byte, byte)
), the first pair of values that follow any common prefix, or when one array is a
prefix of the other, treats the shorter array as the lesser. For example,
[] < [0x01] < [0x01, 0x7F] < [0x01, 0x80] < [0x02]
. Values are treated as unsigned.
The returned comparator is inconsistent with Object.equals(Object)
(since arrays support only identity
equality), but it is consistent with Arrays.equals(byte[], byte[])
.