@Override public int compare(byte[] left, byte[] right) { int minLength = Math.min(left.length, right.length); for (int i = 0; i < minLength; i++) { int result = UnsignedBytes.compare(left[i], right[i]); if (result != 0) { return result; } } return left.length - right.length; }
@Override public int compare(byte[] left, byte[] right) { int minLength = Math.min(left.length, right.length); for (int i = 0; i < minLength; i++) { int result = UnsignedBytes.compare(left[i], right[i]); if (result != 0) { return result; } } return left.length - right.length; }
@Override public int compare(byte[] left, byte[] right) { int minLength = Math.min(left.length, right.length); for (int i = 0; i < minLength; i++) { int result = UnsignedBytes.compare(left[i], right[i]); if (result != 0) { return result; } } return left.length - right.length; }
int result = UnsignedBytes.compare(left[i], right[i]); if (result != 0) { return result;
public void testMaxValue() { assertTrue( UnsignedBytes.compare(UnsignedBytes.MAX_VALUE, (byte) (UnsignedBytes.MAX_VALUE + 1)) > 0); }
int result = UnsignedBytes.compare(left[i], right[i]); if (result != 0) { return result;
int result = UnsignedBytes.compare(left[i], right[i]); if (result != 0) { return result;
public void testCompare() { // This is the only ordering for primitives that does not have a // corresponding Comparable wrapper in java.lang. for (int i = 0; i < VALUES.length; i++) { for (int j = 0; j < VALUES.length; j++) { byte x = VALUES[i]; byte y = VALUES[j]; // note: spec requires only that the sign is the same assertEquals( x + ", " + y, Math.signum(UnsignedBytes.compare(x, y)), Math.signum(Ints.compare(i, j))); } } }
int result = UnsignedBytes.compare( buffer1[offset1 + i], buffer2[offset2 + i]);
@SuppressWarnings("unchecked") public void testLexicographicalComparatorLongInputs() { Random rnd = new Random(); for (Comparator<byte[]> comparator : Arrays.asList( UnsignedBytes.lexicographicalComparator(), UnsignedBytes.lexicographicalComparatorJavaImpl())) { for (int trials = 10; trials-- > 0; ) { byte[] left = new byte[1 + rnd.nextInt(32)]; rnd.nextBytes(left); byte[] right = left.clone(); assertTrue(comparator.compare(left, right) == 0); int i = rnd.nextInt(left.length); left[i] ^= (byte) (1 + rnd.nextInt(255)); assertTrue(comparator.compare(left, right) != 0); assertEquals( comparator.compare(left, right) > 0, UnsignedBytes.compare(left[i], right[i]) > 0); } } }
int res = UnsignedBytes.compare(buf1[i], GridUnsafe.getByte(ptr2 + i));
@ExpectWarning(value="RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VALUE", num = 9) public static int testGuavaPrimitiveCompareCalls() { int count = 0; if (Booleans.compare(false, true) == -1) count++; if (Chars.compare('a', 'b') == -1) count++; if (Doubles.compare(1, 2) == -1) count++; if (Floats.compare(1, 2) == -1) count++; if (Ints.compare(1, 2) == -1) count++; if (Longs.compare(1, 2) == -1) count++; if (Shorts.compare((short) 1, (short) 2) == -1) count++; if (SignedBytes.compare((byte) 1, (byte) 2) == -1) count++; if (UnsignedBytes.compare((byte) 1, (byte) 2) == -1) count++; return count; }
int result = UnsignedBytes.compare(buffer1[offset1 + i], buffer2[offset2 + i]); if (result != 0) { return result; }
@Override public int compare(Host host1, Host host2) { byte[] address1 = host1.getAddress().getAddress(); byte[] address2 = host2.getAddress().getAddress(); return UnsignedBytes.compare( address1[address1.length - 1], address2[address2.length - 1]); } });
@Override public int compare(byte[] left, byte[] right) { int minLength = Math.min(left.length, right.length); for (int i = 0; i < minLength; i++) { int result = UnsignedBytes.compare(left[i], right[i]); if (result != 0) { return result; } } return left.length - right.length; } }
@Override public int compare(byte[] left, byte[] right) { int minLength = Math.min(left.length, right.length); for (int i = 0; i < minLength; i++) { int result = UnsignedBytes.compare(left[i], right[i]); if (result != 0) { return result; } } return left.length - right.length; } }
@Override public int compare(byte[] left, byte[] right) { int minLength = Math.min(left.length, right.length); for (int i = 0; i < minLength; i++) { int result = UnsignedBytes.compare(left[i], right[i]); if (result != 0) { return result; } } return left.length - right.length; }
@Override public int compare(byte[] left, byte[] right) { int minLength = Math.min(left.length, right.length); for (int i = 0; i < minLength; i++) { int result = UnsignedBytes.compare(left[i], right[i]); if (result != 0) { return result; } } return left.length - right.length; } }
public int compare(byte[] left, byte[] right) { int minLength = Math.min(left.length, right.length); for (int i = 0; i < minLength; i++) { int result = UnsignedBytes.compare(left[i], right[i]); if (result != 0) { return result; } } return left.length - right.length; } }
@Override public int compare(byte[] left, byte[] right) { int minLength = Math.min(left.length, right.length); for (int i = 0; i < minLength; i++) { int result = UnsignedBytes.compare(left[i], right[i]); if (result != 0) { return result; } } return left.length - right.length; } }