/** * Returns the greatest value present in {@code array}, treating values as unsigned. * * @param array a <i>nonempty</i> array of unsigned {@code int} values * @return the value present in {@code array} that is greater than or equal to every other value * in the array according to {@link #compare} * @throws IllegalArgumentException if {@code array} is empty */ public static int max(int... array) { checkArgument(array.length > 0); int max = flip(array[0]); for (int i = 1; i < array.length; i++) { int next = flip(array[i]); if (next > max) { max = next; } } return flip(max); }
/** * Returns the least value present in {@code array}, treating values as unsigned. * * @param array a <i>nonempty</i> array of unsigned {@code int} values * @return the value present in {@code array} that is less than or equal to every other value in * the array according to {@link #compare} * @throws IllegalArgumentException if {@code array} is empty */ public static int min(int... array) { checkArgument(array.length > 0); int min = flip(array[0]); for (int i = 1; i < array.length; i++) { int next = flip(array[i]); if (next < min) { min = next; } } return flip(min); }
/** * Compares the two specified {@code int} values, treating them as unsigned values between {@code * 0} and {@code 2^32 - 1} inclusive. * * <p><b>Java 8 users:</b> use {@link Integer#compareUnsigned(int, int)} instead. * * @param a the first unsigned {@code int} to compare * @param b the second unsigned {@code int} to compare * @return a negative value if {@code a} is less than {@code b}; a positive value if {@code a} is * greater than {@code b}; or zero if they are equal */ public static int compare(int a, int b) { return Ints.compare(flip(a), flip(b)); }
/** * Sorts the array between {@code fromIndex} inclusive and {@code toIndex} exclusive, treating its * elements as unsigned 32-bit integers. * * @since 23.1 */ public static void sort(int[] array, int fromIndex, int toIndex) { checkNotNull(array); checkPositionIndexes(fromIndex, toIndex, array.length); for (int i = fromIndex; i < toIndex; i++) { array[i] = flip(array[i]); } Arrays.sort(array, fromIndex, toIndex); for (int i = fromIndex; i < toIndex; i++) { array[i] = flip(array[i]); } }
/** * Returns the least value present in {@code array}, treating values as unsigned. * * @param array a <i>nonempty</i> array of unsigned {@code int} values * @return the value present in {@code array} that is less than or equal to every other value in * the array according to {@link #compare} * @throws IllegalArgumentException if {@code array} is empty */ public static int min(int... array) { checkArgument(array.length > 0); int min = flip(array[0]); for (int i = 1; i < array.length; i++) { int next = flip(array[i]); if (next < min) { min = next; } } return flip(min); }
/** * Returns the greatest value present in {@code array}, treating values as unsigned. * * @param array a <i>nonempty</i> array of unsigned {@code int} values * @return the value present in {@code array} that is greater than or equal to every other value * in the array according to {@link #compare} * @throws IllegalArgumentException if {@code array} is empty */ public static int max(int... array) { checkArgument(array.length > 0); int max = flip(array[0]); for (int i = 1; i < array.length; i++) { int next = flip(array[i]); if (next > max) { max = next; } } return flip(max); }
/** * Compares the two specified {@code int} values, treating them as unsigned values between {@code * 0} and {@code 2^32 - 1} inclusive. * * <p><b>Java 8 users:</b> use {@link Integer#compareUnsigned(int, int)} instead. * * @param a the first unsigned {@code int} to compare * @param b the second unsigned {@code int} to compare * @return a negative value if {@code a} is less than {@code b}; a positive value if {@code a} is * greater than {@code b}; or zero if they are equal */ public static int compare(int a, int b) { return Ints.compare(flip(a), flip(b)); }
/** * Returns the least value present in {@code array}, treating values as unsigned. * * @param array a <i>nonempty</i> array of unsigned {@code int} values * @return the value present in {@code array} that is less than or equal to every other value in * the array according to {@link #compare} * @throws IllegalArgumentException if {@code array} is empty */ public static int min(int... array) { checkArgument(array.length > 0); int min = flip(array[0]); for (int i = 1; i < array.length; i++) { int next = flip(array[i]); if (next < min) { min = next; } } return flip(min); }
/** * Returns the greatest value present in {@code array}, treating values as unsigned. * * @param array a <i>nonempty</i> array of unsigned {@code int} values * @return the value present in {@code array} that is greater than or equal to every other value * in the array according to {@link #compare} * @throws IllegalArgumentException if {@code array} is empty */ public static int max(int... array) { checkArgument(array.length > 0); int max = flip(array[0]); for (int i = 1; i < array.length; i++) { int next = flip(array[i]); if (next > max) { max = next; } } return flip(max); }
/** * Compares the two specified {@code int} values, treating them as unsigned values between {@code * 0} and {@code 2^32 - 1} inclusive. * * <p><b>Java 8 users:</b> use {@link Integer#compareUnsigned(int, int)} instead. * * @param a the first unsigned {@code int} to compare * @param b the second unsigned {@code int} to compare * @return a negative value if {@code a} is less than {@code b}; a positive value if {@code a} is * greater than {@code b}; or zero if they are equal */ public static int compare(int a, int b) { return Ints.compare(flip(a), flip(b)); }
/** * Sorts the array between {@code fromIndex} inclusive and {@code toIndex} exclusive, treating its * elements as unsigned 32-bit integers. * * @since 23.1 */ public static void sort(int[] array, int fromIndex, int toIndex) { checkNotNull(array); checkPositionIndexes(fromIndex, toIndex, array.length); for (int i = fromIndex; i < toIndex; i++) { array[i] = flip(array[i]); } Arrays.sort(array, fromIndex, toIndex); for (int i = fromIndex; i < toIndex; i++) { array[i] = flip(array[i]); } }
/** * Sorts the array between {@code fromIndex} inclusive and {@code toIndex} exclusive, treating its * elements as unsigned 32-bit integers. * * @since 23.1 */ public static void sort(int[] array, int fromIndex, int toIndex) { checkNotNull(array); checkPositionIndexes(fromIndex, toIndex, array.length); for (int i = fromIndex; i < toIndex; i++) { array[i] = flip(array[i]); } Arrays.sort(array, fromIndex, toIndex); for (int i = fromIndex; i < toIndex; i++) { array[i] = flip(array[i]); } }
/** * Compares the two specified {@code int} values, treating them as unsigned values between * {@code 0} and {@code 2^32 - 1} inclusive. * * @param a the first unsigned {@code int} to compare * @param b the second unsigned {@code int} to compare * @return a negative value if {@code a} is less than {@code b}; a positive value if {@code a} is * greater than {@code b}; or zero if they are equal */ public static int compare(int a, int b) { return Ints.compare(flip(a), flip(b)); }
/** * Compares the two specified {@code int} values, treating them as unsigned values between * {@code 0} and {@code 2^32 - 1} inclusive. * * @param a the first unsigned {@code int} to compare * @param b the second unsigned {@code int} to compare * @return a negative value if {@code a} is less than {@code b}; a positive value if {@code a} is * greater than {@code b}; or zero if they are equal */ public static int compare(int a, int b) { return Ints.compare(flip(a), flip(b)); }
/** * Compares the two specified {@code int} values, treating them as unsigned values between * {@code 0} and {@code 2^32 - 1} inclusive. * * @param a the first unsigned {@code int} to compare * @param b the second unsigned {@code int} to compare * @return a negative value if {@code a} is less than {@code b}; a positive value if {@code a} is * greater than {@code b}; or zero if they are equal */ public static int compare(int a, int b) { return Ints.compare(flip(a), flip(b)); }
/** * Compares the two specified {@code int} values, treating them as unsigned values between * {@code 0} and {@code 2^32 - 1} inclusive. * * @param a the first unsigned {@code int} to compare * @param b the second unsigned {@code int} to compare * @return a negative value if {@code a} is less than {@code b}; a positive value if {@code a} is * greater than {@code b}; or zero if they are equal */ public static int compare(int a, int b) { return Ints.compare(flip(a), flip(b)); }
/** * Compares the two specified {@code int} values, treating them as unsigned values between * {@code 0} and {@code 2^32 - 1} inclusive. * * @param a the first unsigned {@code int} to compare * @param b the second unsigned {@code int} to compare * @return a negative value if {@code a} is less than {@code b}; a positive value if {@code a} is * greater than {@code b}; or zero if they are equal */ public static int compare(int a, int b) { return Ints.compare(flip(a), flip(b)); }
/** * Compares the two specified {@code int} values, treating them as unsigned values between * {@code 0} and {@code 2^32 - 1} inclusive. * * @param a the first unsigned {@code int} to compare * @param b the second unsigned {@code int} to compare * @return a negative value if {@code a} is less than {@code b}; a positive value if {@code a} is * greater than {@code b}; or zero if they are equal */ public static int compare(int a, int b) { return Ints.compare(flip(a), flip(b)); }
/** * Compares the two specified {@code int} values, treating them as unsigned values between * {@code 0} and {@code 2^32 - 1} inclusive. * * @param a the first unsigned {@code int} to compare * @param b the second unsigned {@code int} to compare * @return a negative value if {@code a} is less than {@code b}; a positive value if {@code a} is * greater than {@code b}; or zero if they are equal */ public static int compare(int a, int b) { return Ints.compare(flip(a), flip(b)); }
/** * Compares the two specified {@code int} values, treating them as unsigned values between * {@code 0} and {@code 2^32 - 1} inclusive. * * @param a the first unsigned {@code int} to compare * @param b the second unsigned {@code int} to compare * @return a negative value if {@code a} is less than {@code b}; a positive value if {@code a} is * greater than {@code b}; or zero if they are equal */ @CheckReturnValue public static int compare(int a, int b) { return Ints.compare(flip(a), flip(b)); }