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

The following are Jave code examples for showing how to use compare() of the com.google.common.primitives.Ints class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: andbg   File: CollectionUtils.java   Source Code and License Vote up 5 votes
public static <T extends Comparable<? super T>> int compareAsList(@Nonnull Collection<? extends T> list1,
                                                                  @Nonnull Collection<? extends T> list2) {
    int res = Ints.compare(list1.size(), list2.size());
    if (res != 0) return res;
    Iterator<? extends T> elements2 = list2.iterator();
    for (T element1: list1) {
        res = element1.compareTo(elements2.next());
        if (res != 0) return res;
    }
    return 0;
}
 
Example 2
Project: andbg   File: CollectionUtils.java   Source Code and License Vote up 5 votes
public static <T extends Comparable<T>> int compareAsSet(@Nonnull Collection<? extends T> set1,
                                                         @Nonnull Collection<? extends T> set2) {
    int res = Ints.compare(set1.size(), set2.size());
    if (res != 0) return res;

    SortedSet<? extends T> sortedSet1 = toNaturalSortedSet(set1);
    SortedSet<? extends T> sortedSet2 = toNaturalSortedSet(set2);

    Iterator<? extends T> elements2 = set2.iterator();
    for (T element1: set1) {
        res = element1.compareTo(elements2.next());
        if (res != 0) return res;
    }
    return 0;
}
 
Example 3
Project: andbg   File: BaseAnnotationEncodedValue.java   Source Code and License Vote up 5 votes
@Override
public int compareTo(@Nonnull EncodedValue o) {
    int res = Ints.compare(getValueType(), o.getValueType());
    if (res != 0) return res;
    AnnotationEncodedValue other = (AnnotationEncodedValue)o;
    res = getType().compareTo(other.getType());
    if (res != 0) return res;
    return CollectionUtils.compareAsSet(getElements(), other.getElements());
}
 
Example 4
Project: ditb   File: TestMemStoreLAB.java   Source Code and License Vote up 5 votes
@Override
public int compareTo(AllocRecord e) {
  if (alloc.getBytes() != e.alloc.getBytes()) {
    throw new RuntimeException("Can only compare within a particular array");
  }
  return Ints.compare(alloc.getOffset(), e.alloc.getOffset());
}
 
Example 5
Project: andbg   File: BaseCharEncodedValue.java   Source Code and License Vote up 4 votes
@Override
public int compareTo(@Nonnull EncodedValue o) {
    int res = Ints.compare(getValueType(), o.getValueType());
    if (res != 0) return res;
    return Chars.compare(getValue(), ((CharEncodedValue)o).getValue());
}
 
Example 6
Project: guava-mock   File: ClassSanityTester.java   Source Code and License Vote up 4 votes
@Override public int compare(Invokable<?, ?> left, Invokable<?, ?> right) {
  return Ints.compare(left.getParameters().size(), right.getParameters().size());
}
 
Example 7
Project: guava-mock   File: CollectionBenchmarkSampleData.java   Source Code and License Vote up 4 votes
@Override
public int compareTo(Element that) {
  return Ints.compare(hash, that.hash);
}
 
Example 8
Project: guava-mock   File: OrderingTest.java   Source Code and License Vote up 4 votes
@Override
public int compareTo(Composite<T> that) {
  return Ints.compare(rank, that.rank);
}
 
Example 9
Project: andbg   File: BaseLongEncodedValue.java   Source Code and License 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 10
Project: creacoinj   File: VersionedChecksummedBytes.java   Source Code and License Vote up 4 votes
/**
 * {@inheritDoc}
 *
 * This implementation uses an optimized Google Guava method to compare <code>bytes</code>.
 */
@Override
public int compareTo(VersionedChecksummedBytes o) {
    int result = Ints.compare(this.version, o.version);
    return result != 0 ? result : UnsignedBytes.lexicographicalComparator().compare(this.bytes, o.bytes);
}
 
Example 11
Project: andbg   File: BaseArrayEncodedValue.java   Source Code and License Vote up 4 votes
@Override public int compareTo(@Nonnull EncodedValue o) {
    int res = Ints.compare(getValueType(), o.getValueType());
    if (res != 0) return res;
    return CollectionUtils.compareAsList(getValue(), ((ArrayEncodedValue)o).getValue());
}
 
Example 12
Project: andbg   File: BaseFieldEncodedValue.java   Source Code and License Vote up 4 votes
@Override
public int compareTo(@Nonnull EncodedValue o) {
    int res = Ints.compare(getValueType(), o.getValueType());
    if (res != 0) return res;
    return getValue().compareTo(((FieldEncodedValue)o).getValue());
}
 
Example 13
Project: crypto-core   File: CryptoUtils.java   Source Code and License Vote up 4 votes
@Override
public int compareTo(Pair o) {
    return -Ints.compare(count, o.count);
}
 
Example 14
Project: okwallet   File: ChildNumber.java   Source Code and License Vote up 4 votes
@Override
public int compareTo(ChildNumber other) {
    // note that in this implementation compareTo() is not consistent with equals()
    return Ints.compare(this.num(), other.num());
}
 
Example 15
Project: andbg   File: BaseTypeEncodedValue.java   Source Code and License Vote up 4 votes
@Override
public int compareTo(@Nonnull EncodedValue o) {
    int res = Ints.compare(getValueType(), o.getValueType());
    if (res != 0) return res;
    return getValue().compareTo(((TypeEncodedValue)o).getValue());
}
 
Example 16
Project: andbg   File: BaseDoubleEncodedValue.java   Source Code and License Vote up 4 votes
@Override
public int compareTo(@Nonnull EncodedValue o) {
    int res = Ints.compare(getValueType(), o.getValueType());
    if (res != 0) return res;
    return Double.compare(getValue(), ((DoubleEncodedValue)o).getValue());
}
 
Example 17
Project: googles-monorepo-demo   File: Multisets.java   Source Code and License Vote up 4 votes
@Override
public int compare(Entry<?> entry1, Entry<?> entry2) {
  return Ints.compare(entry2.getCount(), entry1.getCount());
}
 
Example 18
Project: googles-monorepo-demo   File: CollectionBenchmarkSampleData.java   Source Code and License Vote up 4 votes
@Override
public int compareTo(Element that) {
  return Ints.compare(hash, that.hash);
}
 
Example 19
Project: andbg   File: BaseMethodEncodedValue.java   Source Code and License Vote up 4 votes
@Override
public int compareTo(@Nonnull EncodedValue o) {
    int res = Ints.compare(getValueType(), o.getValueType());
    if (res != 0) return res;
    return getValue().compareTo(((MethodEncodedValue)o).getValue());
}
 
Example 20
Project: andbg   File: BaseFloatEncodedValue.java   Source Code and License Vote up 4 votes
@Override
public int compareTo(@Nonnull EncodedValue o) {
    int res = Ints.compare(getValueType(), o.getValueType());
    if (res != 0) return res;
    return Float.compare(getValue(), ((FloatEncodedValue)o).getValue());
}