java.lang.Object
de.lmu.ifi.dbs.elki.utilities.pairs.IntIntPair
- All Implemented Interfaces:
PairInterface<Integer,,Integer> Comparable<IntIntPair>
public class IntIntPair
extends Object
implements Comparable<IntIntPair>, PairInterface<Integer,Integer>
Pair storing two integers.
Since int is a native type, this can't be done via the
generic.
invalid reference
CPair
- Author:
- Erich Schubert
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Comparator<IntIntPair> Comparator to compare by second component onlystatic final Comparator<IntIntPair> Comparator to compare by second component onlyintfirst valueintsecond valuestatic final Comparator<IntIntPair> Comparator to compare by swapped components -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcompareSwappedTo(IntIntPair other) Implementation of comparableSwapped interface, sorting by second then first.intcompareTo(IntIntPair other) Implementation of comparable interface, sorting by first then second.booleanTrivial equals implementationfinal IntegergetFirst()Deprecated.use pair.first to avoid boxing!final IntegerDeprecated.use pair.first to avoid boxing!final inthashCode()Trivial hashCode implementation mixing the two integers.final voidsetFirst(int first) Set first valuefinal voidsetSecond(int second) Set second valuetoString()
-
Field Details
-
first
public int firstfirst value -
second
public int secondsecond value -
BYFIRST_COMPARATOR
Comparator to compare by second component only -
BYSECOND_COMPARATOR
Comparator to compare by second component only -
SWAPPED_COMPARATOR
Comparator to compare by swapped components
-
-
Constructor Details
-
IntIntPair
public IntIntPair(int first, int second) Constructor- Parameters:
first- First valuesecond- Second value
-
-
Method Details
-
equals
Trivial equals implementation -
hashCode
public final int hashCode()Trivial hashCode implementation mixing the two integers. -
compareTo
Implementation of comparable interface, sorting by first then second.- Specified by:
compareToin interfaceComparable<IntIntPair>- Parameters:
other- Object to compare to- Returns:
- comparison result
-
compareSwappedTo
Implementation of comparableSwapped interface, sorting by second then first.- Parameters:
other- Object to compare to- Returns:
- comparison result
-
getFirst
Deprecated.use pair.first to avoid boxing!Description copied from interface:PairInterfaceGet the first object - note: this may cause autoboxing, use pair.first for native pairs!- Specified by:
getFirstin interfacePairInterface<Integer,Integer> - Returns:
- First object
-
setFirst
public final void setFirst(int first) Set first value- Parameters:
first- new value
-
getSecond
Deprecated.use pair.first to avoid boxing!Description copied from interface:PairInterfaceGet the second object - note: this may cause autoboxing, use pair.second for native pairs!- Specified by:
getSecondin interfacePairInterface<Integer,Integer> - Returns:
- Second object
-
setSecond
public final void setSecond(int second) Set second value- Parameters:
second- new value
-
toString
-