pub struct Soa<T>where
T: Soapy,{ /* private fields */ }Implementations§
source§impl<T> Soa<T>where
T: Soapy,
impl<T> Soa<T>where
T: Soapy,
sourcepub fn new() -> Self
pub fn new() -> Self
Constructs a new, empty Soa<T>.
The container will not allocate until elements are pushed onto it.
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Construct a new, empty Soa<T> with at least the specified capacity.
The container will be able to hold capacity elements without
reallocating. If the capacity is 0, the container will not allocate.
Note that although the returned vector has the minimum capacity
specified, the vector will have a zero length. The capacity will be as
specified unless T is zero-sized, in which case the capacity will be
usize::MAX.
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of elements in the vector, also referred to as its length.
sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the total number of elements the container can hold without reallocating.
sourcepub fn into_raw_parts(self) -> (*mut u8, usize, usize)
pub fn into_raw_parts(self) -> (*mut u8, usize, usize)
Decomposes a Soa<T> into its raw components.
Returns the raw pointer to the underlying data, the length of the vector (in
elements), and the allocated capacity of the data (in elements). These
are the same arguments in the same order as the arguments to
Soa::from_raw_parts.
After calling this function, the caller is responsible for the memory
previously managed by the Soa. The only way to do this is to convert the
raw pointer, length, and capacity back into a Vec with the
Soa::from_raw_parts function, allowing the destructor to perform the cleanup.
sourcepub unsafe fn from_raw_parts(
ptr: *mut u8,
length: usize,
capacity: usize
) -> Self
pub unsafe fn from_raw_parts( ptr: *mut u8, length: usize, capacity: usize ) -> Self
Creates a Soa<T> from a pointer, a length, and a capacity.
Safety
This is highly unsafe due to the number of invariants that aren’t
checked. Given that many of these invariants are private implementation
details of RawSoa, it is better not to uphold them manually. Rather,
it only valid to call this method with the output of a previous call to
Soa::into_raw_parts.
sourcepub fn pop(&mut self) -> Option<T>
pub fn pop(&mut self) -> Option<T>
Removes the last element from a vector and returns it, or None if it
is empty.
sourcepub fn insert(&mut self, index: usize, element: T)
pub fn insert(&mut self, index: usize, element: T)
Inserts an element at position index, shifting all elements after it
to the right.
Panics
Panics if index > len
sourcepub fn remove(&mut self, index: usize) -> T
pub fn remove(&mut self, index: usize) -> T
Removes and returns the element at position index within the vector, shifting all elements after it to the left.
sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional more elements to be inserted
in the given Soa<T>. The collection may reserve more space to
speculatively avoid frequent reallocations. After calling reserve,
capacity will be greater than or equal to self.len() + additional. Does
nothing if capacity is already sufficient.
sourcepub fn reserve_exact(&mut self, additional: usize)
pub fn reserve_exact(&mut self, additional: usize)
Reserves the minimum capacity for at least additional more elements to
be inserted in the given Soa<T>. Unlike Soa::reserve, this will not
deliberately over-allocate to speculatively avoid frequent allocations.
After calling reserve_exact, capacity will be greater than or equal to
self.len() + additional. Does nothing if the capacity is already
sufficient.
sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the capacity of the container as much as possible.
sourcepub fn shrink_to(&mut self, min_capacity: usize)
pub fn shrink_to(&mut self, min_capacity: usize)
Shrinks the capacity of the vector with a lower bound.
The capacity will remain at least as large as both the length and the supplied value. If the current capacity is less than the lower limit, this is a no-op.
sourcepub fn truncate(&mut self, len: usize)
pub fn truncate(&mut self, len: usize)
Shortens the vector, keeping the first len elements and dropping the rest.
If len is greater or equal to the vector’s current length, this has no effect. Note that this method has no effect on the allocated capacity of the vector.
sourcepub fn swap_remove(&mut self, index: usize) -> T
pub fn swap_remove(&mut self, index: usize) -> T
Removes an element from the vector and returns it.
The removed element is replaced by the last element of the vector. This does not preserve ordering, but is O(1). If you need to preserve the element order, use remove instead.
Panics
Panics if index is out of bounds.
sourcepub fn append(&mut self, other: &mut Self)
pub fn append(&mut self, other: &mut Self)
Moves all the elements of other into self, leaving other empty.
sourcepub fn iter(&self) -> Iter<'_, T> ⓘ
pub fn iter(&self) -> Iter<'_, T> ⓘ
Returns an iterator over the elements.
The iterator yields all items from start to end.
sourcepub fn iter_mut(&mut self) -> IterMut<'_, T> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_, T> ⓘ
Returns an iterator over the elements that allows modifying each value.
The iterator yields all items from start to end.
pub fn try_fold<F, B>(&self, init: B, f: F) -> B
pub fn try_fold_zip<F, B, O>(&self, other: &Soa<O>, init: B, f: F) -> B
sourcepub fn for_each_zip<F, O>(&self, other: &Soa<O>, f: F)
pub fn for_each_zip<F, O>(&self, other: &Soa<O>, f: F)
Calls a closure on each element of the collection.
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears the vector, removing all values.
Note that this method has no effect on the allocated capacity of the vector.
sourcepub fn get<I>(&self, index: I) -> Option<I::Output<'_>>where
I: SoaIndex<T>,
pub fn get<I>(&self, index: I) -> Option<I::Output<'_>>where
I: SoaIndex<T>,
Returns a reference to an element or subslice depending on the type of index.
sourcepub fn nth_cloned(&self, index: usize) -> Twhere
T: Clone,
pub fn nth_cloned(&self, index: usize) -> Twhere
T: Clone,
sourcepub fn slices(&self) -> <T::RawSoa as RawSoa<T>>::Slices<'_>
pub fn slices(&self) -> <T::RawSoa as RawSoa<T>>::Slices<'_>
Returns slices for each of the SoA fields.
sourcepub fn get_mut<I>(&mut self, index: I) -> Option<I::OutputMut<'_>>where
I: SoaIndex<T>,
pub fn get_mut<I>(&mut self, index: I) -> Option<I::OutputMut<'_>>where
I: SoaIndex<T>,
Returns a mutable reference to an element or subslice depending on the type of index.
sourcepub fn slices_mut(&mut self) -> <T::RawSoa as RawSoa<T>>::SlicesMut<'_>
pub fn slices_mut(&mut self) -> <T::RawSoa as RawSoa<T>>::SlicesMut<'_>
Returns mutable slices for each of the SoA fields.
Trait Implementations§
source§impl<T> Extend<T> for Soa<T>where
T: Soapy,
impl<T> Extend<T> for Soa<T>where
T: Soapy,
source§fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)source§impl<T> FromIterator<T> for Soa<T>where
T: Soapy,
impl<T> FromIterator<T> for Soa<T>where
T: Soapy,
source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
source§impl<T> IntoIterator for Soa<T>where
T: Soapy,
impl<T> IntoIterator for Soa<T>where
T: Soapy,
source§impl<T> Ord for Soa<T>
impl<T> Ord for Soa<T>
source§impl<T> PartialEq for Soa<T>
impl<T> PartialEq for Soa<T>
source§impl<T> PartialOrd for Soa<T>where
T: Soapy + PartialOrd,
impl<T> PartialOrd for Soa<T>where
T: Soapy + PartialOrd,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more