Package ghidra.util.datastruct

# Class Duo<T>

java.lang.Object
ghidra.util.datastruct.Duo<T>

Type Parameters:
  `T` - The type of item that is stored in this Duo.

public class Duo<T> extends Object
Class for holding two objects of the same type. We are using the idiom of LEFT and RIGHT to refer to each item in this pair of objects. The enum "Side" is used to represent either the LEFT (or first) or RIGHT (or second) item.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `Duo.Side`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Duo()`
  Constructor with no values.
  `Duo(T left, T right)`
  Constructor with a left and right value.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `each(Consumer<T> c)`
  Invokes the given consumer on both the left and right values.
  `boolean`
  `equals(Object obj)`
  `boolean`
  `equals(T otherLeft, T otherRight)`
  Returns true if both values are equals to this objects values.
  `T`
  `get(Duo.Side side)`
  Gets the value for the given side.
  `int`
  `hashCode()`
  `Duo<T>`
  `with(Duo.Side side, T newValue)`
  Creates a new Duo, replacing the value for just one side.

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Duo

    public Duo()
    Constructor with no values.

  - ### Duo

    public Duo(T left, T right)
    Constructor with a left and right value.
    Parameters:
      `left` - the left value
      `right` - the right value

- ## Method Details

  - ### get

    public T get(Duo.Side side)
    Gets the value for the given side.
    Parameters:
      `side` - LEFT or RIGHT
    Returns:
      the value for the given side

  - ### with

    public Duo<T> with(Duo.Side side, T newValue)
    Creates a new Duo, replacing the value for just one side. The other side uses the value from this Duo.
    Parameters:
      `side` - the side that gets a new value
      `newValue` - the new value for the given side
    Returns:
      the new Duo value as this

  - ### each

    public void each(Consumer<T> c)
    Invokes the given consumer on both the left and right values.
    Parameters:
      `c` - the consumer to invoke on both values

  - ### equals

    public boolean equals(T otherLeft, T otherRight)
    Returns true if both values are equals to this objects values.
    Parameters:
      `otherLeft` - the value to compare to our left side value
      `otherRight` - the value to compare to our right side value
    Returns:
      true if both values are equals to this objects values

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### equals

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