Struct AutoWithThreshold

Source
pub struct AutoWithThreshold<const D: usize>;
Expand description

The AutoWithThreshold policy reclaims closed nodes whenever the utilization falls below a certain threshold which is determined by the constant parameter D.

  • This is a generalization of the Auto policy; in particular, Auto is equivalent to AutoWithThreshold<2>.
  • Its constant parameter D defines the utilization threshold to trigger the memory reclaim operation.
  • Specifically, memory of closed nodes will be reclaimed whenever the ratio of closed nodes to all nodes exceeds one over 2^D. The greater the D, the greater the utilization threshold.
    • when D = 0: memory will be reclaimed when utilization is below 0.00% (equivalent to never).
    • when D = 1: memory will be reclaimed when utilization is below 50.00%.
    • when D = 2: memory will be reclaimed when utilization is below 75.00%.
    • when D = 3: memory will be reclaimed when utilization is below 87.50%.
    • when D = 4: memory will be reclaimed when utilization is below 93.75%.

Compared to Lazy, auto approach has the following pros & cons:

  • (+) Node indices (NodeIdx<V>) created for an auto-reclaim tree will can 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 auto policy, both the explicit (i) and implicit (ii) invalidation can occur.
  • (-) Uses memory efficiently making sure that utilization can never go below a constant threshold.

Since Auto is the default memory policy, we do not need to include it in the tree type signature.

In order to observe the impact of the memory reclaim policy on validity of the node indices, please see the Examples section of MemoryPolicy.

Trait Implementationsยง

Sourceยง

impl<const D: usize> MemoryPolicy for AutoWithThreshold<D>

Sourceยง

type MemoryReclaimPolicy<V> = MemoryReclaimOnThreshold<D, V, <V as TreeVariant>::Reclaimer> where V: TreeVariant

Memory reclaim policy for the specific tree variant V.

Auto Trait Implementationsยง

ยง

impl<const D: usize> Freeze for AutoWithThreshold<D>

ยง

impl<const D: usize> RefUnwindSafe for AutoWithThreshold<D>

ยง

impl<const D: usize> Send for AutoWithThreshold<D>

ยง

impl<const D: usize> Sync for AutoWithThreshold<D>

ยง

impl<const D: usize> Unpin for AutoWithThreshold<D>

ยง

impl<const D: usize> UnwindSafe for AutoWithThreshold<D>

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.