Struct PackedArray

Source
pub struct PackedArray<T, const N: usize> { /* private fields */ }
Expand description

Densly packed data structure for fast iteration

Implementations§

Source§

impl<T, const N: usize> PackedArray<T, N>

Source

pub fn new() -> Self

Return new PackedArray with allocated storage

Source

pub fn len(&self) -> usize

Returns current number of elements stored

Source

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

Returns true if there is a valid entry under index

Source

pub fn full(&self) -> bool

Returns true if allocated memory is exhausted True also means that no more entries can be added

Source

pub fn get(&self, index: usize) -> &T

Returns reference to an element at index Panics if there is no valid element with such index

Source

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

Return mutable reference to an element at index Panics if there is no valid element with such index

Source

pub fn append(&mut self, value: T) -> usize

Adds element to the end of array. Return index of newly-added element for future access Panics if structure is full

Source

pub fn set(&mut self, index: usize, value: T)

Sets value of passed index If there is no valid element with such index, element is added

Source

pub fn remove(&mut self, index: usize)

Removes element by given index Panics if there is no valid element with such index

Source

pub fn as_slice(&self) -> &[T]

Returns an underlying storage as slice

Source

pub fn as_slice_mut(&mut self) -> &mut [T]

Returns an underlying storage as mutable slice

Source

pub fn iter(&self) -> Iter<'_, T>

Returns an iterator to underlying storage

Source

pub fn iter_mut(&mut self) -> IterMut<'_, T>

Return a mutable iterator to underlying storage

Trait Implementations§

Source§

impl<T, const N: usize> Index<usize> for PackedArray<T, N>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T, const N: usize> IndexMut<usize> for PackedArray<T, N>

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<T, const N: usize> Freeze for PackedArray<T, N>

§

impl<T, const N: usize> RefUnwindSafe for PackedArray<T, N>
where T: RefUnwindSafe,

§

impl<T, const N: usize> !Send for PackedArray<T, N>

§

impl<T, const N: usize> !Sync for PackedArray<T, N>

§

impl<T, const N: usize> Unpin for PackedArray<T, N>
where T: Unpin,

§

impl<T, const N: usize> UnwindSafe for PackedArray<T, N>

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.