Skip to main content

MaskTrackedArray

Trait MaskTrackedArray 

Source
pub trait MaskTrackedArray<T>:
    Default
    + FromIterator<T>
    + FromIterator<(usize, T)> {
    type MaskType: Mask;

Show 22 methods // Required methods fn contains_item_at(&self, index: usize) -> bool; fn len(&self) -> u32; fn clear(&mut self); unsafe fn get_unchecked_ref(&self, index: usize) -> &T; unsafe fn get_unchecked_mut(&self, index: usize) -> &mut T; unsafe fn insert_unchecked(&self, index: usize, value: T); unsafe fn remove_unchecked(&self, index: usize) -> T; fn iter_filled_indices(&self) -> impl Iterator<Item = usize>; fn iter_filled_indices_mask( &self, mask: Self::MaskType, ) -> impl Iterator<Item = usize>; fn iter_empty_indices(&self) -> impl Iterator<Item = usize>; fn mask(&self) -> Self::MaskType; // Provided methods fn is_empty(&self) -> bool { ... } fn new() -> Self { ... } fn get_ref(&self, index: usize) -> Option<&T> { ... } fn get_mut(&mut self, index: usize) -> Option<&mut T> { ... } fn insert(&self, index: usize, value: T) -> Option<T> { ... } fn remove(&mut self, index: usize) -> Option<T> { ... } fn iter<'a>(&'a self) -> impl Iterator<Item = &'a T> where T: 'a { ... } fn iter_mut<'a>(&'a mut self) -> impl Iterator<Item = &'a mut T> where T: 'a { ... } fn iter_mask<'a>( &'a self, mask: Self::MaskType, ) -> impl Iterator<Item = &'a T> where T: 'a { ... } fn iter_mut_mask<'a>( &'a mut self, mask: Self::MaskType, ) -> impl Iterator<Item = &'a mut T> where T: 'a { ... } fn push(&mut self, value: T) -> Result<usize, T> { ... }
}
Expand description

Implemented by every variant of the mask tracked array. The MaskTrackedArray::MaskType is the number type used for the mask.

Required Associated Types§

Source

type MaskType: Mask

The number type used as the mask.

Required Methods§

Source

fn contains_item_at(&self, index: usize) -> bool

Check if there is an item at a slot. This function will also return false if the index is out of range.

Source

fn len(&self) -> u32

Check how many slots are occupied.

Source

fn clear(&mut self)

Clear out all items in this array, returning to its empty state. Drop is called if needed.

Source

unsafe fn get_unchecked_ref(&self, index: usize) -> &T

Get an immutable reference to slot without bounds or validity checking.

§Safety

The given index must be valid.

Source

unsafe fn get_unchecked_mut(&self, index: usize) -> &mut T

Get a mutable reference to a slot without bounds, validity or borrow checking.

§Safety

The given index must be valid and there must be no other references to the same slot.

Source

unsafe fn insert_unchecked(&self, index: usize, value: T)

Insert an item at a given index without bounds, validity or borrow checking.

§Safety

The given index must be valid to avoid undefined behaviour. If a value was already present, that value will be forgotten without running its drop implementation.

Source

unsafe fn remove_unchecked(&self, index: usize) -> T

Remove a value from a slot without checking the index or if the item is there.

§Safety

Calling this function on currently referenced or nonexistent slots will result in undefined behaviour.

Source

fn iter_filled_indices(&self) -> impl Iterator<Item = usize>

Get an iterator over all filled slot indices.

Source

fn iter_filled_indices_mask( &self, mask: Self::MaskType, ) -> impl Iterator<Item = usize>

Get an iterator over all filled slot indices also present in the given mask.

Source

fn iter_empty_indices(&self) -> impl Iterator<Item = usize>

Get an iterator over all unfilled slot indices.

Source

fn mask(&self) -> Self::MaskType

Get the internal mask used.

Provided Methods§

Source

fn is_empty(&self) -> bool

Returns true if this array is completely empty.

Source

fn new() -> Self

Construct a new empty instance of this array.

Source

fn get_ref(&self, index: usize) -> Option<&T>

Get a reference to an item inside a slot if available.

Source

fn get_mut(&mut self, index: usize) -> Option<&mut T>

Get a mutable reference to an item inside a slot if available.

Source

fn insert(&self, index: usize, value: T) -> Option<T>

Try to insert an item at a given index. If insertion fails, return the value in an option. If the option is none then the insertion succeeded.

Source

fn remove(&mut self, index: usize) -> Option<T>

Remove a value at a specific index and return it if available.

Source

fn iter<'a>(&'a self) -> impl Iterator<Item = &'a T>
where T: 'a,

Iterate over references to every filled slot.

Source

fn iter_mut<'a>(&'a mut self) -> impl Iterator<Item = &'a mut T>
where T: 'a,

Iterate over mutable references to every filled slot.

Source

fn iter_mask<'a>(&'a self, mask: Self::MaskType) -> impl Iterator<Item = &'a T>
where T: 'a,

Iterate over references which are only present in the given mask.

Source

fn iter_mut_mask<'a>( &'a mut self, mask: Self::MaskType, ) -> impl Iterator<Item = &'a mut T>
where T: 'a,

Iterate over mutable references which are only present in the given mask.

Source

fn push(&mut self, value: T) -> Result<usize, T>

Try to push a value into the lowest indexed position possible. Returns the value if failed.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§