Struct atomic_array::AtomicOptionRefArray [−][src]
pub struct AtomicOptionRefArray<T> { /* fields omitted */ }
An array of references in which elements may be updated and retrieved atomically.
This is a Rust interpretation of AtomicReferenceArray from Java.
Methods
impl<T> AtomicOptionRefArray<T>
[src]
impl<T> AtomicOptionRefArray<T>
pub fn new(len: usize) -> Self
[src]
pub fn new(len: usize) -> Self
Constructs a new array with the specified length.
All values will be None
.
pub fn new_with<U: IntoOptionArc<T>>(
len: usize,
f: impl Fn(usize) -> U
) -> Self
[src]
pub fn new_with<U: IntoOptionArc<T>>(
len: usize,
f: impl Fn(usize) -> U
) -> Self
Constructs a new array with the specified length. Uses the given function to construct each value.
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Returns the number of elements in the array.
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
Returns true
if the array has a length of 0.
pub fn load(&self, index: usize) -> Option<Arc<T>>
[src]
pub fn load(&self, index: usize) -> Option<Arc<T>>
Loads and returns a reference to an value at the given position or None
if the value at the index is not set.
Panics if index
is out of bounds.
pub fn store(
&self,
index: usize,
value: impl IntoOptionArc<T>
)
[src]
pub fn store(
&self,
index: usize,
value: impl IntoOptionArc<T>
)
Stores the value at the given position.
Panics if index
is out of bounds.
pub fn swap(
&self,
index: usize,
value: impl IntoOptionArc<T>
) -> Option<Arc<T>>
[src]
pub fn swap(
&self,
index: usize,
value: impl IntoOptionArc<T>
) -> Option<Arc<T>>
Swaps the value at the given position, returning the previous value.
Panics if index
is out of bounds.
Auto Trait Implementations
impl<T> Send for AtomicOptionRefArray<T>
impl<T> Send for AtomicOptionRefArray<T>
impl<T> Sync for AtomicOptionRefArray<T>
impl<T> Sync for AtomicOptionRefArray<T>