Class/Object

scalaz

FingerTree

Related Docs: object FingerTree | package scalaz

Permalink

sealed abstract class FingerTree[V, A] extends AnyRef

Finger trees with leaves of type A and Nodes that are annotated with type V.

Finger Trees provide a base for implementations of various collection types, as described in "Finger trees: a simple general-purpose data structure", by Ralf Hinze and Ross Paterson. A gentle introduction is presented in the blog post "Monoids and Finger Trees" by Heinrich Apfelmus.

This is done by choosing a suitable type to annotate the nodes. For example, a binary tree can be implemented by annotating each node with the size of its subtree, while a priority queue can be implemented by labelling the nodes by the minimum priority of its children.

The operations on FingerTree enforce the constraint measured (in the form of a Reducer instance).

Finger Trees have excellent (amortized) asymptotic performance:

V

The type of the annotations of the nodes (the measure)

A

The type of the elements stored at the leaves

Source
FingerTree.scala
See also

http://apfelmus.nfshost.com/articles/monoid-fingertree.html

Finger trees: a simple general-purpose data structure

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. FingerTree
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def fold[B](empty: (V) ⇒ B, single: (V, A) ⇒ B, deep: (V, Finger[V, A], ⇒ FingerTree[V, Node[V, A]], Finger[V, A]) ⇒ B): B

    Permalink

    Fold over the structure of the tree.

    Fold over the structure of the tree. The given functions correspond to the three possible variations of the finger tree.

    empty

    if the tree is empty, convert the measure to a B

    single

    if the tree contains a single element, convert the measure and this element to a B

    deep

    otherwise, convert the measure, the two fingers, and the sub tree to a B.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def +:(a: ⇒ A): FingerTree[V, A]

    Permalink

    Prepends an element to the left of the tree.

    Prepends an element to the left of the tree. O(1).

  4. def :+(a: ⇒ A): FingerTree[V, A]

    Permalink

    Appends an element to the right of the tree.

    Appends an element to the right of the tree. O(1).

  5. def :-|(a: ⇒ A): FingerTree[V, A]

    Permalink

    Replace the last element of the tree with the given value.

    Replace the last element of the tree with the given value. O(1)

  6. def <++>(right: ⇒ FingerTree[V, A]): FingerTree[V, A]

    Permalink

    Appends the given finger tree to the right of this tree.

  7. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  8. def add1(n: A, right: ⇒ ATree): ATree

    Permalink
  9. def add2(n1t: ⇒ A, n2t: ⇒ A, right: ⇒ ATree): ATree

    Permalink
  10. def add3(n1t: ⇒ A, n2t: ⇒ A, n3t: ⇒ A, right: ⇒ ATree): ATree

    Permalink
  11. def add4(n1t: ⇒ A, n2t: ⇒ A, n3t: ⇒ A, n4t: ⇒ A, right: ⇒ ATree): ATree

    Permalink
  12. def addDigits0(m1: NodeTree, dig1: AFinger, dig2: AFinger, m2: ⇒ NodeTree): NodeTree

    Permalink
  13. def addDigits1(m1: NodeTree, d1: AFinger, xt: ⇒ A, d2: AFinger, m2t: ⇒ NodeTree): NodeTree

    Permalink
  14. def addDigits2(m1: NodeTree, d1: AFinger, xt: ⇒ A, yt: ⇒ A, d2: AFinger, m2t: ⇒ NodeTree): NodeTree

    Permalink
  15. def addDigits3(m1: NodeTree, d1: AFinger, xt: ⇒ A, yt: ⇒ A, zt: ⇒ A, d2: AFinger, m2t: ⇒ NodeTree): NodeTree

    Permalink
  16. def addDigits4(m1: NodeTree, d1: AFinger, xt: ⇒ A, yt: ⇒ A, zt: ⇒ A, wt: ⇒ A, d2: AFinger, m2t: ⇒ NodeTree): NodeTree

    Permalink
  17. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  18. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  20. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  21. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  22. def foldLeft[B](b: B)(f: (B, A) ⇒ B): B

    Permalink
  23. def foldMap[B](f: (A) ⇒ B)(implicit s: Monoid[B]): B

    Permalink
  24. def foldRight[B](z: ⇒ B)(f: (A, ⇒ B) ⇒ B): B

    Permalink
  25. def foreach(f: (A) ⇒ Unit): Unit

    Permalink

    Execute the provided side effect for each element in the tree.

  26. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  27. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  28. def head: A

    Permalink

    Selects the first element in the tree.

    Selects the first element in the tree.

    Exceptions thrown

    if the tree is empty

  29. def init: FingerTree[V, A]

    Permalink

    Selects a subtree containing all elements except the last

    Selects a subtree containing all elements except the last

    Exceptions thrown

    if the tree is empty

  30. def isEmpty: Boolean

    Permalink
  31. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  32. def iterator: Iterator[A]

    Permalink

    An iterator that visits each element in the tree.

  33. def last: A

    Permalink

    Selects the last element in the tree.

    Selects the last element in the tree.

    Exceptions thrown

    if the tree is empty

  34. def map[B, V2](f: (A) ⇒ B)(implicit m: Reducer[B, V2]): FingerTree[V2, B]

    Permalink

    Maps the given function across the tree, annotating nodes in the resulting tree according to the provided Reducer.

  35. def measure: V

    Permalink
  36. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  37. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  38. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  39. def reverseIterator: Iterator[A]

    Permalink

    An iterator that visits each element in the tree in reverse order.

  40. def split(pred: (V) ⇒ Boolean): (FingerTree[V, A], FingerTree[V, A])

    Permalink

    Splits this tree into a pair of subtrees at the point where the given predicate, based on the measure, changes from false to true.

    Splits this tree into a pair of subtrees at the point where the given predicate, based on the measure, changes from false to true. O(log(min(i,n-i)))

    pred

    predicate on node measures. Must be a semigroup homomorphism from the semigroup V of node measures to the semigroup of Booleans with || as the semigroup operation. Namely, it must hold that pred(v1 |+| v2) = pred(v1) || pred(v2).

    returns

    (as, bs), where

    • as: the subtree containing elements before the point where pred first holds
    • bs: the subtree containing elements at and after the point where pred first holds. Empty if pred never holds.
  41. def split1(pred: (V) ⇒ Boolean): (FingerTree[V, A], A, FingerTree[V, A])

    Permalink

    Like split, but returns the element where pred first holds separately

    Like split, but returns the element where pred first holds separately

    Exceptions thrown

    if the tree is empty.

  42. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  43. def tail: FingerTree[V, A]

    Permalink

    Selects a subtree containing all elements except the first

    Selects a subtree containing all elements except the first

    Exceptions thrown

    if the tree is empty

  44. def toList: List[A]

    Permalink

    Convert the leaves of the tree to a scala.List

  45. def toStream: Stream[A]

    Permalink

    Convert the leaves of the tree to a scala.Stream

  46. def toString(): String

    Permalink

    Convert the tree to a String.

    Convert the tree to a String. Unsafe: this uses Any#toString for types V and A

    Definition Classes
    FingerTree → AnyRef → Any
  47. def traverseTree[F[_], V2, B](f: (A) ⇒ F[B])(implicit ms: Reducer[B, V2], F: Applicative[F]): F[FingerTree[V2, B]]

    Permalink

    Like traverse, but with a more constraint type: we need the additional measure to construct the new tree.

  48. def viewl: ViewL[[β$0$]FingerTree[V, β$0$], A]

    Permalink
  49. def viewr: ViewR[[β$5$]FingerTree[V, β$5$], A]

    Permalink
  50. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  51. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  52. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  53. def |-:(a: ⇒ A): FingerTree[V, A]

    Permalink

    Replace the first element of the tree with the given value.

    Replace the first element of the tree with the given value. O(1)

Inherited from AnyRef

Inherited from Any

Ungrouped