#[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

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:

  • data must be valid for both reads and writes for len * 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.
    • data must 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 as data for zero-length slices using ParallelParam::dangling().
  • data must point to len consecutive properly initialized values of type Param.

  • 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 than isize::MAX.

Returns the number of elements in the vector, also referred to as its ‘length’.

Returns true if the vector contains no elements.

Returns a immutable reference to the element at index, if available, or None if it is out of bounds.

Returns a mutable reference to the element at index, if available, or None if it is out of bounds.

Returns the first element of the slice, or None if it is empty.

Returns the mutable pointer first element of the slice, or None if it is empty.

Returns the last element of the slice, or None if it is empty.

Returns the mutable pointer last element of the slice, or None if it is empty.

Gets a immutable reference to the elements at index.

Panics

This function will panic if index >= self.len.

Gets a mutable reference to the elements at index.

Panics

This function will panic if index >= self.len.

Sets a value at an valid index in the slice.

Panics

This function will panic if index >= self.len.

Sets a value at an valid index in the slice without checking bounds.

Safety

The set is only safe if index >= self.len.

Returns references to elements, without doing bounds checking.

For a safe alternative see get.

Safety

Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used.

Returns mutable references to elements, without doing bounds checking.

For a safe alternative see get_mut.

Safety

Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used.

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.

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.

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.

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.

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.

Gets the individual slices for every sub-slice.

Gets mutable individual slices for every sub-slice.

Swaps two elements.

Arguments
  • a - The index of the first element
  • b - The index of the second element
Panics

Panics if a or b are out of bounds.

Swaps two elements in the slice, without doing bounds checking.

For a safe alternative see swap.

Arguments
  • a - The index of the first element
  • b - 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().

Reverses the order of elements in the ParallelSliceMut, in place.

This is a O(n) operation.

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.

Returns an iterator over the ParallelSliceMut.

Returns an iterator that allows modifying each value.

Returns an iterator over the ParallelSliceMut.

Gets individual iterators.

Fills self with elements by cloning value.

Fills self with elements returned by calling a closure repeatedly.

This method uses a closure to create new values. If you’d rather Clone a given value, use fill. If you want to use the Default trait to generate values, you can pass Default::default as the argument.

Trait Implementations

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.