Package fj.data.fingertrees
Class Digit<V,A>
- java.lang.Object
-
- fj.data.fingertrees.Digit<V,A>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract <B> B
foldLeft(F<B,F<A,B>> f, B z)
Folds this digit to the left using the given function and the given initial value.abstract <B> B
foldRight(F<A,F<B,B>> f, B z)
Folds this digit to the right using the given function and the given initial value.(package private) Option<Digit<V,A>>
init()
abstract int
length()
abstract P2<java.lang.Integer,A>
lookup(F<V,java.lang.Integer> o, int i)
<B> Digit<V,B>
map(F<A,B> f, Measured<V,B> m)
Maps a function across the elements of this digit, measuring with the given measurement.abstract <B> B
match(F<One<V,A>,B> one, F<Two<V,A>,B> two, F<Three<V,A>,B> three, F<Four<V,A>,B> four)
Structural pattern matching on digits.V
measure()
Returns the sum of the measurements of this digit according to the monoid.(package private) Measured<V,A>
measured()
A
reduceLeft(F<A,F<A,A>> f)
Folds this digit to the right using the given function.A
reduceRight(F<A,F<A,A>> f)
Folds this digit to the right using the given function.(package private) abstract P3<Option<Digit<V,A>>,A,Option<Digit<V,A>>>
split1(F<V,java.lang.Boolean> predicate, V acc)
(package private) Option<Digit<V,A>>
tail()
abstract Stream<A>
toStream()
java.lang.String
toString()
FingerTree<V,A>
toTree()
Returns the tree representation of this digit.
-
-
-
Method Detail
-
foldRight
public abstract <B> B foldRight(F<A,F<B,B>> f, B z)
Folds this digit to the right using the given function and the given initial value.- Parameters:
f
- A function with which to fold this digit.z
- An initial value to apply at the rightmost end of the fold.- Returns:
- The right reduction of this digit with the given function and the given initial value.
-
foldLeft
public abstract <B> B foldLeft(F<B,F<A,B>> f, B z)
Folds this digit to the left using the given function and the given initial value.- Parameters:
f
- A function with which to fold this digit.z
- An initial value to apply at the leftmost end of the fold.- Returns:
- The left reduction of this digit with the given function and the given initial value.
-
reduceRight
public final A reduceRight(F<A,F<A,A>> f)
Folds this digit to the right using the given function.- Parameters:
f
- A function with which to fold this digit.- Returns:
- The right reduction of this digit with the given function.
-
reduceLeft
public final A reduceLeft(F<A,F<A,A>> f)
Folds this digit to the right using the given function.- Parameters:
f
- A function with which to fold this digit.- Returns:
- The right reduction of this digit with the given function.
-
map
public final <B> Digit<V,B> map(F<A,B> f, Measured<V,B> m)
Maps a function across the elements of this digit, measuring with the given measurement.- Parameters:
f
- A function to map across the elements of this digit.m
- A measuring for the function's domain (destination type).- Returns:
- A new digit with the same structure as this digit, but with all elements transformed with the given function and measured with the given measuring.
-
match
public abstract <B> B match(F<One<V,A>,B> one, F<Two<V,A>,B> two, F<Three<V,A>,B> three, F<Four<V,A>,B> four)
Structural pattern matching on digits. Applies the function that matches the structure of this digit.- Parameters:
one
- A function to apply to this digit if it's One.two
- A function to apply to this digit if it's Two.three
- A function to apply to this digit if it's Three.four
- A function to apply to this digit if it's Four.- Returns:
- The result of applying the function matching this Digit.
-
measure
public final V measure()
Returns the sum of the measurements of this digit according to the monoid.- Returns:
- the sum of the measurements of this digit according to the monoid.
-
toTree
public final FingerTree<V,A> toTree()
Returns the tree representation of this digit.- Returns:
- the tree representation of this digit.
-
split1
abstract P3<Option<Digit<V,A>>,A,Option<Digit<V,A>>> split1(F<V,java.lang.Boolean> predicate, V acc)
-
length
public abstract int length()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-