Zippy v0.0.1 Zippy.ZForest
Zipper forests are a zipper structure where each node is a list of subtrees.You can iterate over this structure, and thus represent a minimum spanning tree, a DOM, an undo tree, etc. Adding, replacing and deleting operations are constant time.
This module is a port of Fred Hebert’s “Zippers” library, under the MIT licence.
Summary
Functions
Delete the node at the current position
. The next one on the right will take its place
Moves down the forest to the children of the current
node.
If we are already at the bottom, this function returns nil
Insert a new node at the current
position
Moves to the next node from the current
item.
If there is no next node, this function returns nil
Moves to the previous node from the current
item.
If we are already at the top, this function returns nil
Replace the node at the current
position with value
Create an empty zipper forest with value
as its first element
Moves up the forest to the parent of the current
node, while rewinding the current
node’s child list.
This allows the programmer to access children as it it were the first time, all the time.
If we are already at the top, this function returns nil
Moves up the forest to the parent of the current
node, without rewinding the current
node’s child list.
If we are already at the top, this function returns nil
Extract the node value from the current tree position as {:ok, value}
.
If there is no item, the function returns {:error, nil}
Types
Functions
Delete the node at the current position
. The next one on the right will take its place.
Moves down the forest to the children of the current
node.
If we are already at the bottom, this function returns nil
.
Insert a new node at the current
position.
Moves to the next node from the current
item.
If there is no next node, this function returns nil
.
Moves to the previous node from the current
item.
If we are already at the top, this function returns nil
.
Replace the node at the current
position with value
.
Create an empty zipper forest with value
as its first element.
Moves up the forest to the parent of the current
node, while rewinding the current
node’s child list.
This allows the programmer to access children as it it were the first time, all the time.
If we are already at the top, this function returns nil
.
Moves up the forest to the parent of the current
node, without rewinding the current
node’s child list.
If we are already at the top, this function returns nil
.
Extract the node value from the current tree position as {:ok, value}
.
If there is no item, the function returns {:error, nil}