Struct trees::linked::singly::forest::Forest [−][src]
A nullable forest
Implementations
impl<T> Forest<T>
[src]
pub fn new() -> Forest<T>
[src]
Makes an empty Forest
pub fn is_empty(&self) -> bool
[src]
Returns true
if the Forest
is empty.
This operation should compute in O(1) time.
Examples
use trees::linked::singly::{tr,fr}; let mut forest = fr(); assert!( forest.is_empty() ); forest.push_back( tr(1) ); assert!( !forest.is_empty() );
pub fn first(&self) -> Option<&Node<T>>
[src]
Returns the first child of the forest, or None if it is empty.
pub fn first_mut(&mut self) -> Option<&mut Node<T>>
[src]
Returns a mutable pointer to the first child of the forest, or None if it is empty.
pub fn last(&self) -> Option<&Node<T>>
[src]
Returns the last child of the forest, or None if it is empty.
pub fn last_mut(&mut self) -> Option<&mut Node<T>>
[src]
Returns a mutable pointer to the last child of the forest, or None if it is empty.
pub fn push_front(&mut self, tree: Tree<T>)
[src]
Adds the tree as the first child.
Examples
use trees::linked::singly::{tr,fr}; let mut forest = fr(); forest.push_front( tr(1) ); assert_eq!( forest.to_string(), "( 1 )" ); forest.push_front( tr(2) ); assert_eq!( forest.to_string(), "( 2 1 )" );
pub fn push_back(&mut self, tree: Tree<T>)
[src]
Adds the tree as the first child.
Examples
use trees::linked::singly::{tr,fr}; let mut forest = fr(); forest.push_back( tr(1) ); assert_eq!( forest.to_string(), "( 1 )" ); forest.push_back( tr(2) ); assert_eq!( forest.to_string(), "( 1 2 )" );
pub fn pop_front(&mut self) -> Option<Tree<T>>
[src]
remove and return the first child
Examples
use trees::linked::singly::tr; let mut forest = -tr(1)-tr(2); assert_eq!( forest.pop_front(), Some( tr(1) )); assert_eq!( forest.to_string(), "( 2 )" ); assert_eq!( forest.pop_front(), Some( tr(2) )); assert_eq!( forest.to_string(), "()" );
pub fn prepend(&mut self, forest: Forest<T>)
[src]
merge the forest at front
Examples
use trees::linked::singly::{tr,fr}; let mut forest = fr(); forest.prepend( -tr(0)-tr(1) ); assert_eq!( forest.to_string(), "( 0 1 )" ); forest.prepend( -tr(2)-tr(3) ); assert_eq!( forest.to_string(), "( 2 3 0 1 )" );
pub fn append(&mut self, forest: Forest<T>)
[src]
merge the forest at back
Examples
use trees::linked::singly::{tr,fr}; let mut forest = fr(); forest.append( -tr(0)-tr(1) ); assert_eq!( forest.to_string(), "( 0 1 )" ); forest.append( -tr(2)-tr(3) ); assert_eq!( forest.to_string(), "( 0 1 2 3 )" );
pub fn iter<'a>(&self) -> Iter<'a, T>ⓘ
[src]
Provides a forward iterator over child Node
s
Examples
use trees::linked::singly::{tr,fr}; let forest = fr::<i32>(); assert_eq!( forest.iter().next(), None ); let forest = -tr(1)-tr(2); let mut iter = forest.iter(); assert_eq!( iter.next(), Some( tr(1).root() )); assert_eq!( iter.next(), Some( tr(2).root() )); assert_eq!( iter.next(), None ); assert_eq!( iter.next(), None );
pub fn iter_mut<'a>(&mut self) -> IterMut<'a, T>ⓘ
[src]
Provides a forward iterator over child Node
s with mutable references.
Examples
use trees::linked::singly::{tr,fr}; let mut forest = fr::<i32>(); assert_eq!( forest.iter_mut().next(), None ); let mut forest = -tr(1)-tr(2); for child in forest.iter_mut() { child.data *= 10; } assert_eq!( forest.to_string(), "( 10 20 )" );
pub fn onto_iter<'a>(&mut self) -> OntoIter<'a, T>ⓘ
[src]
Provide an iterator over Forest
’s Subnode
s for insert/remove at any position.
See Subnode
’s document for more.
pub fn bfs<'a, 's: 'a>(&'s self) -> BfsForest<Splitted<Iter<'a, T>>>
[src]
Provides a forward iterator in a breadth-first manner
Examples
use trees::{bfs,Size}; use trees::linked::singly::{tr,fr}; let forest = fr::<i32>(); let visits = forest.bfs().iter.collect::<Vec<_>>(); assert!( visits.is_empty() ); let forest = -( tr(1)/tr(2)/tr(3) ) -( tr(4)/tr(5)/tr(6) ); let visits = forest.bfs().iter.collect::<Vec<_>>(); assert_eq!( visits, vec![ bfs::Visit{ data: &1, size: Size{ degree: 2, node_cnt: 0 }}, bfs::Visit{ data: &4, size: Size{ degree: 2, node_cnt: 0 }}, bfs::Visit{ data: &2, size: Size{ degree: 0, node_cnt: 0 }}, bfs::Visit{ data: &3, size: Size{ degree: 0, node_cnt: 0 }}, bfs::Visit{ data: &5, size: Size{ degree: 0, node_cnt: 0 }}, bfs::Visit{ data: &6, size: Size{ degree: 0, node_cnt: 0 }}, ]);
pub fn bfs_mut<'a, 's: 'a>(&'s mut self) -> BfsForest<Splitted<IterMut<'a, T>>>
[src]
Provides a forward iterator with mutable references in a breadth-first manner
Examples
use trees::{bfs,Size}; use trees::linked::singly::{tr,fr}; let mut forest = fr::<i32>(); let visits = forest.bfs_mut().iter.collect::<Vec<_>>(); assert!( visits.is_empty() ); let mut forest = -( tr(1)/tr(2)/tr(3) ) -( tr(4)/tr(5)/tr(6) ); let visits = forest.bfs_mut().iter.collect::<Vec<_>>(); assert_eq!( visits, vec![ bfs::Visit{ data: &mut 1, size: Size{ degree: 2, node_cnt: 0 }}, bfs::Visit{ data: &mut 4, size: Size{ degree: 2, node_cnt: 0 }}, bfs::Visit{ data: &mut 2, size: Size{ degree: 0, node_cnt: 0 }}, bfs::Visit{ data: &mut 3, size: Size{ degree: 0, node_cnt: 0 }}, bfs::Visit{ data: &mut 5, size: Size{ degree: 0, node_cnt: 0 }}, bfs::Visit{ data: &mut 6, size: Size{ degree: 0, node_cnt: 0 }}, ]);
pub fn into_bfs(self) -> BfsForest<Splitted<IntoIter<T>>>
[src]
Provides a forward iterator with owned data in a breadth-first manner
Examples
use trees::{bfs,Size}; use trees::linked::singly::{tr,fr}; let forest = fr::<i32>(); let visits = forest.into_bfs().iter.collect::<Vec<_>>(); assert!( visits.is_empty() ); let forest = -( tr(1)/tr(2)/tr(3) ) -( tr(4)/tr(5)/tr(6) ); let visits = forest.into_bfs().iter.collect::<Vec<_>>(); assert_eq!( visits, vec![ bfs::Visit{ data: 1, size: Size{ degree: 2, node_cnt: 0 }}, bfs::Visit{ data: 4, size: Size{ degree: 2, node_cnt: 0 }}, bfs::Visit{ data: 2, size: Size{ degree: 0, node_cnt: 0 }}, bfs::Visit{ data: 3, size: Size{ degree: 0, node_cnt: 0 }}, bfs::Visit{ data: 5, size: Size{ degree: 0, node_cnt: 0 }}, bfs::Visit{ data: 6, size: Size{ degree: 0, node_cnt: 0 }}, ]);
Trait Implementations
impl<T> Borrow<Forest<T>> for Tree<T>
[src]
impl<T> BorrowMut<Forest<T>> for Tree<T>
[src]
fn borrow_mut(&mut self) -> &mut Forest<T>
[src]
impl<T: Clone> Clone for Forest<T>
[src]
fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Debug> Debug for Forest<T>
[src]
impl<T> Default for Forest<T>
[src]
impl<T> Deref for Forest<T>
[src]
impl<T> DerefMut for Forest<T>
[src]
impl<T: Display> Display for Forest<T>
[src]
impl<'a, T: Clone> Div<&'a Forest<T>> for Tree<T>
[src]
type Output = Tree<T>
The resulting type after applying the /
operator.
fn div(self, rhs: &'a Forest<T>) -> Tree<T>
[src]
impl<'a, T: Clone> Div<&'a Forest<T>> for &'a Tree<T>
[src]
type Output = Tree<T>
The resulting type after applying the /
operator.
fn div(self, rhs: &'a Forest<T>) -> Tree<T>
[src]
impl<T> Div<Forest<T>> for Tree<T>
[src]
type Output = Tree<T>
The resulting type after applying the /
operator.
fn div(self, rhs: Forest<T>) -> Tree<T>
[src]
impl<'a, T: Clone> Div<Forest<T>> for &'a Tree<T>
[src]
type Output = Tree<T>
The resulting type after applying the /
operator.
fn div(self, rhs: Forest<T>) -> Tree<T>
[src]
impl<T> Drop for Forest<T>
[src]
impl<T: Eq> Eq for Forest<T>
[src]
impl<T> Extend<Tree<T>> for Forest<T>
[src]
fn extend<I: IntoIterator<Item = Tree<T>>>(&mut self, iter: I)
[src]
pub fn extend_one(&mut self, item: A)
[src]
pub fn extend_reserve(&mut self, additional: usize)
[src]
impl<T> From<Forest<T>> for ForestWalk<T>
[src]
impl<T> FromIterator<Tree<T>> for Forest<T>
[src]
fn from_iter<I: IntoIterator<Item = Tree<T>>>(iter: I) -> Self
[src]
impl<T: Hash> Hash for Forest<T>
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T> Into<Forest<T>> for ForestWalk<T>
[src]
impl<T> IntoIterator for Forest<T>
[src]
type Item = Tree<T>
The type of the elements being iterated over.
type IntoIter = IntoIter<T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> IntoIter<T>ⓘ
[src]
impl<T: Ord> Ord for Forest<T>
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl<T: PartialEq> PartialEq<Forest<T>> for Forest<T>
[src]
impl<T: PartialOrd> PartialOrd<Forest<T>> for Forest<T>
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<T: Send> Send for Forest<T>
[src]
impl<'a, T: Clone> Sub<&'a Forest<T>> for Forest<T>
[src]
type Output = Forest<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: &'a Forest<T>) -> Self
[src]
impl<'a, T: Clone> Sub<&'a Tree<T>> for Forest<T>
[src]
type Output = Forest<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: &'a Tree<T>) -> Self
[src]
impl<'a, 'b, T: Clone> Sub<&'b Forest<T>> for &'a Forest<T>
[src]
type Output = Forest<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: &'b Forest<T>) -> Forest<T>
[src]
impl<'a, 'b, T: Clone> Sub<&'b Tree<T>> for &'a Forest<T>
[src]
type Output = Forest<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: &'b Tree<T>) -> Forest<T>
[src]
impl<T> Sub<Forest<T>> for Forest<T>
[src]
type Output = Forest<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: Self) -> Self
[src]
impl<'a, T: Clone> Sub<Forest<T>> for &'a Forest<T>
[src]
type Output = Forest<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: Forest<T>) -> Forest<T>
[src]
impl<T> Sub<Tree<T>> for Forest<T>
[src]
type Output = Forest<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: Tree<T>) -> Self
[src]
impl<'a, T: Clone> Sub<Tree<T>> for &'a Forest<T>
[src]
type Output = Forest<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: Tree<T>) -> Forest<T>
[src]
impl<T: Sync> Sync for Forest<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Forest<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Unpin for Forest<T>
impl<T> UnwindSafe for Forest<T> where
T: UnwindSafe,
T: 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<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> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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>,