Pair
public class Pair<F, S>
Container to ease passing around a tuple of two objects. This object provides a sensible implementation of equals(), returning true if equals() is true on each of the contained objects.
Summary
Public constructors |
|---|
Pair(F first, S second)Constructor for a Pair. |
Public methods |
|
|---|---|
static @NonNull Pair<A, B> |
<A, B> create(A a, B b)Convenience method for creating an appropriately typed pair. |
boolean |
Checks the two objects for equality by delegating to their respective |
int |
hashCode()Compute a hash code using the hash codes of the underlying objects |
@NonNull String |
toString() |
Extension functions |
|
|---|---|
final @NonNull F |
<F extends Object, S extends Object> PairKt.component1(Returns the first component of the pair. |
final @NonNull S |
<F extends Object, S extends Object> PairKt.component2(Returns the second component of the pair. |
final @NonNull Pair<@NonNull F, @NonNull S> |
<F extends Object, S extends Object> PairKt.toKotlinPair(Returns this |
Public constructors
Public methods
create
public static @NonNull Pair<A, B> <A, B> create(A a, B b)
Convenience method for creating an appropriately typed pair.
| Parameters | |
|---|---|
A a |
the first object in the Pair |
B b |
the second object in the pair |
equals
public boolean equals(Object o)
Checks the two objects for equality by delegating to their respective equals methods.
| Returns | |
|---|---|
boolean |
true if the underlying objects of the Pair are both considered equal |
hashCode
public int hashCode()
Compute a hash code using the hash codes of the underlying objects
| Returns | |
|---|---|
int |
a hashcode of the Pair |
Extension functions
PairKt.component1
public final @NonNull F <F extends Object, S extends Object> PairKt.component1(
@NonNull Pair<@NonNull F, @NonNull S> receiver
)
Returns the first component of the pair.
This method allows to use destructuring declarations when working with pairs, for example:
val (first, second) = myPair
PairKt.component2
public final @NonNull S <F extends Object, S extends Object> PairKt.component2(
@NonNull Pair<@NonNull F, @NonNull S> receiver
)
Returns the second component of the pair.
This method allows to use destructuring declarations when working with pairs, for example:
val (first, second) = myPair
PairKt.toKotlinPair
public final @NonNull Pair<@NonNull F, @NonNull S> <F extends Object, S extends Object> PairKt.toKotlinPair(
@NonNull Pair<@NonNull F, @NonNull S> receiver
)
Returns this AndroidX as a PairKotlin .Pair