fj.data.fingertrees.One Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of functionaljava Show documentation
Show all versions of functionaljava Show documentation
Functional Java is an open source library that supports closures for the Java programming language
package fj.data.fingertrees;
import fj.F;
import fj.P;
import fj.P2;
import fj.P3;
import fj.data.Option;
import static fj.data.Option.none;
/**
* A single-element prefix or suffix of a finger tree.
*/
public final class One extends Digit {
private final A a;
One(final Measured m, final A a) {
super(m);
this.a = a;
}
public B foldRight(final F> aff, final B z) {
return aff.f(a).f(z);
}
public B foldLeft(final F> bff, final B z) {
return bff.f(z).f(a);
}
@Override public B match(
final F, B> one, final F, B> two, final F, B> three,
final F, B> four) {
return one.f(this);
}
/**
* Returns the single element in this digit.
*
* @return the single element in this digit.
*/
public A value() {
return a;
}
@Override P3