com.hedgehog.utility
Class PairPQ<P,Q>

java.lang.Object
  extended by com.hedgehog.HObject
      extended by com.hedgehog.utility.PairPQ<P,Q>
Type Parameters:
P - Type of first object p.
Q - Type of second object q.
All Implemented Interfaces:
java.lang.Comparable, java.util.Comparator

public class PairPQ<P,Q>
extends HObject

Title: PairPQ - stores a pair of objects of arbitrary types.

Description: Encapsulates a pair (p,q) of Objects with p of type P and q of type Q.

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

Company: Hedgehog Software.

Since:
1.0
Version:
1.1

Field Summary
protected  P mp
          Object p.
protected  Q mq
          Object q.
 
Fields inherited from class com.hedgehog.HObject
mID, mName
 
Constructor Summary
PairPQ()
          Default constructor.
PairPQ(PairPQ<P,Q> object)
          Copy onstructor.
PairPQ(P p, Q q)
          Constructor.
 
Method Summary
 boolean equals(java.lang.Object object)
          Tests whether or not the specified object is equal to this object.
 P getP()
          Returns the p object.
 Q getQ()
          Returns the q object.
 int hashCode()
          Returns the hash code for this object; ie (1 << mp.hashCode()) + mq.hashCode();
 boolean samePair(PairPQ pair)
          Tests for equality of this pair and the specified pair.
 boolean setP(P newP)
          Sets the p object.
 boolean setQ(Q newQ)
          Sets the q object.
 java.lang.String toString()
          Returns a String representation of a PairPQ 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

mp

protected P mp
Object p.


mq

protected Q mq
Object q.

Constructor Detail

PairPQ

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


PairPQ

public PairPQ(P p,
              Q q)
Constructor. Sets the pair object to the specified non-null objects.

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

PairPQ

public PairPQ(PairPQ<P,Q> object)
Copy onstructor.

Parameters:
object - Object to copy.
Method Detail

getP

public P getP()
Returns the p object.

Returns:
The p object.

getQ

public Q getQ()
Returns the q object.

Returns:
The q object.

samePair

public boolean samePair(PairPQ pair)
Tests for equality of this pair and the specified pair. Uses the equals() method of types P and Q. Unlike class Pair, PairPQ.samePair() does not support comparisons in both senses since this is probably meaningless for different types.

Parameters:
pair - Other pair.
Returns:
Logical-true if the specified pair object is equivalent to this object, else logical-false.

setP

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

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

setQ

public boolean setQ(Q 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 PairPQ object.

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

equals

public boolean equals(java.lang.Object object)
Tests whether or not the specified object is equal to this object.

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 (1 << mp.hashCode()) + mq.hashCode();

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