com.hedgehog.utility
Class Pair

java.lang.Object
  extended by com.hedgehog.HObject
      extended by com.hedgehog.utility.Pair
All Implemented Interfaces:
java.lang.Comparable, java.util.Comparator

public class Pair
extends HObject

Title: Pair - stores a pair of objects of type HObject.

Description: Encapsulates a pair (p,q) of Objects.

Copyright: Copyright (c) Hedgehog Software 2007-2009.

Company: Hedgehog Software.

Since:
1.0
Version:
1.1

Field Summary
protected  HObject p
          Object p.
protected  HObject q
          Object q.
 
Fields inherited from class com.hedgehog.HObject
mID, mName
 
Constructor Summary
Pair()
          Default constructor.
Pair(HObject p, HObject q)
          Constructor.
Pair(Pair object)
          Copy constructor.
 
Method Summary
 boolean equals(java.lang.Object object)
          Tests whether or not the specified object is equal to this object.
 HObject getP()
          Returns the p object.
 HObject getQ()
          Returns the q object.
 int hashCode()
          Returns the hash code for this object; ie p.hashCode() ^ q.hashCode().
 boolean samePair(Pair pair, boolean bothSenses)
          Tests for equality of this pair and the specified pair.
 boolean setP(HObject newP)
          Sets the p object.
 boolean setQ(HObject newQ)
          Sets the q object.
 java.lang.String toString()
          Returns a String representation of a Pair object.
 
Methods inherited from class com.hedgehog.HObject
clone, compare, compareTo, copy, getID, getName, hasID, hasName, setID, setName
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

p

protected HObject p
Object p.


q

protected HObject q
Object q.

Constructor Detail

Pair

public Pair()
Default constructor. Sets both of the pair objects to null.


Pair

public Pair(HObject p,
            HObject q)
Constructor. Sets the pair object to the specified non-null objects.

Parameters:
p - Object p.
q - Object q.

Pair

public Pair(Pair object)
Copy constructor.

Parameters:
object - Object to copy.
Method Detail

equals

public boolean equals(java.lang.Object object)
Tests whether or not the specified object is equal to this object. Uses the equals() method for objects p and q.

Specified by:
equals in interface java.util.Comparator
Overrides:
equals in class HObject
Parameters:
object - Object to compare.
Returns:
Logical-true if the specified object is equal to this object, else logical-false.

hashCode

public int hashCode()
Returns the hash code for this object; ie p.hashCode() ^ q.hashCode().

Overrides:
hashCode in class HObject
Returns:
This object's hash code.

getP

public HObject getP()
Returns the p object.

Returns:
The p object.

getQ

public HObject getQ()
Returns the q object.

Returns:
The q object.

samePair

public boolean samePair(Pair pair,
                        boolean bothSenses)
Tests for equality of this pair and the specified pair.

Parameters:
pair - Other pair object.
bothSenses - Specifies whether or not both pair object
Returns:
Logical-true if the specified pair object is equivalent to this object, else logical-false.

setP

public boolean setP(HObject newP)
Sets the p object.

Parameters:
newP - New p object.
Returns:
Logical-true if object set, else logical-false.

setQ

public boolean setQ(HObject newQ)
Sets the q object.

Parameters:
newQ - New q object.
Returns:
Logical-true if object set, else logical-false.

toString

public java.lang.String toString()
Returns a String representation of a Pair object.

Overrides:
toString in class java.lang.Object
Returns:
A String representation of a Pair object.