Class Pair<A,​B>

  • Type Parameters:
    A - Type of first item
    B - Type of second item

    public final class Pair<A,​B>
    extends java.lang.Object
    A pair of objects.
    Since:
    429
    • Field Summary

      Fields 
      Modifier and Type Field Description
      A a
      The first item
      B b
      The second item
    • Constructor Summary

      Constructors 
      Constructor Description
      Pair​(A a, B b)
      Constructs a new Pair.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <U,​V>
      Pair<U,​V>
      create​(U u, V v)
      Convenient constructor method
      boolean equals​(java.lang.Object other)  
      int hashCode()  
      static <T> Pair<T,​T> sort​(Pair<T,​T> p)
      Sorts a single-typed pair so a <= b.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • a

        public A a
        The first item
      • b

        public B b
        The second item
    • Constructor Detail

      • Pair

        public Pair​(A a,
                    B b)
        Constructs a new Pair.
        Parameters:
        a - The first item
        b - The second item
    • Method Detail

      • hashCode

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

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • sort

        public static <T> Pair<T,​T> sort​(Pair<T,​T> p)
        Sorts a single-typed pair so a <= b.
        Type Parameters:
        T - type of both elements
        Parameters:
        p - pair
        Returns:
        p
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • create

        public static <U,​V> Pair<U,​V> create​(U u,
                                                         V v)
        Convenient constructor method
        Type Parameters:
        U - type of first item
        V - type of second item
        Parameters:
        u - The first item
        v - The second item
        Returns:
        The newly created Pair(u,v)