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
impl Tree
Sourcepub fn get_last_child(&self, entity: Entity) -> Option<Entity>
pub fn get_last_child(&self, entity: Entity) -> Option<Entity>
Returns the last child of an entity
Sourcepub fn get_child(&self, entity: Entity, n: usize) -> Option<Entity>
pub fn get_child(&self, entity: Entity, n: usize) -> Option<Entity>
Returns the nth child of an entity
Sourcepub fn get_num_children(&self, entity: Entity) -> Option<u32>
pub fn get_num_children(&self, entity: Entity) -> Option<u32>
Returns the number of children of an entity
Sourcepub fn get_parent(&self, entity: Entity) -> Option<Entity>
pub fn get_parent(&self, entity: Entity) -> Option<Entity>
Returns the parent of an entity
Sourcepub fn get_first_child(&self, entity: Entity) -> Option<Entity>
pub fn get_first_child(&self, entity: Entity) -> Option<Entity>
Returns the first child of an entity or None
if there isn’t one
Sourcepub fn get_next_sibling(&self, entity: Entity) -> Option<Entity>
pub fn get_next_sibling(&self, entity: Entity) -> Option<Entity>
Returns the next sibling of an entity or None
if there isn’t one
Sourcepub fn get_prev_sibling(&self, entity: Entity) -> Option<Entity>
pub fn get_prev_sibling(&self, entity: Entity) -> Option<Entity>
Returns the previous sibling of an entity or None
if there isn’t one
Sourcepub fn is_first_child(&self, entity: Entity) -> bool
pub fn is_first_child(&self, entity: Entity) -> bool
Returns true if the entity is the first child of its parent
pub fn is_last_child(&self, entity: Entity) -> bool
pub fn is_sibling(&self, entity1: Entity, entity2: Entity) -> bool
Sourcepub fn has_children(&self, entity: Entity) -> bool
pub fn has_children(&self, entity: Entity) -> bool
Returns true if the entity has children
Sourcepub fn remove(&mut self, entity: Entity) -> Result<(), TreeError>
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
pub fn set_first_child(&mut self, entity: Entity) -> Result<(), TreeError>
pub fn set_next_sibling( &mut self, entity: Entity, sibling: Entity, ) -> Result<(), TreeError>
pub fn set_prev_sibling( &mut self, entity: Entity, sibling: Entity, ) -> Result<(), TreeError>
pub fn set_parent(&mut self, entity: Entity, parent: Entity)
Trait Implementations§
Source§impl<'a> Hierarchy<'a> for Tree
impl<'a> Hierarchy<'a> for Tree
Source§type DownIter = IntoIter<Entity>
type DownIter = IntoIter<Entity>
A type representing an iterator that walks down the visual tree
Source§type UpIter = Rev<IntoIter<Entity>>
type UpIter = Rev<IntoIter<Entity>>
A type respresenting an iterator that walks up the visual tree
Source§type ChildIter = ChildIterator<'a>
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
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
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
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
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§impl<'a> IntoIterator for &'a Tree
impl<'a> IntoIterator for &'a Tree
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more