diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-05-10 21:58:08 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-05-10 21:58:08 -0400 |
| commit | fff6dc5d43539af05ae2679640240b8545b36947 (patch) | |
| tree | 89dc91bdc013415b76351a22126bffe86a750d7d /BJC-Utils2/src/main/java/bjc/utils/data/BoundLazyPair.java | |
| parent | 507f506093c84ae764d0c26b24d9d055e8613aae (diff) | |
Added interface to JDK collector API
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/BoundLazyPair.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/data/BoundLazyPair.java | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/BoundLazyPair.java b/BJC-Utils2/src/main/java/bjc/utils/data/BoundLazyPair.java index 1635e06..dcf9cca 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/BoundLazyPair.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/BoundLazyPair.java @@ -26,8 +26,8 @@ class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> @Override public <BoundLeft, BoundRight> IPair<BoundLeft, BoundRight> bind( BiFunction<NewLeft, NewRight, IPair<BoundLeft, BoundRight>> bindr) { - IHolder<IPair<NewLeft, NewRight>> newPair = new Identity<>( - boundPair); + IHolder<IPair<NewLeft, NewRight>> newPair = + new Identity<>(boundPair); IHolder<Boolean> newPairMade = new Identity<>(pairBound); Supplier<NewLeft> leftSupp = () -> { @@ -93,8 +93,8 @@ class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> public <MergedType> MergedType merge(BiFunction<NewLeft, NewRight, MergedType> merger) { if (!pairBound) { - boundPair = binder.apply(leftSupplier.get(), - rightSupplier.get()); + boundPair = + binder.apply(leftSupplier.get(), rightSupplier.get()); pairBound = true; } @@ -166,4 +166,19 @@ class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> return new LazyPair<>(leftSupp, rightSupp); } + + @Override + public <OtherLeft, OtherRight, CombinedLeft, CombinedRight> + IPair<CombinedLeft, CombinedRight> + combine(IPair<OtherLeft, OtherRight> otherPair, + BiFunction<NewLeft, OtherLeft, CombinedLeft> leftCombiner, + BiFunction<NewRight, OtherRight, CombinedRight> rightCombiner) { + return otherPair.bind((otherLeft, otherRight) -> { + return bind((leftVal, rightVal) -> { + return new LazyPair<>( + leftCombiner.apply(leftVal, otherLeft), + rightCombiner.apply(rightVal, otherRight)); + }); + }); + } }
\ No newline at end of file |
