Struct Lazy

Source
pub struct Lazy;
Expand description

The Lazy policy never reclaims closed nodes.

  • It never reclaims memory.
  • It never leads to implicit invalidation of node indices. In other words, a node index can only be invalidated if we remove that node from the tree (RemovedNode).

Compared to Auto, lazy approach has the following pros & cons:

  • (+) Node indices (NodeIdx<V>) created for a lazy tree will never be implicitly invalidated. Recall that, analogous to random access to an array element with its index, node indices allow for constant time access to the corresponding node. A node index can be invalidated if either of the following happens (i) the node is removed from the tree, (ii) other nodes are removed from the tree triggering a memory reclaim operation. With lazy policy, the second case can never happen.
  • (-) Uses more memory due to the gaps of the closed nodes especially when there exist many deletions from the tree.

Notice that the con can never be observed for grow-only situations; or might be insignificant when the number of removals is not very large. In such situations, it is the recommended memory reclaim policy.

Trait Implementations§

Source§

impl MemoryPolicy for Lazy

Source§

type MemoryReclaimPolicy<V> = MemoryReclaimNever where V: TreeVariant

Memory reclaim policy for the specific tree variant V.

Auto Trait Implementations§

§

impl Freeze for Lazy

§

impl RefUnwindSafe for Lazy

§

impl Send for Lazy

§

impl Sync for Lazy

§

impl Unpin for Lazy

§

impl UnwindSafe for Lazy

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> 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> SoM<T> for T

Source§

fn get_ref(&self) -> &T

Returns a reference to self.
Source§

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

Returns a mutable reference to self.
Source§

impl<T> SoR<T> for T

Source§

fn get_ref(&self) -> &T

Returns a reference to self.
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.