/** * Clones this object. * * @return clone of this object */ public PairOfLongInt clone() { return new PairOfLongInt(this.leftElement, this.rightElement); }
/** * Checks two pairs for equality. * * @param obj object for comparison * @return <code>true</code> if <code>obj</code> is equal to this object, <code>false</code> * otherwise */ public boolean equals(Object obj) { PairOfLongInt pair = (PairOfLongInt) obj; return leftElement == pair.getLeftElement() && rightElement == pair.getRightElement(); }
/** * Creates a pair. * * @param left the left element * @param right the right element */ public PairOfLongInt(long left, int right) { set(left, right); }
/** * Defines a natural sort order for pairs. Pairs are sorted first by the left element, and then by * the right element. * * @return a value less than zero, a value greater than zero, or zero if this pair should be * sorted before, sorted after, or is equal to <code>obj</code>. */ public int compareTo(PairOfLongInt pair) { long pl = pair.getLeftElement(); int pr = pair.getRightElement(); if (leftElement == pl) { if (rightElement < pr) return -1; if (rightElement > pr) return 1; return 0; } if (leftElement < pl) return -1; return 1; }
public static PairOfLongInt of(long left, int right) { return new PairOfLongInt(left, right); }