Java Code Examples for com.google.common.primitives.Longs.compare()

The following are Jave code examples for showing how to use compare() of the com.google.common.primitives.Longs class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ditb   File: CellComparator.java   View Source Code Vote up 6 votes
/**
 * Compare cells.
 * TODO: Replace with dynamic rather than static comparator so can change comparator
 * implementation.
 * @param a
 * @param b
 * @param ignoreSequenceid True if we are to compare the key portion only and ignore
 * the sequenceid. Set to false to compare key and consider sequenceid.
 * @return 0 if equal, -1 if a < b, and +1 if a > b.
 */
public static int compare(final Cell a, final Cell b, boolean ignoreSequenceid) {
  // row
  int c = compareRows(a, b);
  if (c != 0) return c;

  c = compareWithoutRow(a, b);
  if(c != 0) return c;

  if (!ignoreSequenceid) {
    // Negate following comparisons so later edits show up first
    // mvccVersion: later sorts first
    return Longs.compare(b.getMvccVersion(), a.getMvccVersion());
  } else {
    return c;
  }
}
 
Example 2
Project: GitHub   File: TimeInstant.java   View Source Code Vote up 4 votes
@Override
public int compareTo(TimeInstant that) {
  return Longs.compare(value, that.value);
}
 
Example 3
Project: guava-mock   File: TestingExecutors.java   View Source Code Vote up 4 votes
@Override public int compareTo(Delayed other) {
  return Longs.compare(getDelay(TimeUnit.NANOSECONDS), other.getDelay(TimeUnit.NANOSECONDS));
}
 
Example 4
Project: creacoinj   File: ExponentialBackoff.java   View Source Code Vote up 4 votes
@Override
public int compareTo(ExponentialBackoff other) {
    // note that in this implementation compareTo() is not consistent with equals()
    return Longs.compare(retryTime, other.retryTime);
}
 
Example 5
Project: creacoinj   File: AbstractCoin.java   View Source Code Vote up 4 votes
@Override
public int compareTo(AbstractCoin other) {
    if (!this.currencyCode.equals(other.currencyCode))
        return this.currencyCode.compareTo(other.currencyCode);
    return Longs.compare(this.value, other.value);
}
 
Example 6
Project: okwallet   File: ExponentialBackoff.java   View Source Code Vote up 4 votes
@Override
public int compareTo(ExponentialBackoff other) {
    // note that in this implementation compareTo() is not consistent with equals()
    return Longs.compare(retryTime, other.retryTime);
}
 
Example 7
Project: okwallet   File: Fiat.java   View Source Code Vote up 4 votes
@Override
public int compareTo(final Fiat other) {
    if (!this.currencyCode.equals(other.currencyCode))
        return this.currencyCode.compareTo(other.currencyCode);
    return Longs.compare(this.value, other.value);
}
 
Example 8
Project: okwallet   File: Coin.java   View Source Code Vote up 4 votes
@Override
public int compareTo(final Coin other) {
    return Longs.compare(this.value, other.value);
}
 
Example 9
Project: googles-monorepo-demo   File: TestingExecutors.java   View Source Code Vote up 4 votes
@Override public int compareTo(Delayed other) {
  return Longs.compare(getDelay(TimeUnit.NANOSECONDS), other.getDelay(TimeUnit.NANOSECONDS));
}
 
Example 10
Project: andbg   File: BaseLongEncodedValue.java   View Source Code Vote up 4 votes
@Override
public int compareTo(@Nonnull EncodedValue o) {
    int res = Ints.compare(getValueType(), o.getValueType());
    if (res != 0) return res;
    return Longs.compare(getValue(), ((LongEncodedValue)o).getValue());
}
 
Example 11
Project: bitcoinj-thin   File: Coin.java   View Source Code Vote up 4 votes
@Override
public int compareTo(final Coin other) {
    return Longs.compare(this.value, other.value);
}