pub struct Tree<T> { /* private fields */ }Expand description
A tree where all values (T) are stored in a single contiguous list,
and the inner tree (Nodes) is made up of branches with indices into
the flat list.
This means fewer allocations when removing entire branches as we can reuse the memory for the values.
Implementations§
Source§impl<T> Tree<T>
impl<T> Tree<T>
pub fn view(&mut self) -> TreeView<'_, T>
Sourcepub fn get_mut(&mut self, value_id: ValueId) -> Option<&mut T>
pub fn get_mut(&mut self, value_id: ValueId) -> Option<&mut T>
Get a mutable refernence to a value
Sourcepub fn values(self) -> TreeValues<T>
pub fn values(self) -> TreeValues<T>
Consume the tree and return the values
Sourcepub fn drain_removed(&mut self) -> impl DoubleEndedIterator<Item = ValueId> + '_
pub fn drain_removed(&mut self) -> impl DoubleEndedIterator<Item = ValueId> + '_
Drain the removed value ids. This will not return keys that have been replaced.
Sourcepub fn with_value_mut<F, V>(&mut self, value_id: ValueId, f: F) -> V
pub fn with_value_mut<F, V>(&mut self, value_id: ValueId, f: F) -> V
Perform a given operation (F) on a mutable reference to a value in the tree
while still having mutable access to the rest of the tree.
§Panics
This will panic if the value is already checked out
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Tree<T>
impl<T> RefUnwindSafe for Tree<T>where
T: RefUnwindSafe,
impl<T> Send for Tree<T>where
T: Send,
impl<T> Sync for Tree<T>where
T: Sync,
impl<T> Unpin for Tree<T>where
T: Unpin,
impl<T> UnsafeUnpin for Tree<T>
impl<T> UnwindSafe for Tree<T>where
T: UnwindSafe,
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