Struct parallel_vec::ParallelSliceMut
source · [−]#[repr(C)]pub struct ParallelSliceMut<'a, Param: ParallelParam> { /* private fields */ }Expand description
A mutable dynamically-sized view into a contiguous heterogeneous sequence. Contiguous here means that elements are laid out so that every element is the same distance from its neighbors.
Unlike a struct of slices, this type only stores one length instead of duplicating the values across multiple slice fields.
Implementations
sourceimpl<'a, Param: ParallelParam> ParallelSliceMut<'a, Param>
impl<'a, Param: ParallelParam> ParallelSliceMut<'a, Param>
sourcepub unsafe fn from_raw_parts(data: Param::Storage, len: usize) -> Self
pub unsafe fn from_raw_parts(data: Param::Storage, len: usize) -> Self
Forms a slice from a pointer and a length.
The len argument is the number of elements, not the number of bytes.
Safety
Behavior is undefined if any of the following conditions are violated:
-
datamust be valid for both reads and writes forlen * mem::size_of::<T>()many bytes, and it must be properly aligned. This means in particular:- The entire memory range of this slice must be contained within a single allocated object! Slices can never span across multiple allocated objects.
datamust be non-null and aligned even for zero-length slices. One reason for this is that enum layout optimizations may rely on references (including slices of any length) being aligned and non-null to distinguish them from other data. You can obtain a pointer that is usable asdatafor zero-length slices usingParallelParam::dangling().
-
datamust point tolenconsecutive properly initialized values of typeParam. -
The memory referenced by the returned slice must not be accessed through any other pointer (not derived from the return value) for the duration of lifetime
'a. Both read and write accesses are forbidden. -
The total size
len * mem::size_of::<T>()of the slice must be no larger thanisize::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 get<'b: 'a, I>(&'b self, index: I) -> Option<I::Output> where
I: ParallelSliceIndex<Self>,
pub fn get<'b: 'a, I>(&'b self, index: I) -> Option<I::Output> where
I: ParallelSliceIndex<Self>,
Returns a immutable reference to the element at index, if available, or
None if it is out of bounds.
sourcepub fn get_mut<I>(&mut self, index: I) -> Option<I::Output> where
I: ParallelSliceIndexMut<Self>,
pub fn get_mut<I>(&mut self, index: I) -> Option<I::Output> where
I: ParallelSliceIndexMut<Self>,
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 slice, 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 slice, 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 slice, 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 slice, or None if it is empty.
sourcepub fn index<I>(&self, index: I) -> I::Output where
I: ParallelSliceIndex<Self>,
pub fn index<I>(&self, index: I) -> I::Output where
I: ParallelSliceIndex<Self>,
Gets a immutable reference to the elements at index.
Panics
This function will panic if index >= self.len.
sourcepub fn index_mut<I>(&mut self, index: I) -> I::Output where
I: ParallelSliceIndexMut<Self>,
pub fn index_mut<I>(&mut self, index: I) -> I::Output where
I: ParallelSliceIndexMut<Self>,
Gets a mutable reference to the elements at index.
Panics
This function will panic if index >= self.len.
sourcepub unsafe fn set_unchecked(&mut self, index: usize, value: Param)
pub unsafe fn set_unchecked(&mut self, index: usize, value: Param)
Sets a value at an valid index in the slice without checking bounds.
Safety
The set is only safe if index >= 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 sort_by<F>(&mut self, f: F) where
F: Fn(Param::Ref, Param::Ref) -> Ordering,
pub fn sort_by<F>(&mut self, f: F) where
F: Fn(Param::Ref, Param::Ref) -> Ordering,
Sorts the slice with a comparator function.
This function will allocate sizeof(usize) * self.len bytes as an intermediate sorting
buffer.
This defers to the core implemenation of slice::sort_by, so any properties it
has will also hold for this function.
sourcepub fn sort_by_key<K, F>(&mut self, f: F) where
F: Fn(Param::Ref) -> K,
K: Ord,
pub fn sort_by_key<K, F>(&mut self, f: F) where
F: Fn(Param::Ref) -> K,
K: Ord,
Sorts the slice with a key extraction function.
This function will allocate sizeof(usize) * self.len bytes as an intermediate sorting
buffer.
This defers to the core implemenation of slice::sort_by_key, so any properties it
has will also hold for this function.
sourcepub fn sort_unstable_by<F>(&mut self, f: F) where
F: Fn(Param::Ref, Param::Ref) -> Ordering,
pub fn sort_unstable_by<F>(&mut self, f: F) where
F: Fn(Param::Ref, Param::Ref) -> Ordering,
Sorts the slice with a comparator function, but might not preserve the order of equal elements.
This function will allocate sizeof(usize) * self.len bytes as an intermediate sorting
buffer.
This defers to the core implemenation of slice::sort_unstable_by, so any properties it
has will also hold for this function.
sourcepub fn sort_unstable_by_key<K, F>(&mut self, f: F) where
F: Fn(Param::Ref) -> K,
K: Ord,
pub fn sort_unstable_by_key<K, F>(&mut self, f: F) where
F: Fn(Param::Ref) -> K,
K: Ord,
Sorts the slice with a key extraction function, but might not preserve the order of equal elements.
This function will allocate sizeof(usize) * self.len bytes as an intermediate sorting
buffer.
This defers to the core implemenation of slice::sort_unstable_by_key, so any properties
it has will also hold this function.
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 every sub-slice.
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 reverse(&mut self)
pub fn reverse(&mut self)
Reverses the order of elements in the ParallelSliceMut, in place.
This is a O(n) operation.
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 iter(&self) -> Iter<'a, Param>ⓘNotable traits for Iter<'a, Param>impl<'a, Param: ParallelParam> Iterator for Iter<'a, Param> type Item = Param::Ref;
pub fn iter(&self) -> Iter<'a, Param>ⓘNotable traits for Iter<'a, Param>impl<'a, Param: ParallelParam> Iterator for Iter<'a, Param> type Item = Param::Ref;
Returns an iterator over the ParallelSliceMut.
sourcepub fn iter_mut(&mut self) -> IterMut<'a, Param>ⓘNotable traits for IterMut<'a, Param>impl<'a, Param: ParallelParam> Iterator for IterMut<'a, Param> type Item = Param::RefMut;
pub fn iter_mut(&mut self) -> IterMut<'a, Param>ⓘNotable traits for IterMut<'a, Param>impl<'a, Param: ParallelParam> 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 ParallelSliceMut.
sourceimpl<'a, Param: ParallelParam + Clone> ParallelSliceMut<'a, Param>
impl<'a, Param: ParallelParam + Clone> ParallelSliceMut<'a, Param>
sourceimpl<'a, Param: ParallelParam> ParallelSliceMut<'a, Param>
impl<'a, Param: ParallelParam> ParallelSliceMut<'a, Param>
Trait Implementations
sourceimpl<'s, 'r, Param> Hash for ParallelSliceMut<'s, Param> where
Param: ParallelParam + 's,
Param::Ref: Hash,
'r: 's,
impl<'s, 'r, Param> Hash for ParallelSliceMut<'s, Param> where
Param: ParallelParam + 's,
Param::Ref: Hash,
'r: 's,
Auto Trait Implementations
impl<'a, Param> RefUnwindSafe for ParallelSliceMut<'a, Param> where
<Param as ParallelParam>::Storage: RefUnwindSafe,
impl<'a, Param> Send for ParallelSliceMut<'a, Param> where
<Param as ParallelParam>::Storage: Send,
impl<'a, Param> Sync for ParallelSliceMut<'a, Param> where
<Param as ParallelParam>::Storage: Sync,
impl<'a, Param> Unpin for ParallelSliceMut<'a, Param> where
<Param as ParallelParam>::Storage: Unpin,
impl<'a, Param> UnwindSafe for ParallelSliceMut<'a, Param> where
<Param as ParallelParam>::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