pub struct PointerParSlice;Expand description
Utility struct for contructors for slices that allow unsynchronized access
to their elements through PointerIndex and PointerChunkIndex.
Implementations§
Source§impl PointerParSlice
impl PointerParSlice
Sourcepub fn new<T: Default + Send + Sync>(
len: usize,
) -> impl PointerIndex<T> + ParCollection<Box<[T]>>
pub fn new<T: Default + Send + Sync>( len: usize, ) -> impl PointerIndex<T> + ParCollection<Box<[T]>>
Constructs a new slice with len elements, each initialized
to T::default, that allows unsynchronized
access to its elements through PointerIndex and that can be
converted into a boxed slice.
§Examples
let pointer_slice = PointerParSlice::new(4);
unsafe {
*pointer_slice.get_mut_ptr(0) = 42;
}
assert_eq!(pointer_slice.into().as_ref(), &[42, 0, 0, 0]);Sourcepub fn with_value<T: Clone + Send + Sync>(
value: T,
len: usize,
) -> impl PointerIndex<T> + ParCollection<Box<[T]>>
pub fn with_value<T: Clone + Send + Sync>( value: T, len: usize, ) -> impl PointerIndex<T> + ParCollection<Box<[T]>>
Constructs a new slice with len elements, each initialized
to value, that allows unsynchronized
access to its elements through PointerIndex and that can be
converted into a boxed slice.
§Examples
let pointer_slice = PointerParSlice::with_value(69, 4);
unsafe {
*pointer_slice.get_mut_ptr(0) = 42;
}
assert_eq!(pointer_slice.into().as_ref(), &[42, 69, 69, 69]);Sourcepub fn with_closure<T: Send + Sync>(
closure: impl FnMut(usize) -> T,
len: usize,
) -> impl PointerIndex<T> + ParCollection<Box<[T]>>
pub fn with_closure<T: Send + Sync>( closure: impl FnMut(usize) -> T, len: usize, ) -> impl PointerIndex<T> + ParCollection<Box<[T]>>
Constructs a new slice with len elements, each initialized
to the return value of closure called with the index of the element
to generate as an usize, that allows unsynchronized
access to its elements through PointerIndex and that can be
converted into a boxed slice.
§Examples
let pointer_slice = PointerParSlice::with_closure(|i| i, 4);
unsafe {
*pointer_slice.get_mut_ptr(0) = 42;
}
assert_eq!(pointer_slice.into().as_ref(), &[42, 1, 2, 3]);Sourcepub fn new_chunks<T: Default + Send + Sync>(
len: usize,
chunk_size: usize,
) -> impl PointerChunkIndex<T> + ParCollection<Box<[T]>>
pub fn new_chunks<T: Default + Send + Sync>( len: usize, chunk_size: usize, ) -> impl PointerChunkIndex<T> + ParCollection<Box<[T]>>
Constructs a new slice with len elements, each initialized
to T::default, that allows unsynchronized
access to chunks of chunk_size of its elements through
PointerChunkIndex and that can be converted into a boxed slice.
§Examples
let pointer_slice = PointerParSlice::new_chunks(4, 2);
unsafe {
(*pointer_slice.get_mut_ptr(0))[0] = 42;
}
assert_eq!(pointer_slice.into().as_ref(), &[42, 0, 0, 0]);Sourcepub fn chunks_with_value<T: Clone + Send + Sync>(
value: T,
len: usize,
chunk_size: usize,
) -> impl PointerChunkIndex<T> + ParCollection<Box<[T]>>
pub fn chunks_with_value<T: Clone + Send + Sync>( value: T, len: usize, chunk_size: usize, ) -> impl PointerChunkIndex<T> + ParCollection<Box<[T]>>
Constructs a new slice with len elements, each initialized
to value, that allows unsynchronized
access to chunks of chunk_size of its elements through
PointerChunkIndex and that can be converted into a boxed slice.
§Examples
let pointer_slice = PointerParSlice::chunks_with_value(69, 4, 2);
unsafe {
(*pointer_slice.get_mut_ptr(0))[0] = 42;
}
assert_eq!(pointer_slice.into().as_ref(), &[42, 69, 69, 69]);Sourcepub fn chunks_with_closure<T: Send + Sync>(
closure: impl FnMut(usize) -> T,
len: usize,
chunk_size: usize,
) -> impl PointerChunkIndex<T> + ParCollection<Box<[T]>>
pub fn chunks_with_closure<T: Send + Sync>( closure: impl FnMut(usize) -> T, len: usize, chunk_size: usize, ) -> impl PointerChunkIndex<T> + ParCollection<Box<[T]>>
Constructs a new slice with len elements, each initialized
to the return value of closure called with the index of the element
to generate as an usize, that allows unsynchronized
access to chunks of chunk_size of its elements through
PointerChunkIndex and that can be converted into a boxed slice.
§Examples
let pointer_slice = PointerParSlice::chunks_with_closure(|i| i, 4, 2);
unsafe {
(*pointer_slice.get_mut_ptr(0))[0] = 42;
}
assert_eq!(pointer_slice.into().as_ref(), &[42, 1, 2, 3]);