[−][src]Trait outils::tree::generic::GenericForest
This trait defines the fundamental operations of a generic forest.
Required methods
fn insert(&mut self, value: V) -> NodeIndex<Ix>
Inserts value
into the forest as a new root node and return the assigned NodeIndex
.
fn insert_child(
&mut self,
parent: NodeIndex<Ix>,
value: V
) -> Result<NodeIndex<Ix>, TreeError<Ix>>
&mut self,
parent: NodeIndex<Ix>,
value: V
) -> Result<NodeIndex<Ix>, TreeError<Ix>>
Inserts value
into the forest as a new node. which will be the last child of the
node indexed by parent
. If the operation has been completed successfully, the
index of the new child is returned. Otherwise, in particular if parent
is not a
valid node index, an error is returned.
fn insert_child_at(
&mut self,
parent: NodeIndex<Ix>,
pos: usize,
value: V
) -> Result<NodeIndex<Ix>, TreeError<Ix>>
&mut self,
parent: NodeIndex<Ix>,
pos: usize,
value: V
) -> Result<NodeIndex<Ix>, TreeError<Ix>>
Inserts value
into the forest as a new node. which will be a child of the
node indexed by parent
at the position specified by pos
. If pos
is greater than or
equal to the number of children of parent
, the new child will be the new last child.
If the operation has been completed successfully, the index of the new child is returned.
Otherwise, if parent
is not a valid node index, an error is returned.
fn remove(&mut self, node: NodeIndex<Ix>) -> Result<V, TreeError<Ix>>
Removes the tree node indexed by node
, returning its content in case of a valid index.
If the removed node has children, they will become children of the parent of the removed node,
replacing the removed node. If the removed node has no parent, its children will become roots.
fn remove_subtree(
&mut self,
node: NodeIndex<Ix>
) -> Result<Vec<(NodeIndex, V)>, TreeError<Ix>>
&mut self,
node: NodeIndex<Ix>
) -> Result<Vec<(NodeIndex, V)>, TreeError<Ix>>
Removes the tree node indexed by node
and its subtree, returning the contents of the
removed nodes in case of a valid index. The returned values will be collected in pre-order.
fn set_as_child(
&mut self,
parent: NodeIndex<Ix>,
child: NodeIndex<Ix>
) -> Result<(), TreeError<Ix>>
&mut self,
parent: NodeIndex<Ix>,
child: NodeIndex<Ix>
) -> Result<(), TreeError<Ix>>
Adds the root node child
as the new last child of the node indexed by parent
. If the operation has
been completed successfully, Ok(())
is returned. If the forest has not been changed, an error
is returned. This will be the case if:
- the node indexed by
child
is not a tree root, i.e. has a parent. - the node indexed by
parent
is a node in the tree rooted inchild
. - either
parent
orchild
is not a valid node index.
fn set_as_child_at(
&mut self,
parent: NodeIndex<Ix>,
child: NodeIndex<Ix>,
pos: usize
) -> Result<(), TreeError<Ix>>
&mut self,
parent: NodeIndex<Ix>,
child: NodeIndex<Ix>,
pos: usize
) -> Result<(), TreeError<Ix>>
Adds the root node child
as a child of the node indexed by parent
at the position specified
by pos
. If pos
is greater than or equal to the number of children of parent
, the new
child will be the new last child. If the operation has been completed successfully, Ok(())
is returned. If the forest has not been changed, an error is returned. This will be the case if:
- the node indexed by
child
is not a tree root, i.e. has a parent. - the node indexed by
parent
is a node in the tree rooted inchild
. - either
parent
orchild
is not a valid node index.
fn remove_as_child(&mut self, node: NodeIndex<Ix>) -> Result<(), TreeError<Ix>>
Removes the node indexed by node
as a child of its parent, thus making it a new root
node of the forest. If the operation has been completed successfully, Ok(())
is returned.
If node
is not a valid not index, an error is returned.
Implementors
impl<V> GenericForest<V, usize> for Forest<V> where
V: ValueType,
[src]
V: ValueType,
fn insert(&mut self, value: V) -> NodeIndex
[src]
Inserts value
into the forest as a new root node and return the assigned NodeIndex
.
fn insert_child(
&mut self,
parent: NodeIndex,
value: V
) -> Result<NodeIndex, TreeError>
[src]
&mut self,
parent: NodeIndex,
value: V
) -> Result<NodeIndex, TreeError>
Inserts value
into the forest as a new node. which will be the last child of the
node indexed by parent
. If the operation has been completed successfully, the
index of the new child is returned. Otherwise, in particular if parent
is not a
valid node index, an error is returned.
fn insert_child_at(
&mut self,
parent: NodeIndex,
pos: usize,
value: V
) -> Result<NodeIndex, TreeError>
[src]
&mut self,
parent: NodeIndex,
pos: usize,
value: V
) -> Result<NodeIndex, TreeError>
Inserts value
into the forest as a new node. which will be a child of the
node indexed by parent
at the position specified by pos
. If pos
is greater than or
equal to the number of children of parent
, the new child will be the new last child.
If the operation has been completed successfully, the index of the new child is returned.
Otherwise, if parent
is not a valid node index, an error is returned.
fn remove(&mut self, node: NodeIndex) -> Result<V, TreeError>
[src]
Removes the tree node indexed by node
, returning its content in case of a valid index.
If the removed node has children, they will become children of the parent of the removed node,
replacing the removed node. If the removed node has no parent, its children will become roots.
fn remove_subtree(
&mut self,
node: NodeIndex
) -> Result<Vec<(NodeIndex, V)>, TreeError>
[src]
&mut self,
node: NodeIndex
) -> Result<Vec<(NodeIndex, V)>, TreeError>
Removes the tree node indexed by node
and its subtree, returning the contents of the
removed nodes in case of a valid index. The returned values will be collected in pre-order.
fn set_as_child(
&mut self,
parent: NodeIndex,
child: NodeIndex
) -> Result<(), TreeError>
[src]
&mut self,
parent: NodeIndex,
child: NodeIndex
) -> Result<(), TreeError>
Adds the root node child
as the new last child of the node indexed by parent
. If the operation has
been completed successfully, Ok(())
is returned. If the forest has not been changed, an error
is returned. This will be the case if:
- the node indexed by
child
is not a tree root, i.e. has a parent. - the node indexed by
parent
is a node in the tree rooted inchild
. - either
parent
orchild
is not a valid node index.
fn set_as_child_at(
&mut self,
parent: NodeIndex,
child: NodeIndex,
pos: usize
) -> Result<(), TreeError>
[src]
&mut self,
parent: NodeIndex,
child: NodeIndex,
pos: usize
) -> Result<(), TreeError>
Adds the root node child
as a child of the node indexed by parent
at the position specified
by pos
. If pos
is greater than or equal to the number of children of parent
, the new
child will be the new last child. If the operation has been completed successfully, Ok(())
is returned. If the forest has not been changed, an error is returned. This will be the case if:
- the node indexed by
child
is not a tree root, i.e. has a parent. - the node indexed by
parent
is a node in the tree rooted inchild
. - either
parent
orchild
is not a valid node index.
fn remove_as_child(&mut self, node: NodeIndex) -> Result<(), TreeError>
[src]
Removes the node indexed by node
as a child of its parent, thus making it a new root
node of the forest. If the operation has been completed successfully, Ok(())
is returned.
If node
is not a valid not index, an error is returned.