summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/data
diff options
context:
space:
mode:
authorbculkin2442 <bjculkin@mix.wvu.edu>2016-07-28 11:00:25 -0400
committerbculkin2442 <bjculkin@mix.wvu.edu>2016-07-28 11:00:25 -0400
commitdf972ae7dbdf051268c5cf7754e07c504524b197 (patch)
tree7eb3f7adbccbb64d734e5ec59fcde9d49f7650f1 /BJC-Utils2/src/main/java/bjc/utils/data
parentfd0a1a0a63818fc1098b01b561c636457c1284ba (diff)
Note something to see if needs to be fixed later
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/data')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java7
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java24
2 files changed, 16 insertions, 15 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java b/BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java
index fb1a517..112a503 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java
@@ -16,13 +16,13 @@ import bjc.utils.funcdata.IList;
* @param <ContainedType>
*/
public class Lazy<ContainedType> implements IHolder<ContainedType> {
- private Supplier<ContainedType> valueSupplier;
+ private Supplier<ContainedType> valueSupplier;
private IList<UnaryOperator<ContainedType>> actions = new FunctionalList<>();
- private boolean valueMaterialized;
+ private boolean valueMaterialized;
- private ContainedType heldValue;
+ private ContainedType heldValue;
/**
* Create a new lazy value from the specified seed value
@@ -137,7 +137,6 @@ public class Lazy<ContainedType> implements IHolder<ContainedType> {
@Override
public <NewType> Function<ContainedType, IHolder<NewType>> lift(
Function<ContainedType, NewType> func) {
- // TODO Auto-generated method stub
return (val) -> {
return new Lazy<>(func.apply(val));
};
diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java b/BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java
index d688e5b..e0b39cc 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java
@@ -13,6 +13,9 @@ import java.util.function.Supplier;
* The type on the left side of the pair
* @param <RightType>
* The type on the right side of the pair
+ *
+ * @TODO ensure we don't have any issues with values being materialized
+ * more than once
*/
public class LazyPair<LeftType, RightType>
implements IPair<LeftType, RightType> {
@@ -115,8 +118,8 @@ public class LazyPair<LeftType, RightType>
}
@Override
- public <MergedType> MergedType
- merge(BiFunction<LeftType, RightType, MergedType> merger) {
+ public <MergedType> MergedType merge(
+ BiFunction<LeftType, RightType, MergedType> merger) {
if (!leftMaterialized) {
leftValue = leftSupplier.get();
@@ -156,8 +159,8 @@ public class LazyPair<LeftType, RightType>
}
@Override
- public <NewLeft> IPair<NewLeft, RightType>
- mapLeft(Function<LeftType, NewLeft> mapper) {
+ public <NewLeft> IPair<NewLeft, RightType> mapLeft(
+ Function<LeftType, NewLeft> mapper) {
Supplier<NewLeft> leftSupp = () -> {
if (leftMaterialized) {
return mapper.apply(leftValue);
@@ -178,8 +181,8 @@ public class LazyPair<LeftType, RightType>
}
@Override
- public <NewRight> IPair<LeftType, NewRight>
- mapRight(Function<RightType, NewRight> mapper) {
+ public <NewRight> IPair<LeftType, NewRight> mapRight(
+ Function<RightType, NewRight> mapper) {
Supplier<LeftType> leftSupp = () -> {
if (leftMaterialized) {
return leftValue;
@@ -200,11 +203,10 @@ public class LazyPair<LeftType, RightType>
}
@Override
- public <OtherLeft, OtherRight, CombinedLeft, CombinedRight>
- IPair<CombinedLeft, CombinedRight>
- combine(IPair<OtherLeft, OtherRight> otherPair,
- BiFunction<LeftType, OtherLeft, CombinedLeft> leftCombiner,
- BiFunction<RightType, OtherRight, CombinedRight> rightCombiner) {
+ public <OtherLeft, OtherRight, CombinedLeft, CombinedRight> IPair<CombinedLeft, CombinedRight> combine(
+ IPair<OtherLeft, OtherRight> otherPair,
+ BiFunction<LeftType, OtherLeft, CombinedLeft> leftCombiner,
+ BiFunction<RightType, OtherRight, CombinedRight> rightCombiner) {
return otherPair.bind((otherLeft, otherRight) -> {
return bind((leftVal, rightVal) -> {
return new LazyPair<>(