Struct BucketState

Source
struct BucketState<const N: usize, const CAP: usize, C: Count> {
    counts: [C; N],
}
Expand description

Common implementation for key/value and value-only bucket arrays

Tracks the number of items in each bucket. This is used by BucketArray and BucketArrayPair implementations to safely access only initialized items in the BucketArrayMemory.

Fields§

§counts: [C; N]

Number of initialized items in each bucket

Each bucket B’s valid item range would be (0 .. counts[B])

Implementations§

Source§

impl<const N: usize, const CAP: usize, C: Count> BucketState<N, CAP, C>

Source

fn new() -> Self

Create a new counter store.

This will happen inside the lifetime of our mutable reference to the backing store memory.

Source

fn insert<F: FnMut(usize)>( &mut self, bucket: usize, writer: F, ) -> Result<(), ()>

Append a new item to a specific bucket using a writer callback.

The writer is invoked with an item index, after checking bucket capacity but before marking the new item as written.

The writer must unconditionally write to the index it’s given, in each of the backing memories covered by this state tracker.

Source

fn item_range(&self, bucket: usize) -> Range<usize>

Look up the valid item range for a particular bucket.

Panics if the bucket index is out of range. Item indices inside the returned range are initialized, and any outside may be uninitialized.

Auto Trait Implementations§

§

impl<const N: usize, const CAP: usize, C> Freeze for BucketState<N, CAP, C>
where C: Freeze,

§

impl<const N: usize, const CAP: usize, C> RefUnwindSafe for BucketState<N, CAP, C>
where C: RefUnwindSafe,

§

impl<const N: usize, const CAP: usize, C> Send for BucketState<N, CAP, C>
where C: Send,

§

impl<const N: usize, const CAP: usize, C> Sync for BucketState<N, CAP, C>
where C: Sync,

§

impl<const N: usize, const CAP: usize, C> Unpin for BucketState<N, CAP, C>
where C: Unpin,

§

impl<const N: usize, const CAP: usize, C> UnwindSafe for BucketState<N, CAP, C>
where C: UnwindSafe,

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

Source§

type Output = T

Should always be 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.