de.fhstralsund.vinets.structure
Class NodePair

java.lang.Object
  extended by de.fhstralsund.vinets.structure.NodePair
All Implemented Interfaces:
java.io.Serializable

public class NodePair
extends java.lang.Object
implements java.io.Serializable

A set of two Nodes. The order of the Nodes is not important.

See Also:
Serialized Form

Field Summary
protected  Node first
           
protected  Node second
           
 
Constructor Summary
NodePair(Node u, Node v)
          Creates a NodePair.
 
Method Summary
 boolean contains(Node node)
          Checks whether the passed Node is member of this NodePair.
 boolean equals(java.lang.Object obj)
          Two NodePairs are equal if and only if they contain the same Nodes.
 Node getOne()
          Returns one of the two Nodes.
 Node getOther(Node u)
          Returns the one of the two Nodes in a NodePair that is not identical with the parameter Node.
 int hashCode()
          Two NodePairs containing the same Nodes have the same hashCode.
 java.util.Iterator iterator()
          Returns an iterator over the two Nodes.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

first

protected Node first

second

protected Node second
Constructor Detail

NodePair

public NodePair(Node u,
                Node v)
Creates a NodePair.

Parameters:
u -
v - the two Nodes, they should not be the null reference.
Method Detail

equals

public boolean equals(java.lang.Object obj)
Two NodePairs are equal if and only if they contain the same Nodes.

Overrides:
equals in class java.lang.Object
Parameters:
obj - a NodePair to compare with
Returns:
true if either this NodePair and obj are identical or if they differ only by the order in which the two Nodes are stored.

hashCode

public int hashCode()
Two NodePairs containing the same Nodes have the same hashCode.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this NodePair

getOne

public Node getOne()
Returns one of the two Nodes.

Returns:
a Node contained in the NodePair

getOther

public Node getOther(Node u)
Returns the one of the two Nodes in a NodePair that is not identical with the parameter Node.

Parameters:
u - a Node contained in this NodePair
Returns:
the other Node contained in this NodePair
Throws:
java.lang.IllegalArgumentException - if u is not a member of this NodePair

iterator

public java.util.Iterator iterator()
Returns an iterator over the two Nodes.

Returns:
an iterator over the two Nodes.

contains

public boolean contains(Node node)
Checks whether the passed Node is member of this NodePair.

Parameters:
node - the Node
Returns:
true if the passed Node is contained.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object