Class Pair<X,​Y>

  • Direct Known Subclasses:
    SimpleWrapper

    public class Pair<X,​Y>
    extends Object
    A simple pair class that represents a tuple with two elements.

    This class is not implemented to handle null pair values, however it will accept them.

    Version:
    $Revision: 1.1 $ $Date: 2005/12/21 22:25:35 $
    • Constructor Summary

      Constructors 
      Constructor Description
      Pair​(X first, Y second)
      Constructs this class with the specified first and second values
    • Constructor Detail

      • Pair

        public Pair​(X first,
                    Y second)
        Constructs this class with the specified first and second values
        Parameters:
        first - the first value
        second - the second value
    • Method Detail

      • equals

        public boolean equals​(Object obj)
        Compares this pair to another object.
        Overrides:
        equals in class Object
        Returns:
        if the other object is a pair with the same first and second members
      • hashCode

        public int hashCode()
        Returns a hashCode of this objects first and second elements xor'd.
        Overrides:
        hashCode in class Object
        Returns:
        first.hashCode() ^ second.hashCode
      • getFirst

        public X getFirst()
        Retrieves the first element in the tuple (first, second).
        Returns:
        the first element
      • getSecond

        public Y getSecond()
        Retrieves the second element in the tuple (first, second).
        Returns:
        the second element
      • setFirst

        public void setFirst​(X first)
        Sets the first element in the tuple (first, second).
        Parameters:
        first - the first element
      • setSecond

        public void setSecond​(Y second)
        Sets the second element in the tuple (first, second).
        Parameters:
        second - the second element