pub struct BucketArrayPair<'a, 'b, const N: usize, const CAP: usize, C: Count, A: Copy, B: Copy> {
mem_a: &'a mut BucketArrayMemory<N, CAP, A>,
mem_b: &'b mut BucketArrayMemory<N, CAP, B>,
state: BucketState<N, CAP, C>,
}
Expand description
Concrete binding between one BucketState
and a pair of BucketArrayMemory
Fields§
§mem_a: &'a mut BucketArrayMemory<N, CAP, A>
Reference to external backing memory for type A
mem_b: &'b mut BucketArrayMemory<N, CAP, B>
Reference to external backing memory for type B
state: BucketState<N, CAP, C>
Tracking for which items are in use within each bucket
Implementations§
Source§impl<'a, 'b, const N: usize, const CAP: usize, C: Count, A: Copy, B: Copy> BucketArrayPair<'a, 'b, N, CAP, C, A, B>
impl<'a, 'b, const N: usize, const CAP: usize, C: Count, A: Copy, B: Copy> BucketArrayPair<'a, 'b, N, CAP, C, A, B>
Sourcepub fn new(
mem_a: &'a mut BucketArrayMemory<N, CAP, A>,
mem_b: &'b mut BucketArrayMemory<N, CAP, B>,
) -> Self
pub fn new( mem_a: &'a mut BucketArrayMemory<N, CAP, A>, mem_b: &'b mut BucketArrayMemory<N, CAP, B>, ) -> Self
A new BucketArray
wraps a new BucketState
and two BucketArrayMemory
Sourcepub fn item_range(&self, bucket: usize) -> Range<usize>
pub 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.
Sourcepub fn item_value_first(&self, bucket: usize, item: usize) -> A
pub fn item_value_first(&self, bucket: usize, item: usize) -> A
Look up the first value for one item in one bucket.
Panics if the indices are out of range.
Sourcepub fn item_value_second(&self, bucket: usize, item: usize) -> B
pub fn item_value_second(&self, bucket: usize, item: usize) -> B
Look up the second value for one item in one bucket.
Panics if the indices are out of range.
Sourcepub fn insert(&mut self, bucket: usize, first: A, second: B) -> Result<(), ()>
pub fn insert(&mut self, bucket: usize, first: A, second: B) -> Result<(), ()>
Append a new item pair to a bucket.
If the bucket is full, returns Err(()) and makes no changes.
Sourcepub fn drop_first(self) -> BucketArray<'b, N, CAP, C, B>
pub fn drop_first(self) -> BucketArray<'b, N, CAP, C, B>
Transfer the BucketState
to a new single BucketArray
,
keeping the second half and dropping the first.