FingerTree

sealed trait FingerTree[V, +A]
Companion
object
class Object
trait Matchable
class Any

Value members

Methods

def isEmpty: Boolean
Queries whether the tree is empty or not
Returns
true if the tree is empty
def measure: V
Queries the measure of the tree, which might be its size or sum
Returns
the measure of the tree
def headOption: Option[A]
Returns the first (left-most) element in the tree as an option.
Returns
the head element (Some), or None if the tree is empty
def tail(m: Measure[A, V]): FingerTree[V, A]
Returns a copy of the tree with the first (head) element removed. Throws a runtime exception if performed
on an empty tree.
Value Params
m
the measure used to update the tree's structure
Returns
the new tree with the first element removed
def last: A
Returns the last (right-most) element in the tree. Throws a runtime exception if performed on an empty tree.
Returns
the last element
def lastOption: Option[A]
Returns the last (right-most) element in the tree as an option.
Returns
the last element (Some), or None if the tree is empty
def init(m: Measure[A, V]): FingerTree[V, A]
Drops the last element of the tree.
Returns
the tree where the last element has been removed
def +:[A1 >: A](b: A1)(m: Measure[A1, V]): FingerTree[V, A1]
Prepends an element to the tree.
Value Params
b
the element to prepend
m
the measure used to update the tree's measure
Returns
the new tree with the element prepended
def :+[A1 >: A](b: A1)(m: Measure[A1, V]): FingerTree[V, A1]
Appends an element to the tree.
Value Params
b
the element to append
m
the measure used to update the tree's structure
Returns
the new tree with the element appended
def ++[A1 >: A](right: FingerTree[V, A1])(m: Measure[A1, V]): FingerTree[V, A1]
def viewLeft(m: Measure[A, V]): ViewLeft[V, A]
def viewRight(m: Measure[A, V]): ViewRight[V, A]
def iterator: Iterator[A]
Creates an Iterator over the elements of the tree
Returns
a fresh Iterator for the tree elements
def toList: List[A]
Converts the tree to a List representation.
Returns
a List constructed from the elements in the tree
def to[To](factory: Factory[A, To]): To
def span(pred: V => Boolean)(m: Measure[A, V]): (FingerTree[V, A], FingerTree[V, A])
Same as span1, but prepends the discerning element to the right tree, returning the left and right tree.
Unlike span1, this is an allowed operation on an empty tree.
Value Params
pred
a test function applied to the elements of the tree from left to right, until a
the test returns false.
Returns
the split tree, as a Tuple2 with the left and the right tree
def span1(pred: V => Boolean)(m: Measure[A, V]): (FingerTree[V, A], A, FingerTree[V, A])
Traverses the tree until a predicate on an element becomes false, and then splits the tree,
returning the elements before that element (the prefix for which the predicate holds),
the element itself (the first for which the predicate does not hold), and the remaining elements.
This method is somewhat analogous to the span method in standard Scala collections, the difference
being that the predicate tests the tree's measure and not individual elements.
Note that the returned discerning element corresponds to the last element in the tree, if
pred returns true for every element (rather than a runtime exception being thrown).
If the tree is empty, this throws a runtime exception.
Value Params
pred
a test function applied to the elements of the tree from left to right, until a
the test returns true.
Returns
the split tree, as a Tuple3 with the left tree, the discerning element, and the right tree
def find1(pred: V => Boolean)(m: Measure[A, V]): (V, A)
Traverses the tree until a predicate on an element becomes true, and then returns that
element. Note that if pred returns false for every element, the last element in the
tree is returned (rather than a runtime exception being thrown).
If the tree is empty, this throws a runtime exception.
Value Params
pred
a test function applied to the elements of the tree from left to right, until a
the test returns true.
Returns
the discerning element
def takeWhile(pred: V => Boolean)(m: Measure[A, V]): FingerTree[V, A]
def dropWhile(pred: V => Boolean)(m: Measure[A, V]): FingerTree[V, A]
def takeWhile1(pred: V => Boolean, init: V)(m: Measure[A, V]): (FingerTree[V, A], A)
def dropWhile1(pred: V => Boolean, init: V)(m: Measure[A, V]): (A, FingerTree[V, A])