本文整理了Java中java.lang.Character.compare()
方法的一些代码示例,展示了Character.compare()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Character.compare()
方法的具体详情如下:
包路径:java.lang.Character
类名称:Character
方法名:compare
[英]Compares two char values.
[中]比较两个字符值。
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* 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;
}
代码示例来源:origin: JetBrains/ideavim
public int compare(V o1, V o2) {
Register a = (Register)o1;
Register b = (Register)o2;
return Character.compare(a.name, b.name);
}
}
代码示例来源:origin: apache/flink
@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);
}
代码示例来源:origin: robovm/robovm
/**
* 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);
}
代码示例来源:origin: neo4j/neo4j
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;
}
代码示例来源:origin: speedment/speedment
@Override
default int compare(T first, T second) {
final char f = applyAsChar(first);
final char s = applyAsChar(second);
return Character.compare(f, s);
}
代码示例来源:origin: konsoletyper/teavm
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;
}
}
代码示例来源:origin: apache/flink
@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;
}
代码示例来源:origin: spotify/helios
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;
}
代码示例来源:origin: apache/flink
@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;
}
代码示例来源:origin: speedment/speedment
@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));
}
代码示例来源:origin: konsoletyper/teavm
@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());
}
代码示例来源:origin: speedment/speedment
@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)
);
}
}
代码示例来源:origin: it.unimi.dsi/fastutil
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));
}
代码示例来源:origin: it.unimi.dsi/fastutil
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) {
代码示例来源:origin: it.unimi.dsi/fastutil
@Override
public final int compare(final char a, final char b) {
return (Character.compare((a), (b)));
}
private Object readResolve() {
代码示例来源:origin: it.unimi.dsi/fastutil
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));
}
代码示例来源:origin: it.unimi.dsi/fastutil
@Override
public final int compare(final char a, final char b) {
return -(Character.compare((a), (b)));
}
private Object readResolve() {
代码示例来源:origin: org.apache.flink/flink-gelly_2.11
@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);
}
代码示例来源:origin: it.unimi.dsi/fastutil
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));
}
内容来源于网络,如有侵权,请联系作者删除!