|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectinfo.javelot.functionalj.tuple.Pair<A,B>
public class Pair<A,B>
Used to create a tuple of two objects. Tuples can be used anywhere
there is a need to group objects together, and Pairs are used by the
Tuples.zip(Collection, Collection) method.
| Field Summary | |
|---|---|
Function1<A,Pair<A,B>> |
first
Function that returns the first element of the tuple. |
Function2<Pair<A,B>,A,B> |
pair
Function that creates a Pair. |
Function1<B,Pair<A,B>> |
second
Function that returns the second element of the tuple. |
| Constructor Summary | |
|---|---|
Pair()
Default constructor. |
|
Pair(A p_first,
B p_second)
Creates a tuple containing the two given objects. |
|
| Method Summary | |
|---|---|
int |
compareTo(Pair p_pair)
Sort tuples according to the objects that they contain. |
boolean |
equals(Object p_object)
Determines if the given object is equal to this object, by comparing the two objects of each tuple using their respective equals(Object)
methods. |
A |
getFirst()
Returns the first object of the tuple. |
B |
getSecond()
Returns the second object of the tuple. |
protected List<String> |
getStrings()
Returns a list of the String representations of the objects of the tuple. |
int |
hashCode()
Returns the hash code associated with this object. |
void |
setFirst(A p_first)
Sets the first object of the tuple. |
void |
setSecond(B p_second)
Sets the second object of the tuple. |
String |
toString()
Returns a String representation of the Pair. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public Function2<Pair<A,B>,A,B> pair
public Function1<A,Pair<A,B>> first
public Function1<B,Pair<A,B>> second
| Constructor Detail |
|---|
public Pair()
public Pair(A p_first,
B p_second)
p_first - the first object of the pair. A null value is
accepted.p_second - the second object of the pair. A null value is
accepted.| Method Detail |
|---|
public A getFirst()
null.public void setFirst(A p_first)
p_first - the first object of the tuple.public B getSecond()
null.public void setSecond(B p_second)
p_second - the second object of the tuple.public int hashCode()
Thanks to Paul Field for suggesting the improvement on this hash function.
hashCode in class Object31 each time. A null value is
considered to have* a hash code of 0. Thus, if this pair contains
two null values, this method returns 0.public boolean equals(Object p_object)
equals(Object)
methods. Corresponding null values are also considered equal.
equals in class Objectp_object - the object against which to compare this tuple.
true if the pairs contain the same values;
false otherwise.public int compareTo(Pair p_pair)
Comparable interface, they
are left unsorted.
compareTo in interface Comparable<Pair>protected List<String> getStrings()
toString() method uses this to construct the String representation of the
tuple.
public String toString()
toString in class Object"(String, String)".
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||