Struct iodyn::tree_cursor::Cursor
[−]
[src]
pub struct Cursor<E: TreeUpdate + Debug + Clone + Eq + Hash + 'static> { /* fields omitted */ }
tree cursor, centered on a node of the underlying persistent tree
A cursor allows exploration of the underlying tree by following links to branches or up towards root. This structure is optimised for splitting and combining trees in a cannonical way based on the levels of the nodes; that is, trees with the same levels will have the same structure, regaurdless of order of operations.
Many operations allow structural mutation of the underlying tree.
Methods
impl<'a, E: TreeUpdate + Debug + Clone + Eq + Hash + 'static> Cursor<E>
[src]
fn new() -> Self
creates a new cursor, to an empty underlying tree
fn with_depth(depth: usize) -> Self
creates a new cursor, with expected depth of underlying tree
fn split(self) -> (Cursor<E>, Option<Tree<E>>, Cursor<E>)
Returns the node the cursor is focused on as a tree, plus two cursors containing every node to the left and right, focused on at the two branches of the returned tree
fn into_iters(self) -> (IterL<E>, Option<Tree<E>>, IterR<E>)
A specialized split that returns iterators
Converts the cursor into two iterators, over elements to the left and right of the cursor. The tree at the cursor is returned as well. The iterators include data it its branches, but not the tree's data. Data in a tree is considered to be between the data of the left and right branches.
fn join(
l_cursor: Self,
level: u32,
name: Option<Name>,
data: E,
r_cursor: Self
) -> Self
l_cursor: Self,
level: u32,
name: Option<Name>,
data: E,
r_cursor: Self
) -> Self
makes a new cursor at the given data, between the trees of the other cursors
The rebuild()
method of the data type will be called, with the data
parameter passed here as the old_data
to that method (along with joined branches).
fn at_tree(&self) -> Option<Tree<E>>
copies the focused node as a tree
This is a persistent tree, so copies are Rc clones
fn left_tree(&self) -> Option<Tree<E>>
copies the left branch of the focused node
fn right_tree(&self) -> Option<Tree<E>>
copies the right branch of the focused node
fn peek(&self) -> Option<E>
peek at the data of the focused tree node
fn peek_level(&self) -> Option<u32>
peek at the level of the focused tree node
fn peek_name(&self) -> Option<Name>
peek at the name of the focused tree node if there is a focused tree and it has a name
fn down_left_force(&mut self, force: Force) -> bool
move the cursor into the left branch, returning true if successful
use the Force
enum to determine the type of movement
fn down_left(&mut self) -> bool
move the cursor to the left branch, without entering an empty branch
fn down_right_force(&mut self, force: Force) -> bool
move the cursor into the right branch, returning true if successful
use the Force
enum to determine the type of movement
fn down_right(&mut self) -> bool
move the cursor to the right branch, without entering an empty branch
fn up(&mut self) -> UpResult
move the cursor up towards the root of the underlying persistent tree
If the tree has been changed, the rebuild()
method of the tree's data
type will be called as a new persistent node is created. The return
value represents the direction the cursor moved
fn up_discard(&mut self) -> UpResult
move the cursor up, discarding any changes
The return value represents the direction the cursor moved
Trait Implementations
impl<E: Debug + TreeUpdate + Debug + Clone + Eq + Hash + 'static> Debug for Cursor<E>
[src]
impl<E: PartialEq + TreeUpdate + Debug + Clone + Eq + Hash + 'static> PartialEq for Cursor<E>
[src]
fn eq(&self, __arg_0: &Cursor<E>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Cursor<E>) -> bool
This method tests for !=
.
impl<E: Eq + TreeUpdate + Debug + Clone + Eq + Hash + 'static> Eq for Cursor<E>
[src]
impl<E: Hash + TreeUpdate + Debug + Clone + Eq + Hash + 'static> Hash for Cursor<E>
[src]
fn hash<__HE: Hasher>(&self, __arg_0: &mut __HE)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<E: TreeUpdate + Debug + Clone + Eq + Hash + 'static> Clone for Cursor<E>
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more