|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectinfo.javelot.functionalj.tuple.Pair
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 | |
static Function1 |
first
Function that returns the first element of the tuple. |
static Function2 |
pair
Function that creates a Pair. |
static Function1 |
second
Function that returns the second element of the tuple. |
| Constructor Summary | |
Pair(Object p_first,
Object p_second)
Creates a tuple containing the two given objects. |
|
| Method Summary | |
int |
compareTo(Object p_object)
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. |
Object |
getFirst()
Returns the first object of the tuple. |
Object |
getSecond()
Returns the second object of the tuple. |
protected List |
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(Object p_first)
Sets the first object of the tuple. |
void |
setSecond(Object 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 static final Function2 pair
public static final Function1 first
public static final Function1 second
| Constructor Detail |
public Pair(Object p_first,
Object 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 Object getFirst()
null.public void setFirst(Object p_first)
p_first - the first object of the tuple.public Object getSecond()
null.public void setSecond(Object 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.
31 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.
p_object - the object against which to compare this tuple.
true if the pairs contain the same values;
false otherwise.public int compareTo(Object p_object)
Comparable interface, they
are left unsorted.
compareTo in interface Comparableprotected List getStrings()
toString() method uses this to construct the String representation of the
tuple.
public String toString()
"(String, String)".
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||