Example usage for java.lang Integer compare

List of usage examples for java.lang Integer compare

Introduction

In this page you can find the example usage for java.lang Integer compare.

Prototype

public static int compare(int x, int y) 

Source Link

Document

Compares two int values numerically.

Usage

From source file:net.mintern.primitive.pair.ByteIntPair.java

/**
 * Compares the pair based on the left element followed by the right element.
 *
 * @param other  the other pair, not null
 * @return negative if this is less, zero if equal, positive if greater
 *//*from  w  ww  .  jav a2  s  . c  o m*/
@Override
public int compareTo(ByteIntPair other) {
    int cmp = Byte.compare(getLeft(), other.getLeft());
    return cmp != 0 ? cmp : Integer.compare(getRight(), other.getRight());
}

From source file:net.mintern.primitive.pair.LongIntPair.java

/**
 * Compares the pair based on the left element followed by the right element.
 *
 * @param other  the other pair, not null
 * @return negative if this is less, zero if equal, positive if greater
 *///from   w  w w.  ja v  a2  s.  co  m
@Override
public int compareTo(LongIntPair other) {
    int cmp = Long.compare(getLeft(), other.getLeft());
    return cmp != 0 ? cmp : Integer.compare(getRight(), other.getRight());
}

From source file:net.mintern.primitive.pair.FloatIntPair.java

/**
 * Compares the pair based on the left element followed by the right element.
 *
 * @param other  the other pair, not null
 * @return negative if this is less, zero if equal, positive if greater
 *///from   ww w .ja  v  a  2  s  .c o  m
@Override
public int compareTo(FloatIntPair other) {
    int cmp = Float.compare(getLeft(), other.getLeft());
    return cmp != 0 ? cmp : Integer.compare(getRight(), other.getRight());
}

From source file:net.mintern.primitive.pair.CharIntPair.java

/**
 * Compares the pair based on the left element followed by the right element.
 *
 * @param other  the other pair, not null
 * @return negative if this is less, zero if equal, positive if greater
 *///from www .j  a v a  2s.  c om
@Override
public int compareTo(CharIntPair other) {
    int cmp = Character.compare(getLeft(), other.getLeft());
    return cmp != 0 ? cmp : Integer.compare(getRight(), other.getRight());
}

From source file:lyonlancer5.karasu.lib.WorldCoord.java

@Override
public int compareTo(Vec3i wc) {
    if (wc instanceof WorldCoord) {
        WorldCoord wcx = (WorldCoord) wc;
        int legthThis = getX() * getX() + getY() * getY() + getZ() * getZ();
        int legthOther = wcx.getX() * wcx.getX() + wcx.getY() * wcx.getY() + wcx.getZ() * wcx.getZ();

        return Integer.compare(legthThis, legthOther);
    }/*  w  w w.  j  a  va  2  s .  co m*/
    return super.compareTo(wc);
}

From source file:org.schedoscope.metascope.index.model.SolrQueryResultEntity.java

@Override
public int compareTo(SolrQueryResultEntity other) {
    if (this.highlightings == null || other.highlightings == null) {
        return 0;
    }/* w  ww  .j  a  va 2 s.c o m*/
    return Integer.compare(this.getSize(), other.getSize()) * -1;
}

From source file:net.mintern.primitive.pair.DoubleIntPair.java

/**
 * Compares the pair based on the left element followed by the right element.
 *
 * @param other  the other pair, not null
 * @return negative if this is less, zero if equal, positive if greater
 *///www  .j  a v a  2s  . co m
@Override
public int compareTo(DoubleIntPair other) {
    int cmp = Double.compare(getLeft(), other.getLeft());
    return cmp != 0 ? cmp : Integer.compare(getRight(), other.getRight());
}

From source file:edu.umd.umiacs.clip.tools.classifier.LibSVMUtils.java

public static String asString(Map<Integer, Double> map) {
    return String.join(" ",
            map.entrySet().stream().sorted((e1, e2) -> Integer.compare(e1.getKey(), e2.getKey()))
                    .filter(entry -> entry.getValue() != 0)
                    .map(entry -> entry.getKey() + ":" + entry.getValue()).collect(toList()));
}

From source file:net.mintern.primitive.pair.BooleanIntPair.java

/**
 * Compares the pair based on the left element followed by the right element.
 *
 * @param other  the other pair, not null
 * @return negative if this is less, zero if equal, positive if greater
 *//*from   ww  w .  j  av a 2s.  co m*/
@Override
public int compareTo(BooleanIntPair other) {
    int cmp = Boolean.compare(getLeft(), other.getLeft());
    return cmp != 0 ? cmp : Integer.compare(getRight(), other.getRight());
}

From source file:com.jivesoftware.os.upena.shared.Host.java

@Override
public int compareTo(Host o) {
    int i = hostName.compareTo(o.hostName);
    if (i == 0) {
        i = Integer.compare(port, o.port);
    }// w  w  w .  j a  v  a  2s.  c o  m
    if (i == 0) {
        i = workingDirectory.compareTo(o.workingDirectory);
    }
    return i;
}