Class Pair<A,​B>

    • Field Detail

      • first

        protected A first
        The first pair element
      • second

        protected B second
        The second pair element
    • Constructor Detail

      • Pair

        public Pair​(A a,
                    B b)
        Create a new pair
        Parameters:
        a - the first element
        b - the second element
    • Method Detail

      • getFirst

        public A getFirst()
        Get the first element of the pair
        Returns:
        the first element of the pair
      • getSecond

        public B getSecond()
        Get the second element of the pair
        Returns:
        the second element of the pair
      • setFirst

        public void setFirst​(A f)
        Set the first element of the pair.
        Parameters:
        f - the element to be assigned.
      • setSecond

        public void setSecond​(B s)
        Set the second element of the pair.
        Parameters:
        s - the element to be assigned.
      • hasElement

        public <E> boolean hasElement​(E e)
        Assess if this pair contains an element.
        Type Parameters:
        E - the element type
        Parameters:
        e - The element in question
        Returns:
        true if contains the element, false otherwise
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • of

        public static <A,​B> Pair<A,​B> of​(A a,
                                                     B b)
        Create a new pair.
        Type Parameters:
        A - the first element type
        B - the second element type
        Parameters:
        a - first element
        b - second element
        Returns:
        new pair