8033148: Lexicographic comparators for arrays
Reviewed-by: jrose, chegar, bchristi, mduigou
This commit is contained in:
parent
01355aa18c
commit
b6f45b1889
@ -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
|
||||
|
@ -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
1083
jdk/test/java/util/Arrays/ArraysEqCmpTest.java
Normal file
1083
jdk/test/java/util/Arrays/ArraysEqCmpTest.java
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user