Type Definition ndarray::ArrayViewMut
[−]
[src]
type ArrayViewMut<'a, A, D> = ArrayBase<ViewRepr<&'a mut A>, D>;
A read-write array view.
An array view represents an array or a part of it, created from an iterator, subview or slice of an array.
The ArrayViewMut<'a, A, D>
is parameterized by 'a
for the scope of the
borrow, A
for the element type and D
for the dimensionality.
Array views have all the methods of an array (see ArrayBase
).
See also ArrayView
.
Methods
impl<'a, A, D> ArrayViewMut<'a, A, D> where
D: Dimension,
[src]
D: Dimension,
Methods for read-write array views.
pub fn from_shape<Sh>(shape: Sh, xs: &'a mut [A]) -> Result<Self, ShapeError> where
Sh: Into<StrideShape<D>>,
[src]
Sh: Into<StrideShape<D>>,
Create a read-write array view borrowing its data from a slice.
Checks whether dim
and strides
are compatible with the slice's
length, returning an Err
if not compatible.
use ndarray::ArrayViewMut; use ndarray::arr3; use ndarray::ShapeBuilder; let mut s = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; let mut a = ArrayViewMut::from_shape((2, 3, 2).strides((1, 4, 2)), &mut s).unwrap(); a[[0, 0, 0]] = 1; assert!( a == arr3(&[[[1, 2], [4, 6], [8, 10]], [[1, 3], [5, 7], [9, 11]]]) ); assert!(a.strides() == &[1, 4, 2]);
pub unsafe fn from_shape_ptr<Sh>(shape: Sh, ptr: *mut A) -> Self where
Sh: Into<StrideShape<D>>,
[src]
Sh: Into<StrideShape<D>>,
Create an ArrayViewMut<A, D>
from shape information and a
raw pointer to the elements.
Unsafe because caller is responsible for ensuring that the pointer is valid, not aliased and coherent with the dimension and stride information.
pub fn reborrow<'b>(self) -> ArrayViewMut<'b, A, D> where
'a: 'b,
[src]
'a: 'b,
Convert the view into an ArrayViewMut<'b, A, D>
where 'b
is a lifetime
outlived by 'a'
.
pub fn split_at(self, axis: Axis, index: Ix) -> (Self, Self)
[src]
Split the array view along axis
and return one mutable view strictly
before the split and one mutable view after the split.
Panics if axis
or index
is out of bounds.
pub fn into_slice(self) -> Option<&'a mut [A]>
[src]
Return the array’s data as a slice, if it is contiguous and in standard order.
Return None
otherwise.
Trait Implementations
impl<'a, A, D> IntoIterator for ArrayViewMut<'a, A, D> where
D: Dimension,
[src]
D: Dimension,
type Item = &'a mut A
The type of the elements being iterated over.
type IntoIter = IterMut<'a, A, D>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
Creates an iterator from a value. Read more
impl<'a, A, Slice: ?Sized> From<&'a mut Slice> for ArrayViewMut<'a, A, Ix1> where
Slice: AsMut<[A]>,
[src]
Slice: AsMut<[A]>,
Implementation of ArrayViewMut::from(&mut S)
where S
is a slice or slicable.
Create a one-dimensional read-write array view of the data in slice
.
impl<'a, A, S, D> From<&'a mut ArrayBase<S, D>> for ArrayViewMut<'a, A, D> where
S: DataMut<Elem = A>,
D: Dimension,
[src]
S: DataMut<Elem = A>,
D: Dimension,
Implementation of ArrayViewMut::from(&mut A)
where A
is an array.
Create a read-write array view of the array.
impl<'a, A, D: Dimension> NdProducer for ArrayViewMut<'a, A, D>
[src]
type Item = &'a mut A
The element produced per iteration.
type Dim = D
Dimension type
type Ptr = *mut A
type Stride = isize
fn contiguous_stride(&self) -> Self::Stride
[src]
fn __private__(&self) -> PrivateMarker
[src]
This trait is private to implement; this method exists to make it impossible to implement outside the crate. Read more
impl<'a, I, A, D> IndexLonger<I> for ArrayViewMut<'a, A, D> where
I: NdIndex<D>,
D: Dimension,
[src]
I: NdIndex<D>,
D: Dimension,
type Output = &'a mut A
The type of the reference to the element that is produced, including its lifetime. Read more
fn index(self, index: I) -> &'a mut A
[src]
Convert a mutable array view to a mutable reference of a element.
This method is like IndexMut::index_mut
but with a longer lifetime
(matching the array view); which we can only do for the array view and
not in the Index
trait.
See also the get_mut
method which works for all arrays and array
views.
Panics if index is out of bounds.
fn get(self, index: I) -> Option<&'a mut A>
[src]
Convert a mutable array view to a mutable reference of a element, with checked access.
See also the get_mut
method which works for all arrays and array
views.
unsafe fn uget(self, index: I) -> &'a mut A
[src]
Convert a mutable array view to a mutable reference of a element without boundary check.
See also the uget_mut
method which works for all arrays and array
views.
Note: only unchecked for non-debug builds of ndarray.