edu.cs.ai.kreator.misc.util
Class Pair<E,F>

java.lang.Object
  extended by edu.cs.ai.kreator.misc.util.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

This class implements a simple pair of elements.

Author:
Matthias Thimm

Constructor Summary
Pair()
          Initializes an empty pair.
Pair(E obj1, F obj2)
          Initializes the elements of this pair with the given parameters
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 E getFirst()
          returns the first element of this pair
 F getSecond()
          returns the second element of this pair
 int hashCode()
           
static
<A,B> java.util.List<Pair<A,B>>
makePairs(java.util.Collection<A> first, java.util.Collection<B> second)
          This method combines the two given collections into one collection by making a pair of the collection's elements (as they are given by the collections iterator).
 void setFirst(E obj1)
          sets the first element of this pair
 void setSecond(F obj2)
          sets the second element of this pair
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Pair

public Pair()
Initializes an empty pair.


Pair

public Pair(E obj1,
            F obj2)
Initializes the elements of this pair with the given parameters

Parameters:
obj1 - the first element of this pair
obj2 - the second element of this pair
Method Detail

makePairs

public static <A,B> java.util.List<Pair<A,B>> makePairs(java.util.Collection<A> first,
                                                        java.util.Collection<B> second)
                                           throws java.lang.IllegalArgumentException
This method combines the two given collections into one collection by making a pair of the collection's elements (as they are given by the collections iterator). For example, given a list [a,b,c] and a list [1,2,3] this method returns [(a,1),(b,2),(c,3)]. If the collections differ in their size an IllegalArgumentException is thrown.

Type Parameters:
A - The class of the first element.
B - The class of the second element.
Parameters:
first - a collection of As.
second - a collection of Bs.
Returns:
a list of pairs of As and Bs.
Throws:
java.lang.IllegalArgumentException - if the size of the collections differ.

getFirst

public E getFirst()
returns the first element of this pair

Returns:
the first element of this pair

setFirst

public void setFirst(E obj1)
sets the first element of this pair

Parameters:
obj1 - an object of type E

getSecond

public F getSecond()
returns the second element of this pair

Returns:
the second element of this pair

setSecond

public void setSecond(F obj2)
sets the second element of this pair

Parameters:
obj2 - an object of type F

toString

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

hashCode

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

equals

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