Example usage for com.google.common.primitives Ints compare

List of usage examples for com.google.common.primitives Ints compare

Introduction

In this page you can find the example usage for com.google.common.primitives Ints compare.

Prototype

public static int compare(int a, int b) 

Source Link

Document

Compares the two specified int values.

Usage

From source file:suneido.util.IdentityComparator.java

@Override
public int compare(Object o1, Object o2) {
    return Ints.compare(System.identityHashCode(o1), System.identityHashCode(o2));
}

From source file:com.urswolfer.intellij.plugin.gerrit.util.RevisionInfos.java

public static int compare(RevisionInfo r1, RevisionInfo r2) {
    return Ints.compare(r1._number, r2._number);
}

From source file:garmintools.util.SizeUtil.java

public static <T> int getLargest(List<T> list, final Function<T, Integer> sizeOf) {
    Ordering<T> sizeOrdering = new Ordering<T>() {
        @Override/*ww w  .ja  v  a 2s .c  o m*/
        public int compare(T left, T right) {
            return Ints.compare(sizeOf.apply(left), sizeOf.apply(right));
        }
    };
    return sizeOf.apply(sizeOrdering.max(list));
}

From source file:de.textmining.nerdle.utils.MapSorter.java

public static <K, V extends Comparable<? super V>> List<Map.Entry<K, Collection<String>>> multimapSortedByListSize(
        final Multimap<K, String> multiMap) {

    List<Map.Entry<K, Collection<String>>> entries = new ArrayList<Map.Entry<K, Collection<String>>>();
    entries.addAll(multiMap.asMap().entrySet());

    Collections.sort(entries, new Comparator<Map.Entry<K, Collection<String>>>() {
        // @Override
        public int compare(Map.Entry<K, Collection<String>> e1, Map.Entry<K, Collection<String>> e2) {
            return Ints.compare(e2.getValue().size(), e1.getValue().size());
        }//  w w  w. j  a  va2  s.c o m
    });

    return entries;
}

From source file:net.bafeimao.umbrella.support.util.Numbers.java

public static int compare(Object a, Object b) {

    if (!a.getClass().equals(b.getClass())) {
        throw new IllegalArgumentException("class type not the same");
    }//w  w  w  .j a v a2 s .co  m

    // TODO use instanceof instead
    Class<?> clazz = a.getClass();

    int result = 0;

    if (clazz.equals(Double.class)) {
        result = Doubles.compare((Double) a, (Double) b);
    } else if (clazz.equals(Float.class)) {
        result = Floats.compare((Float) a, (Float) b);
    } else if (clazz.equals(Long.class)) {
        result = Longs.compare((Long) b, (Long) b);
    } else if (clazz.equals(Integer.class)) {
        result = Ints.compare((Integer) a, (Integer) b);
    } else if (clazz.equals(Short.class)) {
        result = Shorts.compare((Short) a, (Short) b);
    } else if (clazz.equals(Byte.class)) {
        result = Shorts.compare((Short) a, (Short) b);
    }

    return result;
}

From source file:edu.cmu.lti.oaqa.framework.eval.passage.TRECPassageOrdering.java

public int compare(Passage left, Passage right) {
    int rankDiff = Ints.compare(left.getRank(), right.getRank());
    if (rankDiff != 0) {
        return rankDiff;
    }/*from w  w  w .  jav  a2s  .c  o  m*/
    int pmidDiff = left.getUri().compareTo(right.getUri());
    if (pmidDiff != 0) {
        return pmidDiff;
    }
    int offsetDiff = Ints.compare(left.getBegin(), right.getBegin());
    if (offsetDiff != 0) {
        return offsetDiff;
    }
    return Ints.compare(left.getEnd() - left.getBegin(), right.getEnd() - right.getBegin());
}

From source file:springfox.documentation.spi.service.contexts.Orderings.java

public static Comparator<Operation> positionComparator() {
    return new Comparator<Operation>() {
        @Override/* w  w w.ja  va  2s  .  com*/
        public int compare(Operation first, Operation second) {
            return Ints.compare(first.getPosition(), second.getPosition());
        }
    };
}

From source file:msi.gama.kernel.experiment.IExperimentDisplayable.java

@Override
public default int compareTo(final IExperimentDisplayable p) {
    return Ints.compare(getOrder(), p.getOrder());
}

From source file:se.sics.ktoolbox.overlaymngr.core.IdComparator.java

@Override
public int compare(IdView o1, IdView o2) {
    return Ints.compare(o1.id, o2.id);
}

From source file:org.n52.iceland.util.Comparables.java

public static int compare(int x, int y) {
    return Ints.compare(x, y);
}