jbil.common
Class Pair<E,F>

java.lang.Object
  extended by jbil.common.Pair<E,F>
Type Parameters:
E - The type of the first element.
F - The type of the second element.

public class Pair<E,F>
extends java.lang.Object

Utility 'generalised' class representing a pair of values with not necessarily identical types.

Author:
Paulo G.S. da Fonseca

Field Summary
 E first
          The first element
 F second
          The second element
 
Constructor Summary
Pair()
          Creates a new (null,null) pair.
Pair(E first, F second)
          Creates a new pair with specified elements.
 
Method Summary
 boolean contains(java.lang.Object o)
          Checks if the pair contains one given element.
 boolean equals(java.lang.Object other)
           
 java.lang.Object get(int index)
          Gets an element from its index: 0=first, 1=second.
 int hashCode()
           
 Pair<F,E> invert()
          Creates a new pair with the same elements of this pair in inversed order.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

first

public E first
The first element


second

public F second
The second element

Constructor Detail

Pair

public Pair()
Creates a new (null,null) pair.


Pair

public Pair(E first,
            F second)
Creates a new pair with specified elements.

Parameters:
first - The first element.
second - The second element.
Method Detail

get

public java.lang.Object get(int index)
Gets an element from its index: 0=first, 1=second.

Parameters:
index - The index of the element.
Throws:
java.lang.IndexOutOfBoundsException

invert

public Pair<F,E> invert()
Creates a new pair with the same elements of this pair in inversed order.


equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

contains

public boolean contains(java.lang.Object o)
Checks if the pair contains one given element.