Class Pair<E,​F>

java.lang.Object
org.tweetyproject.commons.util.Pair<E,​F>
Type Parameters:
E - the type of the first element
F - the type of the second element
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Division

public class Pair<E,​F> extends Object implements Serializable
This class implements a simple pair of elements.
Author:
Matthias Thimm, Bastian Wolf
See Also:
Serialized Form
  • Constructor Summary

    Constructors
    Constructor
    Description
    Initializes an empty pair.
    Pair​(E obj1, F obj2)
    Initializes the elements of this pair with the given parameters
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals​(Object obj)
     
    returns the first element of this pair
    returns the second element of this pair
    int
     
    void
    setFirst​(E obj1)
    sets the first element of this pair
    void
    setSecond​(F obj2)
    sets the second element of this pair
    returns a string representation of a pair as "(obj1, obj2)"

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Pair

      public Pair()
      Initializes an empty pair.
    • Pair

      public Pair(E obj1, F obj2)
      Initializes the elements of this pair with the given parameters
      Parameters:
      obj1 - the first element of this pair
      obj2 - the second element of this pair
  • Method Details

    • getFirst

      public E getFirst()
      returns the first element of this pair
      Returns:
      the first element of this pair
    • setFirst

      public void setFirst(E obj1)
      sets the first element of this pair
      Parameters:
      obj1 - an object of type E
    • getSecond

      public F getSecond()
      returns the second element of this pair
      Returns:
      the second element of this pair
    • setSecond

      public void setSecond(F obj2)
      sets the second element of this pair
      Parameters:
      obj2 - an object of type F
    • hashCode

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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      returns a string representation of a pair as "(obj1, obj2)"
      Overrides:
      toString in class Object
      Returns:
      a string representation of a pair as "(obj1, obj2)"