8033148: Lexicographic comparators for arrays

Reviewed-by: jrose, chegar, bchristi, mduigou
This commit is contained in:
Paul Sandoz 2015-11-04 16:44:38 +01:00
parent 01355aa18c
commit b6f45b1889
4 changed files with 4823 additions and 11 deletions

View File

@ -462,6 +462,22 @@ public final class Byte extends Number implements Comparable<Byte> {
return x - y;
}
/**
* Compares two {@code byte} values numerically treating the values
* as unsigned.
*
* @param x the first {@code byte} to compare
* @param y the second {@code byte} to compare
* @return the value {@code 0} if {@code x == y}; a value less
* than {@code 0} if {@code x < y} as unsigned values; and
* a value greater than {@code 0} if {@code x > y} as
* unsigned values
* @since 9
*/
public static int compareUnsigned(byte x, byte y) {
return Byte.toUnsignedInt(x) - Byte.toUnsignedInt(y);
}
/**
* Converts the argument to an {@code int} by an unsigned
* conversion. In an unsigned conversion to an {@code int}, the

View File

@ -467,6 +467,22 @@ public final class Short extends Number implements Comparable<Short> {
return x - y;
}
/**
* Compares two {@code short} values numerically treating the values
* as unsigned.
*
* @param x the first {@code short} to compare
* @param y the second {@code short} to compare
* @return the value {@code 0} if {@code x == y}; a value less
* than {@code 0} if {@code x < y} as unsigned values; and
* a value greater than {@code 0} if {@code x > y} as
* unsigned values
* @since 9
*/
public static int compareUnsigned(short x, short y) {
return Short.toUnsignedInt(x) - Short.toUnsignedInt(y);
}
/**
* The number of bits used to represent a {@code short} value in two's
* complement binary form.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff