public final class TreeZipper<A> extends java.lang.Object implements java.lang.Iterable<TreeZipper<A>>
Modifier and Type  Method and Description 

<B> TreeZipper<B> 
cobind(F<TreeZipper<A>,B> f)
Maps the given function over the tree of all positions for this zipper (comonad pattern).

Option<TreeZipper<A>> 
delete()
Removes the current node from the tree.

static <A> Equal<TreeZipper<A>> 
eq(Equal<A> e)
An Equal instance for tree zippers.

static <A> F2<F<Tree<A>,java.lang.Boolean>,TreeZipper<A>,Option<TreeZipper<A>>> 
findChild()
A firstclass version of the findChild function.

Option<TreeZipper<A>> 
findChild(F<Tree<A>,java.lang.Boolean> p)
Navigates to the first child of the current location, that satisfies the given predicate.

Option<TreeZipper<A>> 
firstChild()
Navigtes to the first child of the current location.

Tree<A> 
focus()
Returns the tree at the currently focused node.

static <A> Option<TreeZipper<A>> 
fromForest(Stream<Tree<A>> ts)
Creates a new tree zipper focused on the first element of the given forest.

static <A> F<Tree<A>,TreeZipper<A>> 
fromTree()
Firstclass conversion of a Tree to the corresponding tree zipper.

static <A> TreeZipper<A> 
fromTree(Tree<A> t)
Creates a new tree zipper focused on the root of the given tree.

Option<TreeZipper<A>> 
getChild(int n)
Navigates to the given child of the current location, starting at index 0.

A 
getLabel()
Returns the label at the current node.

boolean 
hasChildren()
Indicates whether the current node has any child nodes.

Option<TreeZipper<A>> 
insertDownAt(int n,
Tree<A> t)
Inserts a tree at the specified location in the current node's stream of children.

TreeZipper<A> 
insertDownFirst(Tree<A> t)
Inserts a tree as the first child of the current node.

TreeZipper<A> 
insertDownLast(Tree<A> t)
Inserts a tree as the last child of the current node.

TreeZipper<A> 
insertLeft(Tree<A> t)
Inserts a tree to the left of the current position.

TreeZipper<A> 
insertRight(Tree<A> t)
Inserts a tree to the right of the current position.

boolean 
isChild()
Indicates whether the current node is a child node of another node.

boolean 
isFirst()
Indicates whether the current node is the leftmost tree in the current forest.

boolean 
isLast()
Indicates whether the current node is the rightmost tree in the current forest.

boolean 
isLeaf()
Indicates whether the current node is at the bottom of the tree.

boolean 
isRoot()
Indicates whether the current node is at the top of the tree.

java.util.Iterator<TreeZipper<A>> 
iterator()
Returns an iterator of all the positions of this TreeZipper.

Option<TreeZipper<A>> 
lastChild()
Navigtes to the last child of the current location.

static <A> F<TreeZipper<A>,Option<TreeZipper<A>>> 
left_()
A firstclass version of the left() function.

Option<TreeZipper<A>> 
left()
Navigates to the left sibling of the current location.

Stream<Tree<A>> 
lefts()
Returns the left siblings of the currently focused node.

<B> TreeZipper<B> 
map(F<A,B> f)
Maps the given function across this zipper (covariant functor pattern).

TreeZipper<A> 
modifyLabel(F<A,A> f)
Modifies the label at the current node with the given function.

TreeZipper<A> 
modifyTree(F<Tree<A>,Tree<A>> f)
Modifies the current node with the given function.

static <A> F<TreeZipper<A>,P4<Tree<A>,Stream<Tree<A>>,Stream<Tree<A>>,Stream<P3<Stream<Tree<A>>,A,Stream<Tree<A>>>>>> 
p_()
A firstclass function that returns the product4 representation of a given zipper.

P4<Tree<A>,Stream<Tree<A>>,Stream<Tree<A>>,Stream<P3<Stream<Tree<A>>,A,Stream<Tree<A>>>>> 
p()
Returns the product4 representation of this zipper.

Option<TreeZipper<A>> 
parent()
Navigates to the parent of the current location.

TreeZipper<TreeZipper<A>> 
positions()
Returns a zipper over the tree of all possible permutations of this tree zipper (comonad pattern).

static <A> F<TreeZipper<A>,Option<TreeZipper<A>>> 
right_()
A firstclass version of the right() function.

Option<TreeZipper<A>> 
right()
Navigates to the right sibling of the current location.

Stream<Tree<A>> 
rights()
Returns the right siblings of the currently focused node.

static <A> F<TreeZipper<A>,TreeZipper<A>> 
root_()
A firstclass version of the root function.

TreeZipper<A> 
root()
Navigates to the topmost parent of the current location.

TreeZipper<A> 
setLabel(A v)
Replaces the label of the current node with the given value.

TreeZipper<A> 
setTree(Tree<A> t)
Replaces the current node with the given tree.

static <A> Show<TreeZipper<A>> 
show(Show<A> s)
A Show instance for tree zippers.

Stream<Tree<A>> 
toForest()
Returns the forest containing this location.

Tree<A> 
toTree()
Returns the tree containing this location.

static <A> F<Tree<A>,F<Stream<Tree<A>>,F<Stream<Tree<A>>,F<Stream<P3<Stream<Tree<A>>,A,Stream<Tree<A>>>>,TreeZipper<A>>>>> 
treeZipper()
Firstclass constructor for tree zippers.

