package bjc.utils.data; import java.util.function.BiConsumer; import java.util.function.BiFunction; import java.util.function.Function; /** * 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 { /** * Create a new pair by applying the given functions to the left/right. * Does not change the internal contents of this pair. * * @param * The new left type of the pair * @param * The new right type of the pair * * @param lf * The function to apply to the left value. * @param rf * The function to apply to the right value. * @return A new pair containing the two modified values. */ public IPair apply(Function lf, Function rf); /** * Execute an action with the values of this pair. Has no effect on the * internal contents * * @param bc * The action to execute on the values */ public void doWith(BiConsumer bc); /** * Collapse this pair to a single value. Does not change the internal * contents of this pair. * * @param * The resulting type after merging * * @param bf * The function to use to collapse the pair. * @return The collapsed value. */ public E merge(BiFunction bf); }