diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-02-29 09:27:10 -0500 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-02-29 09:27:10 -0500 |
| commit | b3eb57f0796ef79f58ed76a1baf1cdb315772b6a (patch) | |
| tree | 3fb54b1b7c97d75ed64b1187becd20f7cedcf4f7 /BJC-Utils2/src/main/java/bjc/utils/data/IPair.java | |
| parent | 25959ffced5eb4e239610e79f05c1774e54ec29c (diff) | |
Factored interface out of Pair
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/IPair.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/data/IPair.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/IPair.java b/BJC-Utils2/src/main/java/bjc/utils/data/IPair.java new file mode 100644 index 0000000..9da7d22 --- /dev/null +++ b/BJC-Utils2/src/main/java/bjc/utils/data/IPair.java @@ -0,0 +1,33 @@ +package bjc.utils.data; + +import java.util.function.BiConsumer; +import java.util.function.BiFunction; +import java.util.function.Function; + +public interface IPair<L, R> { + + /** + * Create a new pair by applying the given functions to the left/right. + * Does not change the internal contents of this 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. + */ + <L2, R2> IPair<L2, R2> apply(Function<L, L2> lf, Function<R, R2> rf); + + /** + * Collapse this pair to a single value. Does not change the internal + * contents of this pair. + * + * @param bf + * The function to use to collapse the pair. + * @return The collapsed value. + */ + <E> E merge(BiFunction<L, R, E> bf); + + void doWith(BiConsumer<L, R> bc); + +}
\ No newline at end of file |
