Struct KeyValueBucketArray

Source
pub(crate) struct KeyValueBucketArray<'k, 'v, const N: usize, const CAP: usize, C: Count, K: Key, KS: KeyStorage<K>, V: Copy>(BucketArrayPair<'k, 'v, N, CAP, C, KS, V>, PhantomData<K>);
Expand description

Concrete bucket array with parallel BucketArrayMemory for key and value storage

This is the basic data type used for one layer of sorting buckets.

Takes several type parameters so the narrowest possible types can be chosen for counters, keys, and values. Keys take two types: the ‘wide’ version that appears in the API and a ‘storage’ version that’s been stripped of the data redundant with its bucket position.

The validity of BucketArrayMemory entries is ensured by the combination of our mutable ref to the BucketArrayMemory itself and our tracking of bucket counts within the lifetime of that reference.

Tuple Fields§

§0: BucketArrayPair<'k, 'v, N, CAP, C, KS, V>§1: PhantomData<K>

Implementations§

Source§

impl<'k, 'v, const N: usize, const CAP: usize, C: Count, K: Key, KS: KeyStorage<K>, V: Copy> KeyValueBucketArray<'k, 'v, N, CAP, C, K, KS, V>

Source

pub(crate) fn new( key_mem: &'k mut BucketArrayMemory<N, CAP, KS>, value_mem: &'v mut BucketArrayMemory<N, CAP, V>, ) -> Self

A new KeyValueBucketArray wraps two mutable BucketArrayMemory references and adds state to track which items are valid.

Source

pub(crate) fn drop_key_storage(self) -> ValueBucketArray<'v, N, CAP, C, K, V>

Keep the counts and the value memory but drop the key memory.

Returns a new ValueBucketArray.

Trait Implementations§

Source§

impl<'k, 'v, const N: usize, const CAP: usize, C: Count, K: Key, KS: KeyStorage<K>, V: Copy> Insert<K, V> for KeyValueBucketArray<'k, 'v, N, CAP, C, K, KS, V>

Source§

fn insert(&mut self, key: K, value: V) -> Result<(), ()>

Append a new item to its sorting bucket, or return Err(()) if it’s full
Source§

impl<'k, 'v, const N: usize, const CAP: usize, C: Count, K: Key, KS: KeyStorage<K>, V: Copy> KeyLookup<KS, K> for KeyValueBucketArray<'k, 'v, N, CAP, C, K, KS, V>

Source§

fn item_stored_key(&self, bucket: usize, item: usize) -> KS

Retrieve the stored key remainder bits for this item
Source§

fn item_full_key(&self, bucket: usize, item: usize) -> K

Retrieve the key for a particular item, as a full width key
Source§

impl<'k, 'v, const N: usize, const CAP: usize, C: Count, K: Key, KS: KeyStorage<K>, V: Copy> Shape<K> for KeyValueBucketArray<'k, 'v, N, CAP, C, K, KS, V>

Source§

const NUM_BUCKETS: usize = N

Number of buckets in the array

Source§

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

Get the range of items within a single bucket.
Source§

fn divisor(&self) -> K

Get the key divisor: the number of buckets but as a Key instance.
Source§

fn split_wide_key(&self, key: K) -> (usize, K)

Split a wide key into the bucket index and the remaining bits.
Source§

fn join_wide_key(&self, bucket: usize, remainder: K) -> K

Rebuild a wide key from its split components.
Source§

impl<'k, 'v, const N: usize, const CAP: usize, C: Count, K: Key, KS: KeyStorage<K>, V: Copy> ValueLookup<V> for KeyValueBucketArray<'k, 'v, N, CAP, C, K, KS, V>

Source§

fn item_value(&self, bucket: usize, item: usize) -> V

Retrieve the Value for a particular item

Auto Trait Implementations§

§

impl<'k, 'v, const N: usize, const CAP: usize, C, K, KS, V> Freeze for KeyValueBucketArray<'k, 'v, N, CAP, C, K, KS, V>
where C: Freeze,

§

impl<'k, 'v, const N: usize, const CAP: usize, C, K, KS, V> RefUnwindSafe for KeyValueBucketArray<'k, 'v, N, CAP, C, K, KS, V>

§

impl<'k, 'v, const N: usize, const CAP: usize, C, K, KS, V> Send for KeyValueBucketArray<'k, 'v, N, CAP, C, K, KS, V>
where K: Send, C: Send, KS: Send, V: Send,

§

impl<'k, 'v, const N: usize, const CAP: usize, C, K, KS, V> Sync for KeyValueBucketArray<'k, 'v, N, CAP, C, K, KS, V>
where K: Sync, C: Sync, KS: Sync, V: Sync,

§

impl<'k, 'v, const N: usize, const CAP: usize, C, K, KS, V> Unpin for KeyValueBucketArray<'k, 'v, N, CAP, C, K, KS, V>
where K: Unpin, C: Unpin,

§

impl<'k, 'v, const N: usize, const CAP: usize, C, K, KS, V> !UnwindSafe for KeyValueBucketArray<'k, 'v, N, CAP, C, K, KS, V>

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.