public class Pair<L,R> extends Object implements Comparable<Pair<L,R>>, Map.Entry<L,R>
Because a pair implements equals(Object)
, hashCode()
and
compareTo(Pair)
, it can be used in any kind of
Collection
.
Constructor and Description |
---|
Pair(L left,
R right)
Creates a pair.
|
Pair(Map.Entry<? extends L,? extends R> entry)
Creates a pair representing the same mapping as the
specified entry.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Pair<L,R> that) |
boolean |
equals(Object obj) |
L |
getKey() |
R |
getValue() |
int |
hashCode() |
static <L,R> List<L> |
left(List<Pair<L,R>> list)
Returns a list of the left elements of a list of pairs.
|
static <L,R> Iterable<L> |
leftIter(Iterable<Pair<L,R>> iterable)
Returns an iterable over the left slice of an iterable.
|
static <L,R> Pair<L,R> |
of(L left,
R right)
Creates a Pair.
|
static <L,R> List<R> |
right(List<Pair<L,R>> list)
Returns a list of the right elements of a list of pairs.
|
static <L,R> Iterable<R> |
rightIter(Iterable<Pair<L,R>> iterable)
Returns an iterable over the right slice of an iterable.
|
R |
setValue(R value) |
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
comparingByKey, comparingByKey, comparingByValue, comparingByValue
public static <L,R> Pair<L,R> of(L left, R right)
left
- Left valueright
- Right valuepublic boolean equals(Object obj)
public int hashCode()
public int compareTo(Pair<L,R> that)
compareTo
in interface Comparable<Pair<L,R>>
public static <L,R> Iterable<L> leftIter(Iterable<Pair<L,R>> iterable)
L
- Left typeR
- Right typeiterable
- Iterable over pairspublic static <L,R> Iterable<R> rightIter(Iterable<Pair<L,R>> iterable)
L
- right typeR
- Right typeiterable
- Iterable over pairspublic static <L,R> List<L> left(List<Pair<L,R>> list)
Copyright © 2018 Hitachi Vantara. All rights reserved.