org.moyoman.util
Class IntPair

java.lang.Object
  |
  +--org.moyoman.util.IntPair
All Implemented Interfaces:
Cloneable, Serializable

public class IntPair
extends Object
implements Serializable, Cloneable

This class provides an easy way of relating two integers. The objects are stored and retrieved in order, but two objects of type IntPair are considered to be equal if the two integers are equal regardless of their order.

See Also:
Serialized Form

Field Summary
private  int val1
          The first integer.
private  int val2
          The second integer.
 
Constructor Summary
IntPair(int i1, int i2)
          Create a new IntPair object.
 
Method Summary
 Object clone()
          Override the Object.clone() method.
 boolean equals(Object o)
          Override the default equals() method.
 int getI1()
          Return the first integer.
 int getI2()
          Return the second integer.
 int hashCode()
          Override the default hashCode() method.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

val1

private int val1
The first integer.


val2

private int val2
The second integer.

Constructor Detail

IntPair

public IntPair(int i1,
               int i2)
Create a new IntPair object.

Parameters:
i1 - The first integer in the pair.
i2 - The second integer in the pair.
Method Detail

getI1

public int getI1()
Return the first integer.

Returns:
Return the integer.

getI2

public int getI2()
Return the second integer.

Returns:
Return the integer.

equals

public boolean equals(Object o)
Override the default equals() method. Should return true for all instances where i1 == i1 and i2 == i2, or i1 == i2 and i2 == i1. It can only return true if ip is an IntPair object.

Overrides:
equals in class Object
Returns:
true if the two objects are equal, or false.

hashCode

public int hashCode()
Override the default hashCode() method. Should return the same value for two IntPair objects if ip1.equals(ip2) is true.

Overrides:
hashCode in class Object

clone

public Object clone()
Override the Object.clone() method.

Overrides:
clone in class Object
Returns:
An IntPair object which is a clone of this one.