java.lang.Short.compare()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中java.lang.Short.compare()方法的一些代码示例,展示了Short.compare()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Short.compare()方法的具体详情如下:
包路径:java.lang.Short
类名称:Short
方法名:compare

Short.compare介绍

[英]Compares two short values.
[中]比较两个短值。

代码示例

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * Appends to the <code>builder</code> the comparison of
 * two <code>short</code>s.
 *
 * @param lhs  left-hand value
 * @param rhs  right-hand value
 * @return this - used to chain append calls
 */
public CompareToBuilder append(final short lhs, final short rhs) {
  if (comparison != 0) {
    return this;
  }
  comparison = Short.compare(lhs, rhs);
  return this;
}

代码示例来源:origin: jtablesaw/tablesaw

@Override
public int compare(Short o1, Short o2) {
  return Short.compare(o1, o2);
}

代码示例来源:origin: apache/flink

@Override
public int compareTo(ValueArray<ShortValue> o) {
  ShortValueArray other = (ShortValueArray) o;
  int min = Math.min(position, other.position);
  for (int i = 0; i < min; i++) {
    int cmp = Short.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 short object to determine their
 * relative order.
 *
 * @param object
 *            the short object to compare this object to.
 * @return a negative value if the value of this short is less than the
 *         value of {@code object}; 0 if the value of this short and the
 *         value of {@code object} are equal; a positive value if the value
 *         of this short is greater than the value of {@code object}.
 * @throws NullPointerException
 *             if {@code object} is null.
 * @see java.lang.Comparable
 * @since 1.2
 */
public int compareTo(Short object) {
  return compare(value, object.value);
}

代码示例来源:origin: neo4j/neo4j

/**
 * Compare arrays byte by byte, first byte is most significant.
 * If arrays have different length and the longer array share all bytes with the shorter array, then the longer one is larger,
 * unless ignoreLength is set to true in which case they are considered equal.
 */
static int lexicographicalUnsignedByteArrayCompare( byte[] a, int aLength, byte[] b, int bLength, boolean ignoreLength )
{
  assert a != null && b != null : "Null arrays not supported.";
  if ( a == b && aLength == bLength )
  {
    return 0;
  }
  int length = Math.min( aLength, bLength );
  for ( int i = 0; i < length; i++ )
  {
    int compare = Short.compare( (short) (a[i] & 0xFF), (short) (b[i] & 0xFF) );
    if ( compare != 0 )
    {
      return compare;
    }
  }
  return ignoreLength ? 0 : Integer.compare( aLength, bLength );
}

代码示例来源:origin: prestodb/presto

@Override
public int compareTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition)
{
  // WARNING: the correctness of InCodeGenerator is dependent on the implementation of this
  // function being the equivalence of internal long representation.
  short leftValue = leftBlock.getShort(leftPosition, 0);
  short rightValue = rightBlock.getShort(rightPosition, 0);
  return Short.compare(leftValue, rightValue);
}

代码示例来源:origin: prestodb/presto

@Override
public int compareTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition)
{
  // WARNING: the correctness of InCodeGenerator is dependent on the implementation of this
  // function being the equivalence of internal long representation.
  short leftValue = leftBlock.getShort(leftPosition, 0);
  short rightValue = rightBlock.getShort(rightPosition, 0);
  return Short.compare(leftValue, rightValue);
}

代码示例来源:origin: speedment/speedment

@Override
default int compare(T first, T second) {
  return Short.compare(
    applyAsShort(first),
    applyAsShort(second)
  );
}

代码示例来源: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) {
    short firstValue = firstSource.readShort();
    short secondValue = secondSource.readShort();
    int cmp = Short.compare(firstValue, secondValue);
    if (cmp != 0) {
      return ascendingComparison ? cmp : -cmp;
    }
  }
  int cmp = Integer.compare(firstCount, secondCount);
  return ascendingComparison ? cmp : -cmp;
}

代码示例来源:origin: org.apache.poi/poi

@Override
  public int compare(EscherProperty p1, EscherProperty p2) {
    short s1 = p1.getPropertyNumber();
    short s2 = p2.getPropertyNumber();
    return Short.compare(s1, s2);
  }
});

代码示例来源:origin: prestodb/presto

@Override
  public int compare(TimeZoneKey left, TimeZoneKey right)
  {
    return Short.compare(left.getKey(), right.getKey());
  }
}, TimeZoneKey.getTimeZoneKeys());

代码示例来源:origin: speedment/speedment

@Override
public int compare(ENTITY first, ENTITY second) {
  requireNonNulls(first, second);
  final short a = field.getAsShort(first);
  final short b = field.getAsShort(second);
  return applyReversed(Short.compare(a, b));
}

代码示例来源:origin: speedment/speedment

@Override
public int compare(T first, T second) {
  final boolean f = isNull(first);
  final boolean s = isNull(second);
  if (f && s) return 0;
  else if (f) return 1;
  else if (s) return -1;
  else return Short.compare(
    original.applyAsShort(first),
    original.applyAsShort(second)
  );
}

代码示例来源:origin: konsoletyper/teavm

@Override
public int compareTo(TShortBuffer 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 = Short.compare(getElement(a++), other.getElement(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 Short.compare(
      applyAsShort(first),
      applyAsShort(second)
    );
  }
}

代码示例来源:origin: it.unimi.dsi/fastutil

@Override
public final int compare(final short a, final short b) {
  return -(Short.compare((a), (b)));
}
private Object readResolve() {

代码示例来源:origin: it.unimi.dsi/fastutil

@Override
public final int compare(final short a, final short b) {
  return (Short.compare((a), (b)));
}
private Object readResolve() {

代码示例来源:origin: it.unimi.dsi/fastutil

private static int med3(final short x[], final int a, final int b, final int c) {
  final int ab = (Short.compare((x[a]), (x[b])));
  final int ac = (Short.compare((x[a]), (x[c])));
  final int bc = (Short.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

private static int med3Indirect(final int perm[], final short x[], final int a, final int b, final int c) {
  final short aa = x[perm[a]];
  final short bb = x[perm[b]];
  final short cc = x[perm[c]];
  final int ab = (Short.compare((aa), (bb)));
  final int ac = (Short.compare((aa), (cc)));
  final int bc = (Short.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 long med3(final short x[][], final long a, final long b, final long c) {
  int ab = (Short.compare((get(x, a)), (get(x, b))));
  int ac = (Short.compare((get(x, a)), (get(x, c))));
  int bc = (Short.compare((get(x, b)), (get(x, c))));
  return (ab < 0 ? (bc < 0 ? b : ac < 0 ? c : a) : (bc > 0 ? b : ac > 0 ? c : a));
}

相关文章