Class Pair<T1,T2>

java.lang.Object
com.amalgamasimulation.utils.Pair<T1,T2>
Type Parameters:
T1 - type of the first element
T2 - type of the second element

public class Pair<T1,T2> extends Object
Class representing a pair of elements of the specified types. first and second are public fields of this class allowing the direct access to the contents of the pair.
Author:
Andrey Malykhanov
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    First element of this pair
    Second element of this pair
  • Constructor Summary

    Constructors
    Constructor
    Description
    Pair(T1 first, T2 second)
    Creates a new pair consisting of the specified elements
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    Returns the first element of this pair
    int
     
    static <T1, T2> Pair<T1,T2>
    of(T1 first, T2 second)
    Creates and returns a new pair consisting of the specified elements
    Returns the second element of this pair
     

    Methods inherited from class java.lang.Object

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

    • first

      public T1 first
      First element of this pair
    • second

      public T2 second
      Second element of this pair
  • Constructor Details

    • Pair

      public Pair(T1 first, T2 second)
      Creates a new pair consisting of the specified elements
      Parameters:
      first - first element of this pair
      second - second element of this pair
  • Method Details

    • of

      public static <T1, T2> Pair<T1,T2> of(T1 first, T2 second)
      Creates and returns a new pair consisting of the specified elements
      Parameters:
      first - first element of this pair
      second - second element of this pair
    • first

      public T1 first()
      Returns the first element of this pair
      Returns:
      first element of this pair
    • second

      public T2 second()
      Returns the second element of this pair
      Returns:
      second element of this pair
    • toString

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

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

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