Class Pair<A,​B>

  • Type Parameters:
    A - the first type.
    B - the second type.

    public final class Pair<A,​B>
    extends Object
    Stores two related values. This data structure is very useful if an object must be passed with a property that is not part of that object. This class is based off of the C++ struct std::pair.
    • Constructor Detail

      • Pair

        public Pair​(A first,
                    B second)
        Constructs a new instance of Pair with the two values stored in the pair.
        Parameters:
        first - the first value.
        second - the second value.
      • Pair

        public Pair()
        Constructs a new instance of Pair without specifying the two values stored in the pair.
    • Method Detail

      • getFirst

        public A getFirst()
        Get the first value in the pair.
        Returns:
        the first value in the pair.
      • setFirst

        public void setFirst​(A newValue)
        Set the first value in the pair to the specified value.
        Parameters:
        newValue - the new first value.
      • getSecond

        public B getSecond()
        Get the second value in the pair.
        Returns:
        the second value in the pair.
      • setSecond

        public void setSecond​(B newValue)
        Set the second value in the pair to the specified value.
        Parameters:
        newValue - the new second value.
      • hashCode

        public int hashCode()
        Creates a hash code for this object.
        Overrides:
        hashCode in class Object
        Returns:
        a hash code for this object.