Skip to main content

MultiArrayList

Struct MultiArrayList 

Source
pub struct MultiArrayList<T: SoaRow, A: Allocator = Global> { /* private fields */ }
Expand description

Struct-of-arrays list. See module docs.

Implementations§

Source§

impl<T: SoaRow> MultiArrayList<T, Global>

Source

pub const EMPTY: Self

Source§

impl<T: SoaRow, A: Allocator> MultiArrayList<T, A>

Source

pub const fn new_in(alloc: A) -> Self

Construct an empty list backed by alloc.

Source

pub fn len(&self) -> usize

Number of elements.

Source

pub fn is_empty(&self) -> bool

Source

pub fn capacity(&self) -> usize

Source

pub fn to_owned_slice(&mut self) -> Slice<T>
where A: Default,

The caller owns the returned memory. Empties this MultiArrayList. Only available with the global allocator (the returned Slice carries no allocator handle). Slice has no Drop; call Slice::deinit_owned.

Source

pub fn slice(&self) -> Slice<T>

Compute pointers to the start of each field of the array. If you need to access multiple fields, calling this may be more efficient than calling items() multiple times.

Source

pub fn items_named<F>(&self, name: &str) -> &[F]

Get the shared slice of values for field name (size-checked lookup).

Source

pub fn items_named_mut<F>(&mut self, name: &str) -> &mut [F]

Get the mutable slice of values for field name.

Source

pub fn items_raw_named<F>(&self, name: &str) -> *mut F

Raw column pointer; see [Slice::items_raw]. Obtaining the pointer is always sound; the read/write contract is on the caller’s dereference.

Source

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

Overwrite one array element with new data.

Source

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

Obtain all the data for one array element.

Returns ManuallyDrop<T> because the gathered struct is a bitwise copy of column storage that the list still owns; see Slice::get.

Source

pub fn push(&mut self, elem: T) -> Result<(), AllocError>

Extend the list by 1 element. Allocates more memory as necessary.

Source

pub fn append(&mut self, elem: T) -> Result<(), AllocError>

Alias for [push] (Zig: append).

Source

pub fn append_assume_capacity(&mut self, elem: T)

Extend the list by 1 element, asserting self.capacity is sufficient to hold an additional item.

Source

pub fn add_one(&mut self) -> Result<usize, AllocError>

Extend the list by 1 element, returning the newly reserved index with uninitialized data. Allocates more memory as necessary.

Source

pub fn add_one_assume_capacity(&mut self) -> usize

Extend the list by 1 element, asserting self.capacity is sufficient to hold an additional item. Returns the newly reserved index with uninitialized data.

Source

pub fn pop(&mut self) -> Option<T>

Remove and return the last element from the list, or return None if list is empty. Invalidates pointers to fields of the removed element.

Source

pub fn insert(&mut self, index: usize, elem: T) -> Result<(), AllocError>

Inserts an item into an ordered list. Shifts all elements after and including the specified index back by one and sets the given index to the specified element. May reallocate and invalidate iterators.

Source

pub fn insert_assume_capacity(&mut self, index: usize, elem: T)

Inserts an item into an ordered list which has room for it.

Source

pub fn append_list_assume_capacity(&mut self, other: &Self)

Source

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

Remove the specified item from the list, swapping the last item in the list into its position. Fast, but does not retain list ordering. Returns the removed element, like pop.

Source

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

Remove the specified item from the list, shifting items after it to preserve order. Returns the removed element, like pop.

Source

pub fn resize(&mut self, new_len: usize) -> Result<(), AllocError>

Adjust the list’s length to new_len. Does not initialize added items, if any.

Source

pub fn shrink_and_free(&mut self, new_len: usize)

Attempt to reduce allocated capacity to new_len.

Source

pub fn clear_and_free(&mut self)

Source

pub fn drop_elements(&mut self)

Run every element’s destructor, then reset to empty (len = 0, capacity retained).

Drop for this type is slab-only — it frees the SoA backing buffer but never runs column destructors (see the Drop impl for why: bitwise [clone] aliasing). When T has fields that own global-heap resources and the list is the unique owner, call this before the list goes out of scope or those payloads leak. No-op when !needs_drop::<T>().

Elements are dropped by gathering each row’s column bytes back into a stack T (the inverse of [scatter]) and letting it drop, so every field — not just one named column — is destructed.

Source

pub fn shrink_retaining_capacity(&mut self, new_len: usize)

Reduce length to new_len.

Source

pub fn clear_retaining_capacity(&mut self)

Invalidates all element pointers.

Source

pub fn ensure_total_capacity( &mut self, new_capacity: usize, ) -> Result<(), AllocError>

Modify the array so that it can hold at least new_capacity items.

Source

pub fn ensure_unused_capacity( &mut self, additional_count: usize, ) -> Result<(), AllocError>

Modify the array so that it can hold at least additional_count more items.

Source

pub fn set_capacity(&mut self, new_capacity: usize) -> Result<(), AllocError>

Modify the array so that it can hold exactly new_capacity items. new_capacity must be greater or equal to len.

Source

pub fn clone(&self) -> Result<Self, AllocError>
where A: Clone,

Create a copy of this list with a new backing store.

Source

pub fn sort<C: SortContext>(&mut self, ctx: &C)

Stable sort by index-based context.

Source

pub fn sort_span<C: SortContext>(&mut self, a: usize, b: usize, ctx: &C)

Stable sort of [a, b) by index-based context.

Source

pub fn sort_unstable<C: SortContext>(&mut self, ctx: &C)

Unstable sort by index-based context.

Source

pub fn sort_span_unstable<C: SortContext>( &mut self, a: usize, b: usize, ctx: &C, )

Unstable sort of [a, b) by index-based context.

Source

pub fn capacity_in_bytes(capacity: usize) -> usize

Source

pub fn memory_cost(&self) -> usize

Returns the amount of memory used by this list, in bytes.

Source

pub fn zero(&mut self)

Zero-initialize all allocated memory.

Source

pub unsafe fn set_len(&mut self, new_len: usize)

§Safety

new_len <= self.capacity(), and every column element in old_len..new_len must be initialized before any read.

Trait Implementations§

Source§

impl<T: SoaRow, A: Allocator + Default> Default for MultiArrayList<T, A>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: SoaRow, A: Allocator> Drop for MultiArrayList<T, A>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<T: SoaRow + Send, A: Allocator + Send> Send for MultiArrayList<T, A>

Auto Trait Implementations§

§

impl<T, A = Global> !Sync for MultiArrayList<T, A>

§

impl<T, A> Freeze for MultiArrayList<T, A>
where A: Freeze, PhantomData<T>: Freeze,

§

impl<T, A> RefUnwindSafe for MultiArrayList<T, A>

§

impl<T, A> Unpin for MultiArrayList<T, A>
where A: Unpin, PhantomData<T>: Unpin,

§

impl<T, A> UnsafeUnpin for MultiArrayList<T, A>

§

impl<T, A> UnwindSafe for MultiArrayList<T, A>

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> AsCtxPtr for T
where T: ?Sized,

Source§

fn as_ctx_ptr(&self) -> *mut Self
where Self: Sized,

self’s address as *mut Self for deferred-task / scopeguard / RefPtr::init_ref ctx slots. The closures/trampolines deref it as shared (&*p) — every method they reach is &self post-R-2, so no write provenance is required; the *mut spelling is purely to match the existing HasAutoFlush / RefCount ABI.
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V