| Constructor and Description |
|---|
IntPair(int first,
int second)
Constructs an
IntPair instance that represents the
specified ordered pair of integers. |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(IntPair other)
Returns -1, 0, or 1 depending on whether
this is
less than, equal, or greater than the specified IntPair
object. |
boolean |
equals(java.lang.Object obj)
Compares the specified object with this
IntPair for
equality. |
int |
first()
Returns the first integer in the ordered pair of integers.
|
int |
hashCode()
Returns a hash code value for the object.
|
int |
second()
Returns the second integer in the ordered pair of integers.
|
java.lang.String |
toString()
Returns a string representation of
this. |
public IntPair(int first,
int second)
IntPair instance that represents the
specified ordered pair of integers.first - the first element of the ordered pair of integers.second - the second element of the ordered pair of integers.public int first()
public int second()
public boolean equals(java.lang.Object obj)
IntPair for
equality. Returns true if the specified object
is an IntPair that represents the same ordered
pair of integers as this, and returns false
otherwise.equals in class java.lang.Objectobj - the object to be compared for equality with this
IntPair.true if the specified object is an IntPair
that represents the same ordered pair of integers as this,
and returns false otherwise.public int hashCode()
The hash code is defined by the following calculation:
int hash = 5;
hash = 29 * hash + this.first;
hash = 29 * hash + this.second;
hashCode in class java.lang.Objectpublic java.lang.String toString()
this. The string
representation is "[i1, i2]" where
i1 and i2 are the first and second integers
in the ordered pair of integers represented by this.toString in class java.lang.Objectthis.public int compareTo(IntPair other)
this is
less than, equal, or greater than the specified IntPair
object. IntPair instances are ordered using
lexicographical order.compareTo in interface java.lang.Comparable<IntPair>other - an IntPair instance to be compared to
this.this is
less than, equal, or greater than the specified IntPair
object.