Package fj.data.fingertrees
Class Empty<V,A>
- java.lang.Object
-
- fj.data.fingertrees.FingerTree<V,A>
-
- fj.data.fingertrees.Empty<V,A>
-
public final class Empty<V,A> extends FingerTree<V,A>
The empty tree.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FingerTree<V,A>append(FingerTree<V,A> t)Appends one finger tree to another.FingerTree<V,A>cons(A a)Adds the given element to this tree as the first element.<B> BfoldLeft(F<B,F<A,B>> bff, B z)Folds the tree to the left with the given function and the given initial element.<B> BfoldRight(F<A,F<B,B>> aff, B z)Folds the tree to the right with the given function and the given initial element.Ahead()The first element of this tree.FingerTree<V,A>init()The tree without the last element.Alast()The last element of this tree.intlength()P2<java.lang.Integer,A>lookup(F<V,java.lang.Integer> o, int i)<B> FingerTree<V,B>map(F<A,B> abf, Measured<V,B> m)Maps the given function across this tree, measuring with the given Measured instance.<B> Bmatch(F<Empty<V,A>,B> empty, F<Single<V,A>,B> single, F<Deep<V,A>,B> deep)Pattern matching on the structure of this tree.Vmeasure()Returns zero.AreduceLeft(F<A,F<A,A>> aff)Folds the tree to the left with the given function.AreduceRight(F<A,F<A,A>> aff)Folds the tree to the right with the given function.FingerTree<V,A>snoc(A a)Adds the given element to this tree as the last element.(package private) P3<FingerTree<V,A>,A,FingerTree<V,A>>split1(F<V,java.lang.Boolean> predicate, V acc)FingerTree<V,A>tail()The tree without the first element.Stream<A>toStream()java.lang.StringtoString()-
Methods inherited from class fj.data.fingertrees.FingerTree
empty, emptyIntAddition, emptyIntMax, filter, foldLeft, foldRight, headOption, isEmpty, measured, measured, mkTree, split, split1, uncons
-
-
-
-
Method Detail
-
cons
public FingerTree<V,A> cons(A a)
Description copied from class:FingerTreeAdds the given element to this tree as the first element.- Specified by:
consin classFingerTree<V,A>- Parameters:
a- The element to add to the front of this tree.- Returns:
- A new tree with the given element at the front.
-
snoc
public FingerTree<V,A> snoc(A a)
Description copied from class:FingerTreeAdds the given element to this tree as the last element.- Specified by:
snocin classFingerTree<V,A>- Parameters:
a- The element to add to the end of this tree.- Returns:
- A new tree with the given element at the end.
-
head
public A head()
Description copied from class:FingerTreeThe first element of this tree. This is an O(1) operation.- Specified by:
headin classFingerTree<V,A>- Returns:
- The first element if this tree is nonempty, otherwise throws an error.
-
last
public A last()
Description copied from class:FingerTreeThe last element of this tree. This is an O(1) operation.- Specified by:
lastin classFingerTree<V,A>- Returns:
- The last element if this tree is nonempty, otherwise throws an error.
-
tail
public FingerTree<V,A> tail()
Description copied from class:FingerTreeThe tree without the first element. This is an O(1) operation.- Specified by:
tailin classFingerTree<V,A>- Returns:
- The tree without the first element if this tree is nonempty, otherwise throws an error.
-
init
public FingerTree<V,A> init()
Description copied from class:FingerTreeThe tree without the last element. This is an O(1) operation.- Specified by:
initin classFingerTree<V,A>- Returns:
- The tree without the last element if this tree is nonempty, otherwise throws an error.
-
append
public FingerTree<V,A> append(FingerTree<V,A> t)
Description copied from class:FingerTreeAppends one finger tree to another.- Specified by:
appendin classFingerTree<V,A>- Parameters:
t- A finger tree to append to this one.- Returns:
- A new finger tree which is a concatenation of this tree and the given tree.
-
lookup
public P2<java.lang.Integer,A> lookup(F<V,java.lang.Integer> o, int i)
- Specified by:
lookupin classFingerTree<V,A>
-
length
public int length()
- Specified by:
lengthin classFingerTree<V,A>
-
foldRight
public <B> B foldRight(F<A,F<B,B>> aff, B z)
Description copied from class:FingerTreeFolds the tree to the right with the given function and the given initial element.- Specified by:
foldRightin classFingerTree<V,A>- Parameters:
aff- A function with which to fold the tree.z- An initial element to apply to the fold.- Returns:
- A reduction of this tree by applying the given function, associating to the right.
-
reduceRight
public A reduceRight(F<A,F<A,A>> aff)
Description copied from class:FingerTreeFolds the tree to the right with the given function.- Specified by:
reduceRightin classFingerTree<V,A>- Parameters:
aff- A function with which to fold the tree.- Returns:
- A reduction of this tree by applying the given function, associating to the right.
-
foldLeft
public <B> B foldLeft(F<B,F<A,B>> bff, B z)
Description copied from class:FingerTreeFolds the tree to the left with the given function and the given initial element.- Specified by:
foldLeftin classFingerTree<V,A>- Parameters:
bff- A function with which to fold the tree.z- An initial element to apply to the fold.- Returns:
- A reduction of this tree by applying the given function, associating to the left.
-
reduceLeft
public A reduceLeft(F<A,F<A,A>> aff)
Description copied from class:FingerTreeFolds the tree to the left with the given function.- Specified by:
reduceLeftin classFingerTree<V,A>- Parameters:
aff- A function with which to fold the tree.- Returns:
- A reduction of this tree by applying the given function, associating to the right.
-
map
public <B> FingerTree<V,B> map(F<A,B> abf, Measured<V,B> m)
Description copied from class:FingerTreeMaps the given function across this tree, measuring with the given Measured instance.- Specified by:
mapin classFingerTree<V,A>- Parameters:
abf- A function to map across the values of this tree.m- A measuring with which to annotate the tree.- Returns:
- A new tree with the same structure as this tree, with each element transformed by the given function, and nodes annotated according to the given measuring.
-
measure
public V measure()
Returns zero.- Specified by:
measurein classFingerTree<V,A>- Returns:
- Zero.
-
match
public <B> B match(F<Empty<V,A>,B> empty, F<Single<V,A>,B> single, F<Deep<V,A>,B> deep)
Pattern matching on the structure of this tree. Matches the empty tree.- Specified by:
matchin classFingerTree<V,A>- Parameters:
empty- The function to apply to this empty tree.single- A function to apply if this tree contains a single element.deep- A function to apply if this tree contains more than one element.- Returns:
- The result of the function that matches this tree structurally, applied to this tree.
-
split1
P3<FingerTree<V,A>,A,FingerTree<V,A>> split1(F<V,java.lang.Boolean> predicate, V acc)
- Specified by:
split1in classFingerTree<V,A>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-