mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8033148: Lexicographic comparators for arrays
Reviewed-by: jrose, chegar, bchristi, mduigou
This commit is contained in:
parent
01355aa18c
commit
b6f45b1889
4 changed files with 4823 additions and 11 deletions
|
@ -462,6 +462,22 @@ public final class Byte extends Number implements Comparable<Byte> {
|
||||||
return x - y;
|
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
|
* Converts the argument to an {@code int} by an unsigned
|
||||||
* conversion. In an unsigned conversion to an {@code int}, the
|
* 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;
|
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
|
* The number of bits used to represent a {@code short} value in two's
|
||||||
* complement binary form.
|
* 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…
Add table
Add a link
Reference in a new issue