/** * Appends to the <code>builder</code> the comparison of * two <code>char</code>s. * * @param lhs left-hand value * @param rhs right-hand value * @return this - used to chain append calls */ public CompareToBuilder append(final char lhs, final char rhs) { if (comparison != 0) { return this; } comparison = Character.compare(lhs, rhs); return this; }
public int compare(V o1, V o2) { Register a = (Register)o1; Register b = (Register)o2; return Character.compare(a.name, b.name); } }
@Override public int compareTo(ValueArray<CharValue> o) { CharValueArray other = (CharValueArray) o; int min = Math.min(position, other.position); for (int i = 0; i < min; i++) { int cmp = Character.compare(data[i], other.data[i]); if (cmp != 0) { return cmp; } } return Integer.compare(position, other.position); }
/** * Compares this object to the specified character object to determine their * relative order. * * @param c * the character object to compare this object to. * @return {@code 0} if the value of this character and the value of * {@code c} are equal; a positive value if the value of this * character is greater than the value of {@code c}; a negative * value if the value of this character is less than the value of * {@code c}. * @see java.lang.Comparable * @since 1.2 */ public int compareTo(Character c) { return compare(value, c.value); }
public static int compareCharToString( char c, String s ) { int length = s.length(); int x = length == 0 ? 1 : 0; if ( x == 0 ) { x = Character.compare( c, s.charAt( 0 ) ); if ( x == 0 && length > 1 ) { x = -1; } } return x; }
@Override default int compare(T first, T second) { final char f = applyAsChar(first); final char s = applyAsChar(second); return Character.compare(f, s); }
TrieNode build(TrieNodeBuilder builder) { TrieNode node = new TrieNode(); if (builder == null) { return node; } node.tz = builder.tz; List<TrieNodeBuilder> builders = new ArrayList<>(); TrieNodeBuilder tmp = builder; while (tmp.ch != '\0') { builders.add(tmp); tmp = tmp.sibling; } Collections.sort(builders, (o1, o2) -> Character.compare(o1.ch, o2.ch)); node.chars = new char[builders.size()]; node.childNodes = new TrieNode[builders.size()]; for (int i = 0; i < node.chars.length; ++i) { node.chars[i] = builders.get(i).ch; node.childNodes[i] = build(builders.get(i).next); } return node; } }
@Override public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException { int firstCount = firstSource.readInt(); int secondCount = secondSource.readInt(); int minCount = Math.min(firstCount, secondCount); while (minCount-- > 0) { char firstValue = firstSource.readChar(); char secondValue = secondSource.readChar(); int cmp = Character.compare(firstValue, secondValue); if (cmp != 0) { return ascendingComparison ? cmp : -cmp; } } int cmp = Integer.compare(firstCount, secondCount); return ascendingComparison ? cmp : -cmp; }
private int compareNumerically(final CharBuffer b1, final CharBuffer b2) { final int diff = b1.length() - b2.length(); if (diff != 0) { return diff; } for (int i = 0; i < b1.remaining() && i < b2.remaining(); ++i) { final int result = Character.compare(b1.charAt(i), b2.charAt(i)); if (result != 0) { return result; } } return 0; }
@Override public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException { int firstCount = firstSource.readInt(); int secondCount = secondSource.readInt(); int minCount = Math.min(firstCount, secondCount); while (minCount-- > 0) { int firstLength = readStringLength(firstSource); int secondLength = readStringLength(secondSource); int minLength = Math.min(firstLength, secondLength); while (minLength-- > 0) { char firstChar = readStringChar(firstSource); char secondChar = readStringChar(secondSource); int cmp = Character.compare(firstChar, secondChar); if (cmp != 0) { return ascendingComparison ? cmp : -cmp; } } int cmp = Integer.compare(firstLength, secondLength); if (cmp != 0) { return ascendingComparison ? cmp : -cmp; } } int cmp = Integer.compare(firstCount, secondCount); return ascendingComparison ? cmp : -cmp; }
@Override public int compare(ENTITY first, ENTITY second) { requireNonNulls(first, second); final char a = field.getAsChar(first); final char b = field.getAsChar(second); return applyReversed(Character.compare(a, b)); }
@Override public int compareTo(TCharBuffer other) { if (this == other) { return 0; } int sz = Math.min(remaining(), other.remaining()); int a = position; int b = other.position; for (int i = 0; i < sz; ++i) { int r = Character.compare(getChar(a++), other.getChar(b++)); if (r != 0) { return r; } } return Integer.compare(remaining(), other.remaining()); }
@Override default int compare(T first, T second) { if (isNull(first)) { return isNull(second) ? 0 : 1; } else if (isNull(second)) { return -1; } else { return Character.compare( applyAsChar(first), applyAsChar(second) ); } }
private static int med3Indirect(final int perm[], final char x[], final int a, final int b, final int c) { final char aa = x[perm[a]]; final char bb = x[perm[b]]; final char cc = x[perm[c]]; final int ab = (Character.compare((aa), (bb))); final int ac = (Character.compare((aa), (cc))); final int bc = (Character.compare((bb), (cc))); return (ab < 0 ? (bc < 0 ? b : ac < 0 ? c : a) : (bc > 0 ? b : ac > 0 ? c : a)); }
private static int med3(final char x[], final char[] y, final int a, final int b, final int c) { int t; final int ab = (t = (Character.compare((x[a]), (x[b])))) == 0 ? (Character.compare((y[a]), (y[b]))) : t; final int ac = (t = (Character.compare((x[a]), (x[c])))) == 0 ? (Character.compare((y[a]), (y[c]))) : t; final int bc = (t = (Character.compare((x[b]), (x[c])))) == 0 ? (Character.compare((y[b]), (y[c]))) : t; return (ab < 0 ? (bc < 0 ? b : ac < 0 ? c : a) : (bc > 0 ? b : ac > 0 ? c : a)); } private static void swap(final char x[], final char[] y, final int a, final int b) {
@Override public final int compare(final char a, final char b) { return (Character.compare((a), (b))); } private Object readResolve() {
private static int med3(final char x[], final int a, final int b, final int c) { final int ab = (Character.compare((x[a]), (x[b]))); final int ac = (Character.compare((x[a]), (x[c]))); final int bc = (Character.compare((x[b]), (x[c]))); return (ab < 0 ? (bc < 0 ? b : ac < 0 ? c : a) : (bc > 0 ? b : ac > 0 ? c : a)); }
@Override public final int compare(final char a, final char b) { return -(Character.compare((a), (b))); } private Object readResolve() {
@Override public int compareTo(ValueArray<CharValue> o) { CharValueArray other = (CharValueArray) o; int min = Math.min(position, other.position); for (int i = 0; i < min; i++) { int cmp = Character.compare(data[i], other.data[i]); if (cmp != 0) { return cmp; } } return Integer.compare(position, other.position); }
private static long med3(final char x[][], final long a, final long b, final long c) { int ab = (Character.compare((get(x, a)), (get(x, b)))); int ac = (Character.compare((get(x, a)), (get(x, c)))); int bc = (Character.compare((get(x, b)), (get(x, c)))); return (ab < 0 ? (bc < 0 ? b : ac < 0 ? c : a) : (bc > 0 ? b : ac > 0 ? c : a)); }