public class Pair<T> extends OrderedPair<T,T> implements java.lang.Iterable<T>
ITuple2.Base<T1,T2>
first, second
Modifier and Type | Method and Description |
---|---|
static <U> Pair<U> |
createPair(U f,
U s)
Create a pair from two items.
|
T |
get(int index)
Get the first or second parameter via its index.
|
static <S extends java.lang.Comparable<S>> |
getFirstEntryPairComparator()
Get a comparator which compares the first entries of pairs using their natural order.
|
static <S> java.util.Comparator<Pair<S>> |
getFirstEntryPairComparator(java.util.Comparator<S> comparator)
Get a comparator which compares the first entries of pairs using a comparator.
|
static <S extends java.lang.Comparable<S>> |
getFirstThanSecondEntryPairComparator()
Get a comparator which compares the first entries of two pairs using their natural order.,
and then the second entries of the pairs if the first are equal.
|
static <S> java.util.Comparator<Pair<S>> |
getFirstThanSecondEntryPairComparator(java.util.Comparator<S> comparator)
Get a comparator which compares the first entries of two pairs,
and then the second entries of the pairs if the first are equal.
|
static <S extends java.lang.Comparable<S>> |
getSecondEntryPairComparator()
Get a comparator which compares the first entries of pairs using their natural order.
|
static <S> java.util.Comparator<Pair<S>> |
getSecondEntryPairComparator(java.util.Comparator<S> comparator)
Get a comparator which compares the second entries of pairs using a comparator.
|
java.util.Iterator<T> |
iterator()
Returns an iterator over this pair.
|
(package private) void |
orderBy(Ordering<? super T> ordering)
Order the elements in this pair.
|
void |
set(int index,
T item)
Set the first or second parameter via its index.
|
void |
swap()
Exchange first and second.
|
_1, _2, create, create, equals, getFirstEntryOrderedPairComparator, getFirstEntryOrderedPairComparator, getKey, getSecondEntryOrderedPairComparator, getSecondEntryOrderedPairComparator, getValue, hashCode, setValue, swapped, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
comparingByKey, comparingByKey, comparingByValue, comparingByValue
_21, asBase, concat1, concat2, concat3, concat4, concat5, concat6, concat7, concat8, concatPred1, concatPred2, concatPred3, concatPred4, concatPred5, concatPred6, concatPred7, concatPred8, concatProc1, concatProc2, concatProc3, concatProc4, concatProc5, concatProc6, concatProc7, concatProc8, equals, frozen, frozenNotNull, hash, invoke, sendTo, testBy, toString, toString, view
void orderBy(@NotNull Ordering<? super T> ordering)
ordering
- ordering to apply@NotNull public java.util.Iterator<T> iterator()
iterator
in interface java.lang.Iterable<T>
public void swap()
public T get(int index)
index
- either 0
or 1
index
is 0
the first entry,
if index
is 1
the second entrypublic void set(int index, T item)
index
- either 0
or 1
item
- new first if index
is 0
,
new second if index
is 1
public static <S extends java.lang.Comparable<S>> java.util.Comparator<Pair<S>> getFirstEntryPairComparator()
S
- pair entry type (comparable)@NotNull public static <S> java.util.Comparator<Pair<S>> getFirstEntryPairComparator(@NotNull java.util.Comparator<S> comparator)
S
- pair entry typecomparator
- comparator for inner elements@NotNull public static <S extends java.lang.Comparable<S>> java.util.Comparator<Pair<S>> getSecondEntryPairComparator()
S
- pair entry type (comparable)@NotNull public static <S> java.util.Comparator<Pair<S>> getSecondEntryPairComparator(@NotNull java.util.Comparator<S> comparator)
S
- pair entry typecomparator
- comparator for inner elements@NotNull public static <S extends java.lang.Comparable<S>> java.util.Comparator<Pair<S>> getFirstThanSecondEntryPairComparator()
S
- pair entry type (comparable)@NotNull public static <S> java.util.Comparator<Pair<S>> getFirstThanSecondEntryPairComparator(@NotNull java.util.Comparator<S> comparator)
S
- pair entry type (comparable)comparator
- comparator for inner elements