This implementation refers to the elements as 'first' and 'second'. The class also implements the {@code Map.Entry} interface where the key is 'first'and the value is 'second'.
Although the implementation is immutable, there is no restriction on the objects that may be stored. If mutable objects are stored in the pair, then the pair itself effectively becomes mutable. @param < A> the first element type @param < B> the second element type
Generic Immutable Pair class if an ad-hoc set of fields need to be passed around together
Also, this is why Java is such a manly language. Every programmer must grow a Pair!
@param < A> The type of the first field in the pair. @param < B> The type of the second field in the pairCollection
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.
Pair
class, a subclass of AbstractScoreSlot
, is a score slot type that is meant to contain the score from the "Pair" combination of the Yahtzee dice game.
@author Priidu Neemre
A pair consisting of two elements.
This class is an abstract implementation defining the basic API. It refers to the elements as 'left' and 'right'. It also implements the {@code Map.Entry} interface where the key is 'left' and the value is 'right'.
Subclass implementations may be mutable or immutable. However, there is no restriction on the type of the stored objects that may be stored. If mutable objects are stored in the pair, then the pair itself effectively becomes mutable.
@param < L> the left element type @param < R> the right element type @since Lang 3.0 @version $Id: Pair.java 1436770 2013-01-22 07:09:45Z ggregory $Because a pair implements {@link #equals(Object)}, {@link #hashCode()} and{@link #compareTo(Pair)}, it can be used in any kind of {@link java.util.Collection}.
A tuple of two elements.
@since 1.0 @author Daniel Fernández
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|