byte primitives that interpret values as
unsigned (that is, any negative value b is treated as the positive value 256 + b). The corresponding methods that treat the values as signed are found in SignedBytes, and the methods for which signedness is not an issue are in Bytes.
See the Guava User Guide article on primitive utilities.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | UnsignedBytes.LexicographicalComparatorHolder
Provides a lexicographical comparator implementation; either a Java implementation or a faster
implementation based on |
| Modifier and Type | Field and Description |
|---|---|
| public static final byte | MAX_POWER_OF_TWO
The largest power of two that can be represented as an unsigned |
| public static final byte | MAX_VALUE
The largest value that fits into an unsigned byte. |
| private static final int |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static byte | Returns: thebyte value that, when treated as unsigned, equals valuea value between 0 and 255 inclusive value)Returns the |
| public static int | Returns: a negative value ifa is less than b; a positive value if a is
greater than b; or zero if they are equalthe first a, byte byte to comparethe second b)byte to compareCompares the two specified |
| private static byte | |
| public static String | |
| public static Comparator | |
| pack-priv static Comparator | |
| public static byte | |
| public static byte | |
| public static byte | parseUnsignedByte(String string)
Returns the unsigned |
| public static byte | parseUnsignedByte(String
the string containing the unsigned string, int byte representation to be parsed.the radix to use while parsing radix)stringReturns the unsigned |
| public static byte | Returns: (byte) 255 if value >= 255, (byte) 0 if value <= 0, and
value cast to byte otherwiseany value)long valueReturns the |
| public static void | |
| public static void | sort(byte[] array, int fromIndex, int toIndex)
Sorts the array between |
| public static void | sortDescending(byte[] array)
Sorts the elements of |
| public static void | sortDescending(byte[] array, int fromIndex, int toIndex)
Sorts the elements of |
| public static int | |
| public static String | |
| public static String | toString(byte
the value to convert to a string. x, int the radix to use while working with radix)xReturns a string representation of |
| MAX_POWER_OF_TWO | back to summary |
|---|---|
| public static final byte MAX_POWER_OF_TWO The largest power of two that can be represented as an unsigned
| |
| MAX_VALUE | back to summary |
|---|---|
| public static final byte MAX_VALUE The largest value that fits into an unsigned byte.
| |
| UNSIGNED_MASK | back to summary |
|---|---|
| private static final int UNSIGNED_MASK | |
| UnsignedBytes | back to summary |
|---|---|
| private UnsignedBytes() | |
| checkedCast | back to summary |
|---|---|
| public static byte checkedCast(long value) Returns the
| |
| compare | back to summary |
|---|---|
| public static int compare(byte a, byte b) Compares the two specified
| |
| flip | back to summary |
|---|---|
| private static byte flip(byte b) | |
| join | back to summary |
|---|---|
| public static String join(String separator, byte... array) Returns a string containing the supplied
| |
| lexicographicalComparator | back to summary |
|---|---|
| public static Comparator Returns a comparator that compares two The returned comparator is inconsistent with
| |
| lexicographicalComparatorJavaImpl | back to summary |
|---|---|
pack-priv static Comparator
| |
| max | back to summary |
|---|---|
| public static byte max(byte... array) Returns the greatest value present in
| |
| min | back to summary |
|---|---|
| public static byte min(byte... array) Returns the least value present in
| |
| parseUnsignedByte | back to summary |
|---|---|
| public static byte parseUnsignedByte(String string) Returns the unsigned
| |
| parseUnsignedByte | back to summary |
|---|---|
| public static byte parseUnsignedByte(String string, int radix) Returns the unsigned
| |
| saturatedCast | back to summary |
|---|---|
| public static byte saturatedCast(long value) Returns the
| |
| sort | back to summary |
|---|---|
| public static void sort(byte[] array) Sorts the array, treating its elements as unsigned bytes.
| |
| sort | back to summary |
|---|---|
| public static void sort(byte[] array, int fromIndex, int toIndex) Sorts the array between
| |
| sortDescending | back to summary |
|---|---|
| public static void sortDescending(byte[] array) Sorts the elements of
| |
| sortDescending | back to summary |
|---|---|
| public static void sortDescending(byte[] array, int fromIndex, int toIndex) Sorts the elements of
| |
| toInt | back to summary |
|---|---|
| public static int toInt(byte value) Returns the value of the given byte as an integer, when treated as unsigned. That is, returns
Java 8 users: use
| |
| toString | back to summary |
|---|---|
| public static String toString(byte x) Returns a string representation of x, where x is treated as unsigned.
| |
| toString | back to summary |
|---|---|
| public static String toString(byte x, int radix) Returns a string representation of
| |
Unsafe.
Uses reflection to gracefully fall back to the Java implementation if Unsafe isn't
available.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static enum | |
| pack-priv static enum |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final Comparator | |
| pack-priv static final String |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv static Comparator | getBestComparator()
Returns the Unsafe-using Comparator, or falls back to the pure-Java implementation if unable to do so. |
| BEST_COMPARATOR | back to summary |
|---|---|
| pack-priv static final Comparator<byte[]> BEST_COMPARATOR | |
| UNSAFE_COMPARATOR_NAME | back to summary |
|---|---|
| pack-priv static final String UNSAFE_COMPARATOR_NAME | |
| LexicographicalComparatorHolder | back to summary |
|---|---|
| pack-priv LexicographicalComparatorHolder() | |
| getBestComparator | back to summary |
|---|---|
| pack-priv static Comparator Returns the Unsafe-using Comparator, or falls back to the pure-Java implementation if unable to do so. | |
| Modifier and Type | Field and Description |
|---|---|
| public static final UnsignedBytes. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public int | compare(byte[]
the first object to be compared. left, byte[] the second object to be compared. right)Implements java. |
| public String | toString()
Overrides java. |
| public static UnsignedBytes. | |
| public static UnsignedBytes. |
| INSTANCE | back to summary |
|---|---|
| public static final UnsignedBytes. | |
| PureJavaComparator | back to summary |
|---|---|
| private PureJavaComparator() | |
| compare | back to summary |
|---|---|
| public int compare(byte[] left, byte[] right) Implements java. Doc from java. Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
The implementor must ensure that
The implementor must also ensure that the relation is transitive:
Finally, the implementor must ensure that
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns the name of this enum constant, as contained in the declaration. This method may be overridden, though it typically isn't necessary or desirable. An enum class should override this method when a more "programmer-friendly" string form exists. | |
| valueOf | back to summary |
|---|---|
| public static UnsignedBytes. | |
| values | back to summary |
|---|---|
| public static UnsignedBytes. | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final boolean | |
| pack-priv static final int | BYTE_ARRAY_BASE_OFFSET
The offset to the first element in a byte array. |
| public static final UnsignedBytes. | |
| pack-priv static final Unsafe |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public int | compare(byte[]
the first object to be compared. left, byte[] the second object to be compared. right)Implements java. |
| private static Unsafe | |
| public String | toString()
Overrides java. |
| public static UnsignedBytes. | |
| public static UnsignedBytes. |
| BIG_ENDIAN | back to summary |
|---|---|
| pack-priv static final boolean BIG_ENDIAN | |
| BYTE_ARRAY_BASE_OFFSET | back to summary |
|---|---|
| pack-priv static final int BYTE_ARRAY_BASE_OFFSET The offset to the first element in a byte array. | |
| INSTANCE | back to summary |
|---|---|
| public static final UnsignedBytes. | |
| theUnsafe | back to summary |
|---|---|
| pack-priv static final Unsafe theUnsafe | |
| UnsafeComparator | back to summary |
|---|---|
| private UnsafeComparator() | |
| compare | back to summary |
|---|---|
| public int compare(byte[] left, byte[] right) Implements java. Doc from java. Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
The implementor must ensure that
The implementor must also ensure that the relation is transitive:
Finally, the implementor must ensure that
| |
| getUnsafe | back to summary |
|---|---|
| private static Unsafe getUnsafe() Returns a sun.misc.Unsafe. Suitable for use in a 3rd party package. Replace with a simple call to Unsafe.getUnsafe when integrating into a jdk.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns the name of this enum constant, as contained in the declaration. This method may be overridden, though it typically isn't necessary or desirable. An enum class should override this method when a more "programmer-friendly" string form exists. | |
| valueOf | back to summary |
|---|---|
| public static UnsignedBytes. | |
| values | back to summary |
|---|---|
| public static UnsignedBytes. | |