/** * Compares this unsigned integer to another unsigned integer. Returns {@code 0} if they are * equal, a negative number if {@code this < other}, and a positive number if {@code this > * other}. */ @Override public int compareTo(UnsignedInteger other) { checkNotNull(other); return compare(value, other.value); }
@Override public int compare(int[] left, int[] right) { int minLength = Math.min(left.length, right.length); for (int i = 0; i < minLength; i++) { if (left[i] != right[i]) { return UnsignedInts.compare(left[i], right[i]); } } return left.length - right.length; }
@Override public int compare(int[] left, int[] right) { int minLength = Math.min(left.length, right.length); for (int i = 0; i < minLength; i++) { if (left[i] != right[i]) { return UnsignedInts.compare(left[i], right[i]); } } return left.length - right.length; }
/** * Compares this unsigned integer to another unsigned integer. Returns {@code 0} if they are * equal, a negative number if {@code this < other}, and a positive number if {@code this > * other}. */ @Override public int compareTo(UnsignedInteger other) { checkNotNull(other); return compare(value, other.value); }
@Override public int compare(int[] left, int[] right) { int minLength = Math.min(left.length, right.length); for (int i = 0; i < minLength; i++) { if (left[i] != right[i]) { return UnsignedInts.compare(left[i], right[i]); } } return left.length - right.length; }
/** * Compares this unsigned integer to another unsigned integer. Returns {@code 0} if they are * equal, a negative number if {@code this < other}, and a positive number if {@code this > * other}. */ @Override public int compareTo(UnsignedInteger other) { checkNotNull(other); return compare(value, other.value); }
public void testCompare() { for (long a : UNSIGNED_INTS) { for (long b : UNSIGNED_INTS) { int cmpAsLongs = Longs.compare(a, b); int cmpAsUInt = UnsignedInts.compare((int) a, (int) b); assertEquals(Integer.signum(cmpAsLongs), Integer.signum(cmpAsUInt)); } } }
/** * Compares this unsigned integer to another unsigned integer. * Returns {@code 0} if they are equal, a negative number if {@code this < other}, * and a positive number if {@code this > other}. */ @Override public int compareTo(UnsignedInteger other) { checkNotNull(other); return compare(value, other.value); }
@Override public int compare(int[] left, int[] right) { int minLength = Math.min(left.length, right.length); for (int i = 0; i < minLength; i++) { if (left[i] != right[i]) { return UnsignedInts.compare(left[i], right[i]); } } return left.length - right.length; } }
@Override public int compare(int[] left, int[] right) { int minLength = Math.min(left.length, right.length); for (int i = 0; i < minLength; i++) { if (left[i] != right[i]) { return UnsignedInts.compare(left[i], right[i]); } } return left.length - right.length; } }
/** * Compares this unsigned integer to another unsigned integer. Returns {@code 0} if they are * equal, a negative number if {@code this < other}, and a positive number if {@code this > * other}. */ @Override public int compareTo(UnsignedInteger other) { checkNotNull(other); return compare(value, other.value); }
/** * Compares this unsigned integer to another unsigned integer. * Returns {@code 0} if they are equal, a negative number if {@code this < other}, * and a positive number if {@code this > other}. */ @Override public int compareTo(UnsignedInteger other) { checkNotNull(other); return compare(value, other.value); }
@Override public int compare(int[] left, int[] right) { int minLength = Math.min(left.length, right.length); for (int i = 0; i < minLength; i++) { if (left[i] != right[i]) { return UnsignedInts.compare(left[i], right[i]); } } return left.length - right.length; } }
/** * Compares this unsigned integer to another unsigned integer. * Returns {@code 0} if they are equal, a negative number if {@code this < other}, * and a positive number if {@code this > other}. */ @Override public int compareTo(UnsignedInteger other) { checkNotNull(other); return compare(value, other.value); }
/** * Compares this unsigned integer to another unsigned integer. * Returns {@code 0} if they are equal, a negative number if {@code this < other}, * and a positive number if {@code this > other}. */ @Override public int compareTo(UnsignedInteger other) { checkNotNull(other); return compare(value, other.value); }
@Override public int compare(int[] left, int[] right) { int minLength = Math.min(left.length, right.length); for (int i = 0; i < minLength; i++) { if (left[i] != right[i]) { return UnsignedInts.compare(left[i], right[i]); } } return left.length - right.length; }
@Override public int compare(int[] left, int[] right) { int minLength = Math.min(left.length, right.length); for (int i = 0; i < minLength; i++) { if (left[i] != right[i]) { return UnsignedInts.compare(left[i], right[i]); } } return left.length - right.length; } }
@Override public int compare(int[] left, int[] right) { int minLength = Math.min(left.length, right.length); for (int i = 0; i < minLength; i++) { if (left[i] != right[i]) { return UnsignedInts.compare(left[i], right[i]); } } return left.length - right.length; } }
/** * Compares this unsigned integer to another unsigned integer. Returns {@code 0} if they are * equal, a negative number if {@code this < other}, and a positive number if {@code this > * other}. */ @Override public int compareTo(UnsignedInteger other) { checkNotNull(other); return compare(value, other.value); }
public void testCompare() { for (long a : UNSIGNED_INTS) { for (long b : UNSIGNED_INTS) { int cmpAsLongs = Longs.compare(a, b); int cmpAsUInt = UnsignedInts.compare((int) a, (int) b); assertEquals(Integer.signum(cmpAsLongs), Integer.signum(cmpAsUInt)); } } }