Package com.groiss.ds

Class Pair<F,S>

java.lang.Object
com.groiss.ds.Pair<F,S>
All Implemented Interfaces:
KeyValuePair<F,S>, Serializable
Direct Known Subclasses:
ComparablePair, Parameter

public class Pair<F,S> extends Object implements KeyValuePair<F,S>, Serializable
A Pair is an object that contains two other objects. It is most commonly used for conveniently storing and passing pairs of objects.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The first object.
    The second object.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    Pair(F first, S second)
    Constructor for holding a pair of objects.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if obj is also a Pair and contains two objects equal to the two objects of this Pair.
    Return the first object
    Return the second object
    int
    Builds a new hash code out of the two objects' hash codes.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • first

      public F first
      The first object.
    • second

      public S second
      The second object.
  • Constructor Details

    • Pair

      public Pair()
    • Pair

      public Pair(F first, S second)
      Constructor for holding a pair of objects.
  • Method Details

    • getKey

      public F getKey()
      Return the first object
      Specified by:
      getKey in interface KeyValuePair<F,S>
    • getValue

      public S getValue()
      Return the second object
      Specified by:
      getValue in interface KeyValuePair<F,S>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Returns true if obj is also a Pair and contains two objects equal to the two objects of this Pair. null references are considered as equal, too.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Builds a new hash code out of the two objects' hash codes.
      Overrides:
      hashCode in class Object