Dynamic

Struct Dynamic 

Source
pub struct Dynamic;
Expand description

The marker type that indicates a dynamic state for a Sector.

In this state, the sector is implemented as a dynamically resizing vector. The dynamic behavior includes growing the allocation when the number of elements reaches the current capacity, and shrinking the allocation when a significant number of elements are removed. The resizing factors are determined by the following rules:

  • Growth: When pushing elements and the current length equals the capacity, the sector will grow its allocation. The new capacity is increased iteratively until it can accommodate the new length. The growth factor is determined by a manual unchecked growth function that typically doubles (or follows a similar pattern) the capacity.
  • Shrinkage: When the sector’s length falls to or below half of its capacity, and the capacity is at least 4, the capacity is reduced. The new capacity is calculated as three-quarters of the old capacity plus a remainder (the modulus of the old capacity by 4). This approach helps to prevent excessive allocation while ensuring a smooth transition when elements are removed.

This state is intended for use cases where the number of elements is expected to vary significantly.

Trait Implementations§

Auto Trait Implementations§

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, 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.