rcf.core.util.groups
Class Pair<A,B>

java.lang.Object
  extended by rcf.core.util.groups.Singleton<A>
      extended by rcf.core.util.groups.Pair<A,B>
Type Parameters:
A - The type of the first entry in each pair.
B - The type of the second entry in each pair.
All Implemented Interfaces:
ImmutablePairInterface<A,B>, ImmutableSingletonInterface<A>, PairInterface<A,B>, SingletonInterface<A>
Direct Known Subclasses:
Triple

@Revision(value="$Revision: 1.37 $",
          date="$Date: 2006/11/09 02:10:09 $",
          tag="$Name:  $")
public class Pair<A,B>
extends Singleton<A>
implements PairInterface<A,B>

TODO: Javadoc Provides a simple, type safe (generic) wrapper which can encapsulate a pair of references. This is effectively a multi-type, type safe limited length array.

Version:
$Revision: 1.37 $
Author:
Greg Gibeling

Nested Class Summary
static class Pair.Iterable<A,B>
          TODO: Javadoc Binds a pair of iterable objects, allowing them to be iterated in tandem.
static class Pair.Iterator<A,B>
          TODO: Javadoc Binds a pair of iterators, allowing them to be iterated in tandem.
 
Field Summary
protected  B b
          TODO: Javadoc The second object to store.
 
Fields inherited from class rcf.core.util.groups.Singleton
a
 
Constructor Summary
Pair(A _a, B _b)
          TODO: Javadoc Base constructor, simply records the elements for this object.
 
Method Summary
static
<A,B> Pair<A,B>[]
composeArrays(A[] a, B[] b)
          TODO: Javadoc Compose two arrays of values into an array of pairs of values.
static
<A,B,P extends ImmutablePairInterface<A,B>>
Pair<A[],B[]>
decomposeArrays(P[] p)
          TODO: Javadoc Decompose an array of pairs into a pair of arrays of values.
 boolean equals(Object o)
           
 A getA()
          TODO: Javadoc Get the first element of this pair.
 B getB()
          TODO: Javadoc Get the second element of this pair.
 int hashCode()
           
 void set(A _a, B _b)
          TODO: Javadoc
 A setA(A _a)
          TODO: Javadoc Set the first element of this pair.
 B setB(B _b)
          TODO: Javadoc Set the second element of this pair.
 String toString()
           
 
Methods inherited from class rcf.core.util.groups.Singleton
composeArrays, decomposeArrays, get, set
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface rcf.core.util.groups.ImmutableSingletonInterface
get
 
Methods inherited from interface rcf.core.util.groups.SingletonInterface
set
 
Methods inherited from interface rcf.core.util.groups.ImmutableSingletonInterface
get
 

Field Detail

b

protected B b
TODO: Javadoc The second object to store.

Constructor Detail

Pair

public Pair(A _a,
            B _b)
TODO: Javadoc Base constructor, simply records the elements for this object.

Parameters:
_a - The first object to store.
_b - The second object to store.
Method Detail

composeArrays

public static final <A,B> Pair<A,B>[] composeArrays(A[] a,
                                                    B[] b)
TODO: Javadoc Compose two arrays of values into an array of pairs of values. The two input arrays must have equal length.

Type Parameters:
A - The type of the first array, and the first element in each pair.
B - The type of the second array, and the second element in each pair.
Parameters:
a - Array of the first elements of the resulting pairs.
b - Array of the second elements of the resulting pairs.
Returns:
An array of pairs of values pulled from the specified arrays.

decomposeArrays

public static final <A,B,P extends ImmutablePairInterface<A,B>> Pair<A[],B[]> decomposeArrays(P[] p)
TODO: Javadoc Decompose an array of pairs into a pair of arrays of values.

Type Parameters:
A - The type of the first array, and the first element in each pair.
B - The type of the second array, and the second element in each pair.
P - The type of the actual elements in the input array, must extend ImmutablePairInterface.
Parameters:
p - An array of pairs of values to be put into the resulting arrays.
Returns:
A pair of arrays of the values from the specified pairs.

equals

public boolean equals(Object o)
Overrides:
equals in class Singleton<A>

getA

public A getA()
Description copied from interface: ImmutablePairInterface
TODO: Javadoc Get the first element of this pair.

Specified by:
getA in interface ImmutablePairInterface<A,B>
Returns:
The first element of this pair.
See Also:
ImmutableSingletonInterface.get()

getB

public B getB()
Description copied from interface: ImmutablePairInterface
TODO: Javadoc Get the second element of this pair.

Specified by:
getB in interface ImmutablePairInterface<A,B>
Returns:
The second element of this pair.

hashCode

public int hashCode()
Overrides:
hashCode in class Singleton<A>

setA

public A setA(A _a)
Description copied from interface: PairInterface
TODO: Javadoc Set the first element of this pair.

Specified by:
setA in interface PairInterface<A,B>
Parameters:
_a - The new first element of this pair.
Returns:
The old first element on this pair.
See Also:
SingletonInterface.set(Object)

setB

public B setB(B _b)
Description copied from interface: PairInterface
TODO: Javadoc Set the second element of this pair.

Specified by:
setB in interface PairInterface<A,B>
Parameters:
_b - The new second element of this pair.
Returns:
The old second element on this pair.

set

public void set(A _a,
                B _b)
Description copied from interface: PairInterface
TODO: Javadoc

Specified by:
set in interface PairInterface<A,B>

toString

public String toString()
Overrides:
toString in class Singleton<A>