Class MutablePair<T,U>

java.lang.Object
com.yetnt.utils.tuple.MutablePair<T,U>
Type Parameters:
T - The type of the first element
U - The type of the second element

public class MutablePair<T,U> extends Object
A mutable version of Pair

From J3Engine

Author:
Lehlogonolo Poole
  • Field Details

    • first

      private T first
    • second

      private U second
  • Constructor Details

    • MutablePair

      public MutablePair(T first, U second)
      Constructs a new MutablePair
      Parameters:
      first - The first value
      second - The second value
  • Method Details

    • getFirst

      public T getFirst()
      Gets the first value
      Returns:
      The first value
    • getSecond

      public U getSecond()
      Gets the second value
      Returns:
      The second value
    • setFirst

      public void setFirst(T first)
      Sets the first value
      Parameters:
      first - The new value
    • setSecond

      public void setSecond(U second)
      Sets the second value
      Parameters:
      second - The new value
    • freeze

      public Pair<T,U> freeze()
      Creates a pair of the first and second value, effectively "freezing" them.

      This is similar to calling

      
           MutablePair<T, U> mut = ...;
           Pair<T, U> pair1 = new Pair<>(mut);                              // using constructor
           Pair<T, U> pair2 = new Pair<>(mut.getFirst(), mut.getSecond());  // using values directly
           

      Returns:
      A new pair