Struct parallel_vec::ParallelVec
source · [−]pub struct ParallelVec<Param: ParallelVecParam> { /* private fields */ }Expand description
A contiguously growable heterogenous array type.
This type stores the values [structure of arrays] layout. This layout may improve cache utilizatoin in specific use cases, which may have.
Unlike a struct of Vecs, this type allocates memory for the all individual
fields simultaneously. This may minimize memory fragmentation and decrease
allocation pressure. It also only stores one length and capacity instead
of duplicating the values across multiple Vec fields.
Implementations
sourceimpl<Param: ParallelVecParam> ParallelVec<Param>
impl<Param: ParallelVecParam> ParallelVec<Param>
sourcepub fn new() -> Self
pub fn new() -> Self
Constructs a new, empty ParallelVec.
The vector will not allocate until elements are pushed onto it.
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Constructs a new, empty ParallelVec with the specified capacity.
The vector will be able to hold exactly capacity elements without reallocating. If capacity is 0, the vector will not allocate.
It is important to note that although the returned vector has the capacity specified, the vector will have a zero length.
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 number of elements the vector can hold without reallocating.
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(&self, index: usize) -> Option<Param::Ref>
pub fn get(&self, index: usize) -> Option<Param::Ref>
Returns a immutable reference to the element at index, if available, or
None if it is out of bounds.
sourcepub fn get_mut(&mut self, index: usize) -> Option<Param::RefMut>
pub fn get_mut(&mut self, index: usize) -> Option<Param::RefMut>
Returns a mutable reference to the element at index, if available, or
None if it is out of bounds.
sourcepub fn first(&self) -> Option<Param::Ref>
pub fn first(&self) -> Option<Param::Ref>
Returns the first element of the ParallelVec, or None if it is empty.
sourcepub fn first_mut(&mut self) -> Option<Param::RefMut>
pub fn first_mut(&mut self) -> Option<Param::RefMut>
Returns the mutable pointer first element of the ParallelVec, or None if it is empty.
sourcepub fn last(&self) -> Option<Param::Ref>
pub fn last(&self) -> Option<Param::Ref>
Returns the last element of the ParallelVec, or None if it is empty.
sourcepub fn last_mut(&mut self) -> Option<Param::RefMut>
pub fn last_mut(&mut self) -> Option<Param::RefMut>
Returns the mutable pointer last element of the ParallelVec, or None if it is empty.
sourcepub fn index(&self, index: usize) -> Param::Ref
pub fn index(&self, index: usize) -> Param::Ref
Gets a immutable reference to the elements at index.
Panics
This function will panic if index is >= self.len.
sourcepub fn index_mut(&mut self, index: usize) -> Param::RefMut
pub fn index_mut(&mut self, index: usize) -> Param::RefMut
Gets a mutable reference to the elements at index.
Panics
This function will panic if index is >= self.len.
sourcepub unsafe fn get_unchecked(&self, index: usize) -> Param::Ref
pub unsafe fn get_unchecked(&self, index: usize) -> Param::Ref
sourcepub unsafe fn get_unchecked_mut(&mut self, index: usize) -> Param::RefMut
pub unsafe fn get_unchecked_mut(&mut self, index: usize) -> Param::RefMut
sourcepub fn as_mut_ptrs(&mut self) -> Param::Ptr
pub fn as_mut_ptrs(&mut self) -> Param::Ptr
Returns a raw pointer to the slice’s buffer.
The caller must ensure that the slice outlives the pointer this function returns, or else it will end up pointing to garbage.
Modifying the container referenced by this slice may cause its buffer to be reallocated, which would also make any pointers to it invalid.
sourcepub fn as_slices_mut(&mut self) -> Param::SlicesMut
pub fn as_slices_mut(&mut self) -> Param::SlicesMut
Gets mutable individual slices for very sub-Vec.
sourcepub unsafe fn swap_unchecked(&mut self, a: usize, b: usize)
pub unsafe fn swap_unchecked(&mut self, a: usize, b: usize)
Swaps two elements in the slice, without doing bounds checking.
For a safe alternative see swap.
Arguments
a- The index of the first elementb- The index of the second element
Safety
Calling this method with an out-of-bounds index is undefined behavior.
The caller has to ensure that a < self.len() and b < self.len().
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 than 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 reverse(&mut self)
pub fn reverse(&mut self)
Reverses the order of elements in the ParallelVec, in place.
This is a O(n) operation.
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 swap_with(&mut self, other: &mut Self)
pub fn swap_with(&mut self, other: &mut Self)
Swaps all elements in self with those in other.
The length of other must be the same as self.
Panics
This function will panic if the two slices have different lengths.
sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the capacity of the vector as much as possible.
It will drop down as close as possible to the length but the allocator may still inform the vector that there is space for a few more elements.
sourcepub fn append(&mut self, other: &mut ParallelVec<Param>)
pub fn append(&mut self, other: &mut ParallelVec<Param>)
Moves all the elements of other into Self, leaving other empty.
sourcepub fn pop(&mut self) -> Option<Param>
pub fn pop(&mut self) -> Option<Param>
Removes the last element from the vector and returns it,
or None if it is empty.
sourcepub fn swap_remove(&mut self, index: usize) -> Param
pub fn swap_remove(&mut self, index: usize) -> Param
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.
sourcepub fn insert(&mut self, index: usize, value: Param)
pub fn insert(&mut self, index: usize, value: Param)
Inserts a value at index. Moves all of the elements above
index up one index. This is a O(N) operation.
Panics
This function will panic if index is greater than or equal to
len().
sourcepub fn remove(&mut self, index: usize) -> Option<Param>
pub fn remove(&mut self, index: usize) -> Option<Param>
Removes a value at index. Moves all of the elements above
index down one index. This is a O(N) operation.
Returns None if index is is greater than or equal to len().
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 ParallelVec. The collection may reserve more space to 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 iter(&self) -> Iter<'_, Param>ⓘNotable traits for Iter<'a, Param>impl<'a, Param: ParallelVecParam> Iterator for Iter<'a, Param> type Item = Param::Ref;
pub fn iter(&self) -> Iter<'_, Param>ⓘNotable traits for Iter<'a, Param>impl<'a, Param: ParallelVecParam> Iterator for Iter<'a, Param> type Item = Param::Ref;
Returns an iterator over the ParallelVec.
sourcepub fn iter_mut(&mut self) -> IterMut<'_, Param>ⓘNotable traits for IterMut<'a, Param>impl<'a, Param: ParallelVecParam> Iterator for IterMut<'a, Param> type Item = Param::RefMut;
pub fn iter_mut(&mut self) -> IterMut<'_, Param>ⓘNotable traits for IterMut<'a, Param>impl<'a, Param: ParallelVecParam> Iterator for IterMut<'a, Param> type Item = Param::RefMut;
Returns an iterator that allows modifying each value.
sourcepub fn iters(&self) -> Param::Iters
pub fn iters(&self) -> Param::Iters
Returns an iterator over the ParallelVec.
sourceimpl<Param: ParallelVecParam + Copy> ParallelVec<Param>
impl<Param: ParallelVecParam + Copy> ParallelVec<Param>
sourcepub fn repeat(&self, n: usize) -> ParallelVec<Param>
pub fn repeat(&self, n: usize) -> ParallelVec<Param>
Creates a ParallelVec by repeating self n times.
sourceimpl<Param: ParallelVecParam + Clone> ParallelVec<Param>
impl<Param: ParallelVecParam + Clone> ParallelVec<Param>
sourceimpl<Param: ParallelVecParam> ParallelVec<Param>
impl<Param: ParallelVecParam> ParallelVec<Param>
Trait Implementations
sourceimpl<Param: ParallelVecParam + Clone> Clone for ParallelVec<Param>
impl<Param: ParallelVecParam + Clone> Clone for ParallelVec<Param>
sourceimpl<Param: ParallelVecParam> Default for ParallelVec<Param>
impl<Param: ParallelVecParam> Default for ParallelVec<Param>
sourceimpl<Param: ParallelVecParam> Drop for ParallelVec<Param>
impl<Param: ParallelVecParam> Drop for ParallelVec<Param>
sourceimpl<Param: ParallelVecParam> Extend<Param> for ParallelVec<Param>
impl<Param: ParallelVecParam> Extend<Param> for ParallelVec<Param>
sourcefn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = Param>,
fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = Param>,
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl<Param: ParallelVecParam> IntoIterator for ParallelVec<Param>
impl<Param: ParallelVecParam> IntoIterator for ParallelVec<Param>
sourceimpl<T1: 'static, T2: 'static, T3: 'static, T4: 'static, T5: 'static, T6: 'static, T7: 'static, T8: 'static> TryFrom<(Vec<T1, Global>, Vec<T2, Global>, Vec<T3, Global>, Vec<T4, Global>, Vec<T5, Global>, Vec<T6, Global>, Vec<T7, Global>, Vec<T8, Global>)> for ParallelVec<(T1, T2, T3, T4, T5, T6, T7, T8)>
impl<T1: 'static, T2: 'static, T3: 'static, T4: 'static, T5: 'static, T6: 'static, T7: 'static, T8: 'static> TryFrom<(Vec<T1, Global>, Vec<T2, Global>, Vec<T3, Global>, Vec<T4, Global>, Vec<T5, Global>, Vec<T6, Global>, Vec<T7, Global>, Vec<T8, Global>)> for ParallelVec<(T1, T2, T3, T4, T5, T6, T7, T8)>
sourceimpl<T1: 'static, T2: 'static, T3: 'static, T4: 'static, T5: 'static, T6: 'static, T7: 'static> TryFrom<(Vec<T1, Global>, Vec<T2, Global>, Vec<T3, Global>, Vec<T4, Global>, Vec<T5, Global>, Vec<T6, Global>, Vec<T7, Global>)> for ParallelVec<(T1, T2, T3, T4, T5, T6, T7)>
impl<T1: 'static, T2: 'static, T3: 'static, T4: 'static, T5: 'static, T6: 'static, T7: 'static> TryFrom<(Vec<T1, Global>, Vec<T2, Global>, Vec<T3, Global>, Vec<T4, Global>, Vec<T5, Global>, Vec<T6, Global>, Vec<T7, Global>)> for ParallelVec<(T1, T2, T3, T4, T5, T6, T7)>
sourceimpl<T1: 'static, T2: 'static, T3: 'static, T4: 'static, T5: 'static, T6: 'static> TryFrom<(Vec<T1, Global>, Vec<T2, Global>, Vec<T3, Global>, Vec<T4, Global>, Vec<T5, Global>, Vec<T6, Global>)> for ParallelVec<(T1, T2, T3, T4, T5, T6)>
impl<T1: 'static, T2: 'static, T3: 'static, T4: 'static, T5: 'static, T6: 'static> TryFrom<(Vec<T1, Global>, Vec<T2, Global>, Vec<T3, Global>, Vec<T4, Global>, Vec<T5, Global>, Vec<T6, Global>)> for ParallelVec<(T1, T2, T3, T4, T5, T6)>
sourceimpl<T1: 'static, T2: 'static, T3: 'static, T4: 'static, T5: 'static> TryFrom<(Vec<T1, Global>, Vec<T2, Global>, Vec<T3, Global>, Vec<T4, Global>, Vec<T5, Global>)> for ParallelVec<(T1, T2, T3, T4, T5)>
impl<T1: 'static, T2: 'static, T3: 'static, T4: 'static, T5: 'static> TryFrom<(Vec<T1, Global>, Vec<T2, Global>, Vec<T3, Global>, Vec<T4, Global>, Vec<T5, Global>)> for ParallelVec<(T1, T2, T3, T4, T5)>
sourceimpl<T1: 'static, T2: 'static, T3: 'static, T4: 'static> TryFrom<(Vec<T1, Global>, Vec<T2, Global>, Vec<T3, Global>, Vec<T4, Global>)> for ParallelVec<(T1, T2, T3, T4)>
impl<T1: 'static, T2: 'static, T3: 'static, T4: 'static> TryFrom<(Vec<T1, Global>, Vec<T2, Global>, Vec<T3, Global>, Vec<T4, Global>)> for ParallelVec<(T1, T2, T3, T4)>
sourceimpl<T1: 'static, T2: 'static, T3: 'static, V3: 'static, T5: 'static, T6: 'static, T7: 'static, T8: 'static, T9: 'static, T10: 'static, T11: 'static, T12: 'static> TryFrom<(Vec<T1, Global>, Vec<T2, Global>, Vec<T3, Global>, Vec<V3, Global>, Vec<T5, Global>, Vec<T6, Global>, Vec<T7, Global>, Vec<T8, Global>, Vec<T9, Global>, Vec<T10, Global>, Vec<T11, Global>, Vec<T12, Global>)> for ParallelVec<(T1, T2, T3, V3, T5, T6, T7, T8, T9, T10, T11, T12)>
impl<T1: 'static, T2: 'static, T3: 'static, V3: 'static, T5: 'static, T6: 'static, T7: 'static, T8: 'static, T9: 'static, T10: 'static, T11: 'static, T12: 'static> TryFrom<(Vec<T1, Global>, Vec<T2, Global>, Vec<T3, Global>, Vec<V3, Global>, Vec<T5, Global>, Vec<T6, Global>, Vec<T7, Global>, Vec<T8, Global>, Vec<T9, Global>, Vec<T10, Global>, Vec<T11, Global>, Vec<T12, Global>)> for ParallelVec<(T1, T2, T3, V3, T5, T6, T7, T8, T9, T10, T11, T12)>
sourceimpl<T1: 'static, T2: 'static, T3: 'static, V3: 'static, T5: 'static, T6: 'static, T7: 'static, T8: 'static, T9: 'static, T10: 'static, T11: 'static> TryFrom<(Vec<T1, Global>, Vec<T2, Global>, Vec<T3, Global>, Vec<V3, Global>, Vec<T5, Global>, Vec<T6, Global>, Vec<T7, Global>, Vec<T8, Global>, Vec<T9, Global>, Vec<T10, Global>, Vec<T11, Global>)> for ParallelVec<(T1, T2, T3, V3, T5, T6, T7, T8, T9, T10, T11)>
impl<T1: 'static, T2: 'static, T3: 'static, V3: 'static, T5: 'static, T6: 'static, T7: 'static, T8: 'static, T9: 'static, T10: 'static, T11: 'static> TryFrom<(Vec<T1, Global>, Vec<T2, Global>, Vec<T3, Global>, Vec<V3, Global>, Vec<T5, Global>, Vec<T6, Global>, Vec<T7, Global>, Vec<T8, Global>, Vec<T9, Global>, Vec<T10, Global>, Vec<T11, Global>)> for ParallelVec<(T1, T2, T3, V3, T5, T6, T7, T8, T9, T10, T11)>
sourceimpl<T1: 'static, T2: 'static, T3: 'static, V3: 'static, T5: 'static, T6: 'static, T7: 'static, T8: 'static, T9: 'static, T10: 'static> TryFrom<(Vec<T1, Global>, Vec<T2, Global>, Vec<T3, Global>, Vec<V3, Global>, Vec<T5, Global>, Vec<T6, Global>, Vec<T7, Global>, Vec<T8, Global>, Vec<T9, Global>, Vec<T10, Global>)> for ParallelVec<(T1, T2, T3, V3, T5, T6, T7, T8, T9, T10)>
impl<T1: 'static, T2: 'static, T3: 'static, V3: 'static, T5: 'static, T6: 'static, T7: 'static, T8: 'static, T9: 'static, T10: 'static> TryFrom<(Vec<T1, Global>, Vec<T2, Global>, Vec<T3, Global>, Vec<V3, Global>, Vec<T5, Global>, Vec<T6, Global>, Vec<T7, Global>, Vec<T8, Global>, Vec<T9, Global>, Vec<T10, Global>)> for ParallelVec<(T1, T2, T3, V3, T5, T6, T7, T8, T9, T10)>
sourceimpl<T1: 'static, T2: 'static, T3: 'static, V3: 'static, T5: 'static, T6: 'static, T7: 'static, T8: 'static, T9: 'static> TryFrom<(Vec<T1, Global>, Vec<T2, Global>, Vec<T3, Global>, Vec<V3, Global>, Vec<T5, Global>, Vec<T6, Global>, Vec<T7, Global>, Vec<T8, Global>, Vec<T9, Global>)> for ParallelVec<(T1, T2, T3, V3, T5, T6, T7, T8, T9)>
impl<T1: 'static, T2: 'static, T3: 'static, V3: 'static, T5: 'static, T6: 'static, T7: 'static, T8: 'static, T9: 'static> TryFrom<(Vec<T1, Global>, Vec<T2, Global>, Vec<T3, Global>, Vec<V3, Global>, Vec<T5, Global>, Vec<T6, Global>, Vec<T7, Global>, Vec<T8, Global>, Vec<T9, Global>)> for ParallelVec<(T1, T2, T3, V3, T5, T6, T7, T8, T9)>
Auto Trait Implementations
impl<Param> RefUnwindSafe for ParallelVec<Param> where
<Param as ParallelVecParam>::Storage: RefUnwindSafe,
impl<Param> Send for ParallelVec<Param> where
<Param as ParallelVecParam>::Storage: Send,
impl<Param> Sync for ParallelVec<Param> where
<Param as ParallelVecParam>::Storage: Sync,
impl<Param> Unpin for ParallelVec<Param> where
<Param as ParallelVecParam>::Storage: Unpin,
impl<Param> UnwindSafe for ParallelVec<Param> where
<Param as ParallelVecParam>::Storage: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more