Tree

org.specs2.fp.Tree
See theTree companion object
sealed abstract class Tree[A]

Inspired from the scalaz (https://github.com/scalaz/scalaz) project

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

def rootLabel: A

The label at the root of this tree.

The label at the root of this tree.

Attributes

def subForest: LazyList[Tree[A]]

The child nodes of this tree.

The child nodes of this tree.

Attributes

Concrete methods

def cobind[B](f: Tree[A] => B): Tree[B]

Binds the given function across all the subtrees of this tree.

Binds the given function across all the subtrees of this tree.

Attributes

def drawTree(using sh: Show[A]): String

A 2D String representation of this Tree.

A 2D String representation of this Tree.

Attributes

def flatMap[B](f: A => Tree[B]): Tree[B]
def flatten: LazyList[A]

Pre-order traversal.

Pre-order traversal.

Attributes

def foldMap[B](f: A => B)(using evidence$1: Monoid[B]): B

Maps the elements of the Tree into a Monoid and folds the resulting Tree.

Maps the elements of the Tree into a Monoid and folds the resulting Tree.

Attributes

def foldNode[Z](f: A => LazyList[Tree[A]] => Z): Z
def foldRight[B](z: => B)(f: (A, => B) => B): B
def levels: LazyList[LazyList[A]]

Breadth-first traversal.

Breadth-first traversal.

Attributes

def loc: TreeLoc[A]

A TreeLoc zipper of this tree, focused on the root node.

A TreeLoc zipper of this tree, focused on the root node.

Attributes

def map[B](f: A => B): Tree[B]
def scanr[B](g: (A, LazyList[Tree[B]]) => B): Tree[B]

A histomorphic transform. Each element in the resulting tree is a function of the corresponding element in this tree and the histomorphic transform of its children.

A histomorphic transform. Each element in the resulting tree is a function of the corresponding element in this tree and the histomorphic transform of its children.

Attributes

def size: Int

return the size of the tree == the number of labels

return the size of the tree == the number of labels

Attributes

def unzip[A1, A2](using p: A => (A1, A2)): (Tree[A1], Tree[A2])

Turns a tree of pairs into a pair of trees.

Turns a tree of pairs into a pair of trees.

Attributes