[−][src]Enum rosary::RoseTree
Variants
A simple (and almost certainly terribly inefficient) Rose Tree implementation. A dead end node, single value.
A branch has a head value, and then all its child values.
Implementations
impl<V> RoseTree<V>
[src]
pub fn leaf(val: V) -> Self
[src]
Constructors, because I don't know how to make From
do this for me.
pub fn branch<I: Iterator<Item = V>>(val: V, children: I) -> Self
[src]
pub fn ref_tree(&self) -> RoseTree<&V>
[src]
Creates a tree of the same structure as self
where every node is a
reference to the corresponding node in the owning tree.
pub fn is_leaf(&self) -> bool
[src]
These three check if a RoseTree is of a given variant.
pub fn is_branch(&self) -> bool
[src]
pub fn size(&self) -> usize
[src]
Calculates the number of nodes in the tree.
pub fn head(&self) -> Option<&V>
[src]
Retrieves a reference to the head of the tree.
pub fn head_mut(&mut self) -> Option<&mut V>
[src]
pub fn children(&self) -> Option<&Vec<RoseTree<V>>>
[src]
Gets the children of a branch directly, if it is a branch.
pub fn children_mut(&mut self) -> Option<&mut Vec<RoseTree<V>>>
[src]
pub fn swap_head(mut self: Self, new_head: V) -> Self
[src]
Swaps out the head-most
value of the tree with the provided one.
pub fn add_child(self, child: V) -> Self
[src]
Adds a child to specifically a Branch node.
pub fn map_head(self, head_fn: fn(_: V) -> V) -> Self
[src]
pub fn map_leaves(self, child_fn: fn(_: V) -> V) -> Self
[src]
Map over only the leaves of the tree.
pub fn map<U>(&self, func: fn(_: &V) -> U) -> RoseTree<U>
[src]
Map over the whole tree.
pub fn map_into<U>(self, func: fn(_: V) -> U) -> RoseTree<U>
[src]
pub fn depth_map<A: Clone, U>(
&self,
initial: A,
func: fn(_: A, _: &V) -> (A, U)
) -> RoseTree<U>
[src]
&self,
initial: A,
func: fn(_: A, _: &V) -> (A, U)
) -> RoseTree<U>
Maps over the tree, where each child of the same parent receives the same accumulator value as a function argument. Add more variants of this for different argument mutabilities maybe?
pub fn filter<F: Fn(&V) -> bool>(self, func: F) -> Option<Self>
[src]
Removes all values from the tree which don't satisfy the predicate. In the case of branches, if the head of the branch does not satisfy the predicate, both it and all its children are removed.
pub fn preorder_iter<'a>(&'a self) -> PreorderRoseIter<'_, V>ⓘNotable traits for PreorderRoseIter<'a, T>
impl<'a, T: Debug> Iterator for PreorderRoseIter<'a, T> type Item = &'a T;
[src]
Notable traits for PreorderRoseIter<'a, T>
impl<'a, T: Debug> Iterator for PreorderRoseIter<'a, T> type Item = &'a T;
Trait Implementations
impl<V: Clone> Clone for RoseTree<V>
[src]
impl<V: Debug> Debug for RoseTree<V>
[src]
impl<V: Eq> Eq for RoseTree<V>
[src]
impl<V, I: IntoIterator<Item = V>> From<(V, I)> for RoseTree<V>
[src]
pub fn from((head, child_collection): (V, I)) -> RoseTree<V>
[src]
Convenience to make wrapping anything in a Branch nicer(I know, shocking).
impl<V> From<V> for RoseTree<V>
[src]
impl<V: PartialEq> PartialEq<RoseTree<V>> for RoseTree<V>
[src]
pub fn eq(&self, other: &Self) -> bool
[src]
It'd be really nice to be able to check equality of variants independently of the values within the variants, but I have no idea how or if that's possible.
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<V> StructuralEq for RoseTree<V>
[src]
impl<T: Display> TreeFormat for RoseTree<T>
[src]
If you're a RoseTree, you get TreeFormat for free so long as T can be printed. If printing T involves printing newlines, don't. It'll get weird.
Auto Trait Implementations
impl<V> RefUnwindSafe for RoseTree<V> where
V: RefUnwindSafe,
[src]
V: RefUnwindSafe,
impl<V> Send for RoseTree<V> where
V: Send,
[src]
V: Send,
impl<V> Sync for RoseTree<V> where
V: Sync,
[src]
V: Sync,
impl<V> Unpin for RoseTree<V> where
V: Unpin,
[src]
V: Unpin,
impl<V> UnwindSafe for RoseTree<V> where
V: UnwindSafe,
[src]
V: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<!> for T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,