Class MPair<V1,V2>

java.lang.Object
org.plumelib.util.MPair<V1,V2>
Type Parameters:
V1 - the type of the first element of the pair
V2 - the type of the second element of the pair

public class MPair<V1,V2> extends Object
Mutable pair class.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The first element of the pair.
    The second element of the pair.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T1 extends Cloneable, T2 extends Cloneable>
    MPair<T1,T2>
    cloneElements(MPair<T1,T2> orig)
    Returns a copy of this in which each element is a clone of the corresponding element of this.
    static <T1 extends DeepCopyable<T1>, T2 extends DeepCopyable<T2>>
    MPair<T1,T2>
    deepCopy(MPair<T1,T2> orig)
    Returns a deep copy of this: each element is a deep copy (according to the DeepCopyable interface) of the corresponding element of this.
    static <T1 extends DeepCopyable<T1>, T2>
    MPair<T1,T2>
    deepCopyFirst(MPair<T1,T2> orig)
    Returns a copy, where the first element is deep: the first element is a deep copy (according to the DeepCopyable interface), and the second element is identical to the argument.
    static <T1, T2 extends DeepCopyable<T2>>
    MPair<T1,T2>
    deepCopySecond(MPair<T1,T2> orig)
    Returns a copy, where the second element is deep: the first element is identical to the argument, and the second element is a deep copy (according to the DeepCopyable interface).
    boolean
    equals(@GuardSatisfied @Nullable Object obj)
     
    int
     
    static <T1, T2> MPair<T1,T2>
    of(T1 first, T2 second)
    Creates a new mutable pair.
     

    Methods inherited from class java.lang.Object

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

    • first

      public V1 first
      The first element of the pair.
    • second

      public V2 second
      The second element of the pair.
  • Method Details

    • of

      public static <T1, T2> MPair<T1,T2> of(T1 first, T2 second)
      Creates a new mutable pair.
      Type Parameters:
      T1 - type of first argument
      T2 - type of second argument
      Parameters:
      first - first argument
      second - second argument
      Returns:
      a pair of the values (first, second)
    • cloneElements

      public static <T1 extends Cloneable, T2 extends Cloneable> MPair<T1,T2> cloneElements(MPair<T1,T2> orig)
      Returns a copy of this in which each element is a clone of the corresponding element of this. clone() may or may not itself make a deep copy of the elements.
      Type Parameters:
      T1 - the type of the first element of the pair
      T2 - the type of the second element of the pair
      Parameters:
      orig - a pair
      Returns:
      a copy of orig, with all elements cloned
    • deepCopy

      public static <T1 extends DeepCopyable<T1>, T2 extends DeepCopyable<T2>> MPair<T1,T2> deepCopy(MPair<T1,T2> orig)
      Returns a deep copy of this: each element is a deep copy (according to the DeepCopyable interface) of the corresponding element of this.
      Type Parameters:
      T1 - the type of the first element of the pair
      T2 - the type of the second element of the pair
      Parameters:
      orig - a pair
      Returns:
      a deep copy of orig
    • deepCopyFirst

      public static <T1 extends DeepCopyable<T1>, T2> MPair<T1,T2> deepCopyFirst(MPair<T1,T2> orig)
      Returns a copy, where the first element is deep: the first element is a deep copy (according to the DeepCopyable interface), and the second element is identical to the argument.
      Type Parameters:
      T1 - the type of the first element of the pair
      T2 - the type of the second element of the pair
      Parameters:
      orig - a pair
      Returns:
      a copy of orig, where the first element is a deep copy
    • deepCopySecond

      public static <T1, T2 extends DeepCopyable<T2>> MPair<T1,T2> deepCopySecond(MPair<T1,T2> orig)
      Returns a copy, where the second element is deep: the first element is identical to the argument, and the second element is a deep copy (according to the DeepCopyable interface).
      Type Parameters:
      T1 - the type of the first element of the pair
      T2 - the type of the second element of the pair
      Parameters:
      orig - a pair
      Returns:
      a copy of orig, where the second element is a deep copy
    • equals

      @Pure public boolean equals(@GuardSatisfied MPair<V1,V2> this, @GuardSatisfied @Nullable Object obj)
      Overrides:
      equals in class Object
    • hashCode

      @Pure public int hashCode(@GuardSatisfied MPair<V1,V2> this)
      Overrides:
      hashCode in class Object
    • toString

      @SideEffectFree public String toString(@GuardSatisfied MPair<V1,V2> this)
      Overrides:
      toString in class Object