static <A> TreeZipper<A> 
treeZipper(Tree<A> tree,
Stream<Tree<A>> lefts,
Stream<Tree<A>> rights,
Stream<P3<Stream<Tree<A>>,A,Stream<Tree<A>>>> parents)
Creates a new tree zipper given a currently selected tree, a forest on the left, a forest on the right,
and a stream of parent contexts.

<B,C> TreeZipper<C> 
zipWith(TreeZipper<B> bs,
F<A,F<B,C>> f)
Zips this TreeZipper with another, applying the given function lockstep over both zippers in all directions.

<B,C> TreeZipper<C> 
zipWith(TreeZipper<B> bs,
F2<A,B,C> f)
Zips this TreeZipper with another, applying the given function lockstep over both zippers in all directions.

TreeZipper<P2<A,java.lang.Boolean>> 
zipWithFocus()
Zips the nodes in this zipper with a boolean that indicates whether that node has focus.

public java.util.Iterator<TreeZipper<A>> iterator()
iterator
in interface java.lang.Iterable<TreeZipper<A>>
public static <A> TreeZipper<A> treeZipper(Tree<A> tree, Stream<Tree<A>> lefts, Stream<Tree<A>> rights, Stream<P3<Stream<Tree<A>>,A,Stream<Tree<A>>>> parents)
tree
 The currently selected tree.lefts
 The selected tree's left siblings, closest first.rights
 The selected tree's right siblings, closest first.parents
 The parent of the selected tree, and the parent's siblings.public static <A> F<Tree<A>,F<Stream<Tree<A>>,F<Stream<Tree<A>>,F<Stream<P3<Stream<Tree<A>>,A,Stream<Tree<A>>>>,TreeZipper<A>>>>> treeZipper()
public P4<Tree<A>,Stream<Tree<A>>,Stream<Tree<A>>,Stream<P3<Stream<Tree<A>>,A,Stream<Tree<A>>>>> p()
public static <A> F<TreeZipper<A>,P4<Tree<A>,Stream<Tree<A>>,Stream<Tree<A>>,Stream<P3<Stream<Tree<A>>,A,Stream<Tree<A>>>>>> p_()
public static <A> Equal<TreeZipper<A>> eq(Equal<A> e)
e
 An Equal instance for tree elements.public static <A> Show<TreeZipper<A>> show(Show<A> s)
s
 A Show instance for tree elements.public Option<TreeZipper<A>> parent()
public TreeZipper<A> root()
public static <A> F<TreeZipper<A>,TreeZipper<A>> root_()
public Option<TreeZipper<A>> left()
public Option<TreeZipper<A>> right()
public Option<TreeZipper<A>> firstChild()
public Option<TreeZipper<A>> lastChild()
public Option<TreeZipper<A>> getChild(int n)
n
 The index of the child to which to navigate.public Option<TreeZipper<A>> findChild(F<Tree<A>,java.lang.Boolean> p)
p
 A predicate to be satisfied by the child node.public static <A> TreeZipper<A> fromTree(Tree<A> t)
t
 A tree over which to create a new zipper.public static <A> Option<TreeZipper<A>> fromForest(Stream<Tree<A>> ts)
ts
 A forest over which to create a new zipper.public Tree<A> toTree()
public Stream<Tree<A>> toForest()
public Tree<A> focus()
public Stream<Tree<A>> lefts()
public Stream<Tree<A>> rights()
public boolean isRoot()
public boolean isFirst()
public boolean isLast()
public boolean isLeaf()
public boolean isChild()
public boolean hasChildren()
public TreeZipper<A> setTree(Tree<A> t)
t
 A tree with which to replace the current node.public TreeZipper<A> modifyTree(F<Tree<A>,Tree<A>> f)
f
 A function with which to modify the current tree.public TreeZipper<A> modifyLabel(F<A,A> f)
f
 A function with which to transform the current node's label.public TreeZipper<A> setLabel(A v)
v
 The new value for the node's label.public A getLabel()
public TreeZipper<A> insertLeft(Tree<A> t)
t
 A tree to insert to the left of the current position.public TreeZipper<A> insertRight(Tree<A> t)
t
 A tree to insert to the right of the current position.public TreeZipper<A> insertDownFirst(Tree<A> t)
t
 A tree to insert.public TreeZipper<A> insertDownLast(Tree<A> t)
t
 A tree to insert.public Option<TreeZipper<A>> insertDownAt(int n, Tree<A> t)
n
 The index at which to insert the given tree, starting at 0.t
 A tree to insert.n
children.public Option<TreeZipper<A>> delete()
public TreeZipper<P2<A,java.lang.Boolean>> zipWithFocus()
public <B> TreeZipper<B> map(F<A,B> f)
f
 A function to map across this zipper.public static <A> F<Tree<A>,TreeZipper<A>> fromTree()
public static <A> F<TreeZipper<A>,Option<TreeZipper<A>>> left_()
public static <A> F<TreeZipper<A>,Option<TreeZipper<A>>> right_()
public TreeZipper<TreeZipper<A>> positions()
public <B> TreeZipper<B> cobind(F<TreeZipper<A>,B> f)
f
 A function to map over the tree of all positions for this zipper.public static <A> F2<F<Tree<A>,java.lang.Boolean>,TreeZipper<A>,Option<TreeZipper<A>>> findChild()
public <B,C> TreeZipper<C> zipWith(TreeZipper<B> bs, F2<A,B,C> f)
bs
 A TreeZipper to zip this one with.f
 A function with which to zip together the two TreeZippers.public <B,C> TreeZipper<C> zipWith(TreeZipper<B> bs, F<A,F<B,C>> f)
bs
 A TreeZipper to zip this one with.f
 A function with which to zip together the two TreeZippers.