|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<Object>
com.healthmarketscience.common.util.Tuple1<ObjType0>
com.healthmarketscience.common.util.Tuple2<ObjType0,ObjType1>
public class Tuple2<ObjType0,ObjType1>
Simple class for holding a pair of typed objects. Also implements
Entry.Map
. You can construct a Tuple2
from a
Map.Entry
, and equals(java.lang.Object)
and hashCode()
are both
special-cased to handle Map.Entry
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.healthmarketscience.common.util.Tuple1 |
---|
Tuple1.Accessor, Tuple1.IterableIterator<Type> |
Field Summary |
---|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
Tuple2()
Initializes a new Tuple2 with null objects. |
|
Tuple2(Map.Entry<? extends ObjType0,? extends ObjType1> entry)
Initializes a new Tuple2 based on the given Map.Entry. |
|
Tuple2(ObjType0 obj0,
ObjType1 obj1)
Initializes a new Tuple2 with the given objects. |
Method Summary | ||
---|---|---|
Tuple2<ObjType0,ObjType1> |
clone()
Makes a copy of this Tuple2. |
|
static
|
collection1(Collection<? extends Tuple2<?,InObjType1>> col)
Get a Collection adapter for element 1 of the Tuples of the given Collection. |
|
static
|
create(InObjType0 obj0,
InObjType1 obj1)
Creates a new Tuple2 with the provided objects |
|
static
|
create(Map.Entry<InObjType0,InObjType1> entry)
Creates a new Tuple2 with the Map.Entry's key and value as the objects. |
|
boolean |
equals(Object o)
Indicates whether the given Object is equal to this Tuple2. |
|
Object[] |
get()
Get the objects of this tuple as an array. |
|
Object |
get(int index)
Get the value of this tuple identified by index, which must always be either 0 or 1, since this tuple class stores exactly two objects. |
|
ObjType1 |
get1()
Returns the second object of this tuple. |
|
ObjType0 |
getKey()
Get the first object of this tuple. |
|
ObjType1 |
getValue()
Get the second object of this tuple. |
|
int |
hashCode()
Returns a hash code for this Tuple2, based on the objects it contains. |
|
static
|
iterable1(Iterable<? extends Tuple2<?,InObjType1>> iable)
Get an Iterable adapter that returns an Iterator that iterates over element 1 of the Tuples within the given Iterable/Iterator. |
|
void |
set(ObjType0 obj0,
ObjType1 obj1)
Sets the values of this Tuple2. |
|
void |
set1(ObjType1 obj)
Sets the second object of this tuple. |
|
ObjType1 |
setValue(ObjType1 newValue)
Set the second object of this tuple. |
|
int |
size()
Get the size of this tuple, which is always 2. |
Methods inherited from class com.healthmarketscience.common.util.Tuple1 |
---|
collection0, get0, iterable0, set, set0 |
Methods inherited from class java.util.AbstractList |
---|
add, add, addAll, clear, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList |
Methods inherited from class java.util.AbstractCollection |
---|
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
add, add, addAll, addAll, clear, contains, containsAll, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, subList, toArray, toArray |
Constructor Detail |
---|
public Tuple2()
public Tuple2(ObjType0 obj0, ObjType1 obj1)
create(InObjType0, InObjType1)
instead, since it infers the type parameters based on
its arguments.
obj0
- the first object to store in this tuple.obj1
- the second object to store in this tuple.public Tuple2(Map.Entry<? extends ObjType0,? extends ObjType1> entry)
entry
- the entry base this Tuple2 onMethod Detail |
---|
public static <InObjType0,InObjType1> Tuple2<InObjType0,InObjType1> create(InObjType0 obj0, InObjType1 obj1)
obj0
- the first object to store in this tuple.obj1
- the second object to store in this tuple.
public static <InObjType0,InObjType1> Tuple2<InObjType0,InObjType1> create(Map.Entry<InObjType0,InObjType1> entry)
entry
- the Map.Entry from which a new Tuple2 will be created.
public static <InObjType1> Iterable<InObjType1> iterable1(Iterable<? extends Tuple2<?,InObjType1>> iable)
public static <InObjType1> Collection<InObjType1> collection1(Collection<? extends Tuple2<?,InObjType1>> col)
public final ObjType1 get1()
public final void set1(ObjType1 obj)
obj
- the object to set as the second object of this tuple.public Object[] get()
get
in class Tuple1<ObjType0>
public Object get(int index)
get
in interface List<Object>
get
in class Tuple1<ObjType0>
index
- the index of the object to retrieve. Must be 0 or 1.
public final void set(ObjType0 obj0, ObjType1 obj1)
obj0
- the object to use as the first object of this tuple.obj1
- the object to use as the second object of this tuple.public ObjType0 getKey()
getKey
in interface Map.Entry<ObjType0,ObjType1>
public ObjType1 getValue()
getValue
in interface Map.Entry<ObjType0,ObjType1>
public ObjType1 setValue(ObjType1 newValue)
setValue
in interface Map.Entry<ObjType0,ObjType1>
newValue
- the object to set as the second object of this tuple.
public int size()
size
in interface Collection<Object>
size
in interface List<Object>
size
in class Tuple1<ObjType0>
public Tuple2<ObjType0,ObjType1> clone()
clone
in class Tuple1<ObjType0>
public boolean equals(Object o)
equals
in interface Collection<Object>
equals
in interface List<Object>
equals
in interface Map.Entry<ObjType0,ObjType1>
equals
in class Tuple1<ObjType0>
true
if the given Object refers to this Tuple2.true
if the given Object is an instance of Tuple2 for which
the contained objects are equal to this Tuple2's objects.true
if the given Object is an instance of Entry.Map, and
the Object's key and value are equal to this Tuple2's key and value,
respectively.
false
otherwise.public int hashCode()
hashCode
in interface Collection<Object>
hashCode
in interface List<Object>
hashCode
in interface Map.Entry<ObjType0,ObjType1>
hashCode
in class Tuple1<ObjType0>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |