FileDocCategorySizeDatePackage
Pair.javaAPI DocAndroid 5.1 API2517Thu Mar 12 22:22:56 GMT 2015android.support.v4.util

Pair

public class Pair extends Object
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.

Fields Summary
public final F
first
public final S
second
Constructors Summary
public Pair(F first, S second)
Constructor for a Pair.

param
first the first object in the Pair
param
second the second object in the pair

        this.first = first;
        this.second = second;
    
Methods Summary
public static android.support.v4.util.Paircreate(A a, B b)
Convenience method for creating an appropriately typed pair.

param
a the first object in the Pair
param
b the second object in the pair
return
a Pair that is templatized with the types of a and b

        return new Pair<A, B>(a, b);
    
public booleanequals(java.lang.Object o)
Checks the two objects for equality by delegating to their respective {@link Object#equals(Object)} methods.

param
o the {@link Pair} to which this one is to be checked for equality
return
true if the underlying objects of the Pair are both considered equal

        if (!(o instanceof Pair)) {
            return false;
        }
        Pair<?, ?> p = (Pair<?, ?>) o;
        return objectsEqual(p.first, first) && objectsEqual(p.second, second);
    
public inthashCode()
Compute a hash code using the hash codes of the underlying objects

return
a hashcode of the Pair

        return (first == null ? 0 : first.hashCode()) ^ (second == null ? 0 : second.hashCode());
    
private static booleanobjectsEqual(java.lang.Object a, java.lang.Object b)

        return a == b || (a != null && a.equals(b));