Package fj.data.fingertrees
Class Single<V,A>
java.lang.Object
fj.data.fingertrees.FingerTree<V,A>
fj.data.fingertrees.Single<V,A>
A tree with a single element.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionFingerTree
<V, A> append
(FingerTree<V, A> t) Appends one finger tree to another.FingerTree
<V, A> Adds the given element to this tree as the first element.<B> B
Folds the tree to the left with the given function and the given initial element.<B> B
Folds the tree to the right with the given function and the given initial element.head()
The first element of this tree.FingerTree
<V, A> init()
The tree without the last element.last()
The last element of this tree.int
length()
<B> FingerTree
<V, B> Maps the given function across this tree, measuring with the given Measured instance.<B> B
Pattern matching on the structure of this tree.measure()
Returns the annotation of this tree's single element.Folds the tree to the left with the given function.Folds the tree to the right with the given function.FingerTree
<V, A> Adds the given element to this tree as the last element.(package private) P3
<FingerTree<V, A>, A, FingerTree<V, A>> FingerTree
<V, A> tail()
The tree without the first element.toStream()
toString()
value()
Returns the single element of this tree.Methods inherited from class fj.data.fingertrees.FingerTree
empty, emptyIntAddition, emptyIntMax, filter, foldLeft, foldRight, headOption, isEmpty, measured, measured, mkTree, split, split1, uncons
-
Field Details
-
a
-
v
-
-
Constructor Details
-
Single
-
-
Method Details
-
foldRight
Description copied from class:FingerTree
Folds the tree to the right with the given function and the given initial element.- Specified by:
foldRight
in 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
Description copied from class:FingerTree
Folds the tree to the right with the given function.- Specified by:
reduceRight
in 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
Description copied from class:FingerTree
Folds the tree to the left with the given function and the given initial element.- Specified by:
foldLeft
in 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
Description copied from class:FingerTree
Folds the tree to the left with the given function.- Specified by:
reduceLeft
in 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
Description copied from class:FingerTree
Maps the given function across this tree, measuring with the given Measured instance.- Specified by:
map
in 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
Returns the annotation of this tree's single element.- Specified by:
measure
in classFingerTree<V,
A> - Returns:
- the annotation of this tree's single element.
-
match
Pattern matching on the structure of this tree. Matches the singleton tree.- Specified by:
match
in 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.
-
cons
Description copied from class:FingerTree
Adds the given element to this tree as the first element.- Specified by:
cons
in classFingerTree<V,
A> - Parameters:
b
- The element to add to the front of this tree.- Returns:
- A new tree with the given element at the front.
-
snoc
Description copied from class:FingerTree
Adds the given element to this tree as the last element.- Specified by:
snoc
in classFingerTree<V,
A> - Parameters:
b
- The element to add to the end of this tree.- Returns:
- A new tree with the given element at the end.
-
head
Description copied from class:FingerTree
The first element of this tree. This is an O(1) operation.- Specified by:
head
in classFingerTree<V,
A> - Returns:
- The first element if this tree is nonempty, otherwise throws an error.
-
last
Description copied from class:FingerTree
The last element of this tree. This is an O(1) operation.- Specified by:
last
in classFingerTree<V,
A> - Returns:
- The last element if this tree is nonempty, otherwise throws an error.
-
tail
Description copied from class:FingerTree
The tree without the first element. This is an O(1) operation.- Specified by:
tail
in classFingerTree<V,
A> - Returns:
- The tree without the first element if this tree is nonempty, otherwise throws an error.
-
init
Description copied from class:FingerTree
The tree without the last element. This is an O(1) operation.- Specified by:
init
in classFingerTree<V,
A> - Returns:
- The tree without the last element if this tree is nonempty, otherwise throws an error.
-
append
Description copied from class:FingerTree
Appends one finger tree to another.- Specified by:
append
in 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.
-
split1
- Specified by:
split1
in classFingerTree<V,
A>
-
lookup
- Specified by:
lookup
in classFingerTree<V,
A>
-
length
public int length()- Specified by:
length
in classFingerTree<V,
A>
-
value
Returns the single element of this tree.- Returns:
- the single element of this tree.
-
toString
-
toStream
- Specified by:
toStream
in classFingerTree<V,
A>
-