|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.uci.ics.jung.graph.util.Pair<T>
public final class Pair<T>
An implementation of Collection that stores exactly
2 non-null objects and is not mutable. They respect equals
and may be used as indices or map keys.
Note that they do not protect from malevolent behavior: if one or another object in the tuple is mutable, then it can be changed with the usual bad effects.
| Constructor Summary | |
|---|---|
Pair(Collection<? extends T> values)
Creates a Pair from the passed Collection. |
|
Pair(T[] values)
Creates a Pair from the passed array. |
|
Pair(T value1,
T value2)
Creates a Pair from the specified elements. |
|
| Method Summary | ||
|---|---|---|
boolean |
add(T o)
|
|
boolean |
addAll(Collection<? extends T> c)
|
|
void |
clear()
|
|
boolean |
contains(Object o)
|
|
boolean |
containsAll(Collection<?> c)
|
|
boolean |
equals(Object o)
|
|
T |
getFirst()
Returns the first element. |
|
T |
getSecond()
Returns the second element. |
|
int |
hashCode()
|
|
boolean |
isEmpty()
|
|
Iterator<T> |
iterator()
|
|
boolean |
remove(Object o)
|
|
boolean |
removeAll(Collection<?> c)
|
|
boolean |
retainAll(Collection<?> c)
|
|
int |
size()
|
|
Object[] |
toArray()
|
|
|
toArray(S[] a)
|
|
String |
toString()
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Pair(T value1,
T value2)
Pair from the specified elements.
value1 - the first value in the new Pairvalue2 - the second value in the new Pair
IllegalArgumentException - if either argument is nullpublic Pair(Collection<? extends T> values)
values - the elements of the new Pair
IllegalArgumentException - if the input collection is null,
contains null values, or has != 2 elements.public Pair(T[] values)
Pair from the passed array.
The size of the array must be 2.
IllegalArgumentException - if the input array is null,
contains null values, or has != 2 elements.| Method Detail |
|---|
public T getFirst()
public T getSecond()
public boolean equals(Object o)
equals in interface Collection<T>equals in class Objectpublic int hashCode()
hashCode in interface Collection<T>hashCode in class Objectpublic String toString()
toString in class Objectpublic boolean add(T o)
add in interface Collection<T>public boolean addAll(Collection<? extends T> c)
addAll in interface Collection<T>public void clear()
clear in interface Collection<T>public boolean contains(Object o)
contains in interface Collection<T>public boolean containsAll(Collection<?> c)
containsAll in interface Collection<T>public boolean isEmpty()
isEmpty in interface Collection<T>public Iterator<T> iterator()
iterator in interface Iterable<T>iterator in interface Collection<T>public boolean remove(Object o)
remove in interface Collection<T>public boolean removeAll(Collection<?> c)
removeAll in interface Collection<T>public boolean retainAll(Collection<?> c)
retainAll in interface Collection<T>public int size()
size in interface Collection<T>public Object[] toArray()
toArray in interface Collection<T>public <S> S[] toArray(S[] a)
toArray in interface Collection<T>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||