Package fj.data.fingertrees
Class MakeTree<V,A>
java.lang.Object
fj.data.fingertrees.MakeTree<V,A>
A builder of trees and tree components, supplied with a particular monoid and measuring function.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionFingerTree
<V, A> Constructs a deep tree.FingerTree
<V, A> Constructs a deep tree with the given annotation value.FingerTree
<V, A> empty()
Constructs an empty tree.A digit of four elements.A binary tree node.A binary tree nodeA trinary tree node.A trinary tree nodeA digit of one element.FingerTree
<V, A> Constructs a singleton tree.A digit of three elements.A digit of two elements.
-
Field Details
-
m
-
empty
-
-
Constructor Details
-
MakeTree
-
-
Method Details
-
empty
Constructs an empty tree.- Returns:
- The empty tree.
-
single
Constructs a singleton tree.- Parameters:
a
- A single element for the tree.- Returns:
- A tree with the given value as the single element.
-
deep
Constructs a deep tree. This structure consists of two digits, of 1 to 4 elements each, on the left and right, with the rest of the tree in the middle.- Parameters:
prefix
- The leftmost elements of the tree.middle
- The subtree, which is a Finger Tree of 2-3 nodes.suffix
- The rightmost elements of the tree.- Returns:
- A new finger tree with the given prefix, suffix, and middle.
-
deep
public FingerTree<V,A> deep(V v, Digit<V, A> prefix, FingerTree<V, Node<V, A>> middle, Digit<V, A> suffix) Constructs a deep tree with the given annotation value.- Parameters:
v
- The value with which to annotate this tree.prefix
- The leftmost elements of the tree.middle
- The subtree, which is a Finger Tree of 2-3 nodes.suffix
- The rightmost elements of the tree.- Returns:
- A new finger tree with the given prefix, suffix, and middle, and annotated with the given value.
-
one
A digit of one element.- Parameters:
a
- The element of the digit.- Returns:
- A digit of the given element.
-
two
A digit of two elements.- Parameters:
a
- The first element of the digit.b
- The second element of the digit.- Returns:
- A digit of the given elements.
-
three
A digit of three elements.- Parameters:
a
- The first element of the digit.b
- The second element of the digit.c
- The third element of the digit.- Returns:
- A digit of the given elements.
-
four
A digit of four elements.- Parameters:
a
- The first element of the digit.b
- The second element of the digit.c
- The third element of the digit.d
- The fifth element of the digit.- Returns:
- A digit of the given elements.
-
node2
A binary tree node.- Parameters:
a
- The left child of the node.b
- The right child of the node.- Returns:
- A new binary tree node.
-
node3
A trinary tree node.- Parameters:
a
- The left child of the node.b
- The middle child of the node.c
- The right child of the node.- Returns:
- A new trinary tree node.
-
node2
A binary tree node- Parameters:
v
- A vector of the node's elements.- Returns:
- A new binary tree node.
-
node3
A trinary tree node- Parameters:
v
- A vector of the node's elements.- Returns:
- A new trinary tree node.
-