package bjc.utils.data; import java.util.function.BiConsumer; import java.util.function.BiFunction; /** * An interface representing a pair of values * * @author ben * * @param * The type stored in the left side of the pair * @param * The type stored in the right side of the pair */ public interface IPair { /** * Apply a function to the two internal values that returns a new pair. * * Is a monadic bind. * * @param * The new left pair type * @param * The new right pair type * @param binder * The function to use as a bind * @return The new pair */ public IPair bind( BiFunction> binder); /** * Execute an action with the values of this pair. Has no effect on the * internal contents * * @param action * The action to execute on the values */ public void doWith(BiConsumer action); /** * Collapse this pair to a single value. Does not change the internal * contents of this pair. * * @param * The resulting type after merging * * @param merger * The function to use to collapse the pair. * @return The collapsed value. */ public E merge(BiFunction merger); }