S - type of first entryT - type of second entrypublic class OrderedPair<S,T> extends java.lang.Object implements java.util.Map.Entry<S,T>, ITuple2<S,T>
Useful for temporary packing.
It implements also Map.Entry, and will return the first value as key and the second value as value.
Obviously it will not allow setting to the underlying map.
ITuple2.Base<T1,T2>| Modifier and Type | Field and Description |
|---|---|
S |
first
The first element.
|
T |
second
The second element.
|
| Constructor and Description |
|---|
OrderedPair(S first,
T second)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
S |
_1()
Get the first element.
|
T |
_2()
Get the second element.
|
static <U,V> OrderedPair<U,V> |
create(java.util.Map.Entry<U,V> mapEntry)
Create an ordered pair from a map entry.
|
static <U,V> OrderedPair<U,V> |
create(U firstValue,
V secondValue)
Create an ordered pair from two values.
|
boolean |
equals(java.lang.Object o)
Is this pair equal to another?
|
static <U extends java.lang.Comparable<U>,V> |
getFirstEntryOrderedPairComparator()
Get a comparator which compares the first entries of ordered pairs using their natural order.
|
static <U,V> java.util.Comparator<OrderedPair<U,V>> |
getFirstEntryOrderedPairComparator(java.util.Comparator<U> comparator)
Get a comparator which compares the first entries of ordered pairs using a comparator.
|
S |
getKey()
Returns the key corresponding to this entry.
|
static <U,V extends java.lang.Comparable<V>> |
getSecondEntryOrderedPairComparator()
Get a comparator which compares the second entries of ordered pairs using their natural order.
|
static <U,V> java.util.Comparator<OrderedPair<U,V>> |
getSecondEntryOrderedPairComparator(java.util.Comparator<V> comparator)
Get a comparator which compares the second entries of ordered pairs using a comparator.
|
T |
getValue()
Returns the value corresponding to this entry.
|
int |
hashCode()
Get a hash code.
|
T |
setValue(T value)
Replaces the value corresponding to this entry with the specified
value (optional operation).
|
OrderedPair<T,S> |
swapped()
Get a ordered pair with inverted order.
|
java.lang.String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitcomparingByKey, 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, viewpublic S getKey()
public T getValue()
public T setValue(T value)
setValue in interface java.util.Map.Entry<S,T>value - new value to be stored in this entry.java.lang.UnsupportedOperationException - if the put operation
is not supported by the backing map.java.lang.ClassCastException - if the class of the specified value
prevents it from being stored in the backing map.java.lang.IllegalArgumentException - if some aspect of this value
prevents it from being stored in the backing map.java.lang.NullPointerException - if the backing map does not permit
null values, and the specified value is
null.java.lang.IllegalStateException - implementations may, but are not
required to, throw this exception if the entry has been
removed from the backing mappublic boolean equals(java.lang.Object o)
public int hashCode()
@NotNull public OrderedPair<T,S> swapped()
public java.lang.String toString()
toString in class java.lang.Object@NotNull public static <U extends java.lang.Comparable<U>,V> java.util.Comparator<OrderedPair<U,V>> getFirstEntryOrderedPairComparator()
U - first entry typeV - second entry type@NotNull public static <U,V> java.util.Comparator<OrderedPair<U,V>> getFirstEntryOrderedPairComparator(java.util.Comparator<U> comparator)
U - first entry typeV - second entry typecomparator - comparator for first entry@NotNull public static <U,V extends java.lang.Comparable<V>> java.util.Comparator<OrderedPair<U,V>> getSecondEntryOrderedPairComparator()
U - first entry typeV - second entry type@NotNull public static <U,V> java.util.Comparator<OrderedPair<U,V>> getSecondEntryOrderedPairComparator(java.util.Comparator<V> comparator)
U - first entry typeV - second entry typecomparator - comparator for first entry@NotNull public static <U,V> OrderedPair<U,V> create(U firstValue, V secondValue)
U - first value typeV - second value typefirstValue - first valuesecondValue - second value@NotNull public static <U,V> OrderedPair<U,V> create(java.util.Map.Entry<U,V> mapEntry)
U - first value (map key) typeV - second value (map value) typemapEntry - map entry