Struct Tree

Source
pub struct Tree {
    pub parent: Vec<Option<Entity>>,
    pub first_child: Vec<Option<Entity>>,
    pub next_sibling: Vec<Option<Entity>>,
    pub prev_sibling: Vec<Option<Entity>>,
    pub changed: bool,
}
Expand description

The tree describes a tree of entities

Fields§

§parent: Vec<Option<Entity>>§first_child: Vec<Option<Entity>>§next_sibling: Vec<Option<Entity>>§prev_sibling: Vec<Option<Entity>>§changed: bool

Implementations§

Source§

impl Tree

Source

pub fn new() -> Tree

Creates a new tree with a root entity

Source

pub fn get_last_child(&self, entity: Entity) -> Option<Entity>

Returns the last child of an entity

Source

pub fn get_child(&self, entity: Entity, n: usize) -> Option<Entity>

Returns the nth child of an entity

Source

pub fn get_num_children(&self, entity: Entity) -> Option<u32>

Returns the number of children of an entity

Source

pub fn get_parent(&self, entity: Entity) -> Option<Entity>

Returns the parent of an entity

Source

pub fn get_first_child(&self, entity: Entity) -> Option<Entity>

Returns the first child of an entity or None if there isn’t one

Source

pub fn get_next_sibling(&self, entity: Entity) -> Option<Entity>

Returns the next sibling of an entity or None if there isn’t one

Source

pub fn get_prev_sibling(&self, entity: Entity) -> Option<Entity>

Returns the previous sibling of an entity or None if there isn’t one

Source

pub fn is_first_child(&self, entity: Entity) -> bool

Returns true if the entity is the first child of its parent

Source

pub fn is_last_child(&self, entity: Entity) -> bool

Source

pub fn is_sibling(&self, entity1: Entity, entity2: Entity) -> bool

Source

pub fn has_children(&self, entity: Entity) -> bool

Returns true if the entity has children

Source

pub fn remove(&mut self, entity: Entity) -> Result<(), TreeError>

Removes an entity from the tree

This method assumes that a check if the entity is alive has already been done prior to calling this method

Source

pub fn set_first_child(&mut self, entity: Entity) -> Result<(), TreeError>

Source

pub fn set_next_sibling( &mut self, entity: Entity, sibling: Entity, ) -> Result<(), TreeError>

Source

pub fn set_prev_sibling( &mut self, entity: Entity, sibling: Entity, ) -> Result<(), TreeError>

Source

pub fn set_parent(&mut self, entity: Entity, parent: Entity)

Source

pub fn add(&mut self, entity: Entity, parent: Entity) -> Result<(), TreeError>

Adds an entity to the tree with the specified parent

Trait Implementations§

Source§

impl Clone for Tree

Source§

fn clone(&self) -> Tree

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Tree

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'a> Hierarchy<'a> for Tree

Source§

type Item = Entity

A type respresenting a node in the visual tree
Source§

type DownIter = IntoIter<Entity>

A type representing an iterator that walks down the visual tree
Source§

type UpIter = Rev<IntoIter<Entity>>

A type respresenting an iterator that walks up the visual tree
Source§

type ChildIter = ChildIterator<'a>

A type representing an iterator which iterates through the children of a specified node
Source§

fn down_iter(&'a self) -> <Tree as Hierarchy<'a>>::DownIter

Returns an iterator which walks down the hierarchy
Source§

fn up_iter(&'a self) -> <Tree as Hierarchy<'a>>::UpIter

Returns an iterator which walks up the hierarchy
Source§

fn child_iter( &'a self, node: <Tree as Hierarchy<'a>>::Item, ) -> <Tree as Hierarchy<'a>>::ChildIter

Returns an iterator over the child nodes of a specified node
Source§

fn is_first_child(&self, node: <Tree as Hierarchy<'a>>::Item) -> bool

Returns true if the specified node is the first child of its parent
Source§

fn is_last_child(&self, node: <Tree as Hierarchy<'a>>::Item) -> bool

Returns true if the specified node is the last child of its parent
Source§

fn parent( &self, node: <Tree as Hierarchy<'a>>::Item, ) -> Option<<Tree as Hierarchy<'a>>::Item>

Get the parent node of the specified node
Source§

impl<'a> IntoIterator for &'a Tree

Source§

type Item = Entity

The type of the elements being iterated over.
Source§

type IntoIter = TreeIterator<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> <&'a Tree as IntoIterator>::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl Freeze for Tree

§

impl RefUnwindSafe for Tree

§

impl Send for Tree

§

impl Sync for Tree

§

impl Unpin for Tree

§

impl UnwindSafe for Tree

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Node for T
where T: 'static,