Class MakeTree<V,A>

java.lang.Object
fj.data.fingertrees.MakeTree<V,A>

public final class MakeTree<V,A> extends Object
A builder of trees and tree components, supplied with a particular monoid and measuring function.
  • Field Details

  • Constructor Details

  • Method Details

    • empty

      public FingerTree<V,A> empty()
      Constructs an empty tree.
      Returns:
      The empty tree.
    • single

      public FingerTree<V,A> single(A a)
      Constructs a singleton tree.
      Parameters:
      a - A single element for the tree.
      Returns:
      A tree with the given value as the single element.
    • deep

      public FingerTree<V,A> deep(Digit<V,A> prefix, FingerTree<V,Node<V,A>> middle, Digit<V,A> suffix)
      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

      public One<V,A> one(A a)
      A digit of one element.
      Parameters:
      a - The element of the digit.
      Returns:
      A digit of the given element.
    • two

      public Two<V,A> two(A a, A b)
      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

      public Three<V,A> three(A a, A b, A c)
      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

      public Four<V,A> four(A a, A b, A c, A d)
      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

      public Node2<V,A> node2(A a, A b)
      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

      public Node3<V,A> node3(A a, A b, A c)
      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

      public Node2<V,A> node2(V2<A> v)
      A binary tree node
      Parameters:
      v - A vector of the node's elements.
      Returns:
      A new binary tree node.
    • node3

      public Node3<V,A> node3(V3<A> v)
      A trinary tree node
      Parameters:
      v - A vector of the node's elements.
      Returns:
      A new trinary tree node.