[][src]Struct nalgebra::base::VecStorage

#[repr(C)]
pub struct VecStorage<N, R: Dim, C: Dim> { /* fields omitted */ }

A Vec-based matrix data storage. It may be dynamically-sized.

Methods

impl<N, R: Dim, C: Dim> VecStorage<N, R, C>[src]

pub fn new(nrows: R, ncols: C, data: Vec<N>) -> VecStorage<N, R, C>[src]

Creates a new dynamic matrix data storage from the given vector and shape.

pub fn data(&self) -> &Vec<N>[src]

The underlying data storage.

pub unsafe fn data_mut(&mut self) -> &mut Vec<N>[src]

The underlying mutable data storage.

This is unsafe because this may cause UB if the vector is modified by the user.

pub unsafe fn resize(self, sz: usize) -> Vec<N>[src]

Resizes the underlying mutable data storage and unwraps it.

If sz is larger than the current size, additional elements are uninitialized. If sz is smaller than the current size, additional elements are truncated.

Methods from Deref<Target = Vec<N>>

pub fn capacity(&self) -> usize1.0.0[src]

Returns the number of elements the vector can hold without reallocating.

Examples

let vec: Vec<i32> = Vec::with_capacity(10);
assert_eq!(vec.capacity(), 10);

pub fn as_slice(&self) -> &[T]1.7.0[src]

Extracts a slice containing the entire vector.

Equivalent to &s[..].

Examples

use std::io::{self, Write};
let buffer = vec![1, 2, 3, 5, 8];
io::sink().write(buffer.as_slice()).unwrap();

pub fn as_ptr(&self) -> *const T1.37.0[src]

Returns a raw pointer to the vector's buffer.

The caller must ensure that the vector outlives the pointer this function returns, or else it will end up pointing to garbage. Modifying the vector may cause its buffer to be reallocated, which would also make any pointers to it invalid.

The caller must also ensure that the memory the pointer (non-transitively) points to is never written to (except inside an UnsafeCell) using this pointer or any pointer derived from it. If you need to mutate the contents of the slice, use as_mut_ptr.

Examples

let x = vec![1, 2, 4];
let x_ptr = x.as_ptr();

unsafe {
    for i in 0..x.len() {
        assert_eq!(*x_ptr.add(i), 1 << i);
    }
}

pub fn len(&self) -> usize1.0.0[src]

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

Examples

let a = vec![1, 2, 3];
assert_eq!(a.len(), 3);

pub fn is_empty(&self) -> bool1.0.0[src]

Returns true if the vector contains no elements.

Examples

let mut v = Vec::new();
assert!(v.is_empty());

v.push(1);
assert!(!v.is_empty());

Trait Implementations

impl<N: Scalar, C: Dim> Storage<N, Dynamic, C> for VecStorage<N, Dynamic, C> where
    DefaultAllocator: Allocator<N, Dynamic, C, Buffer = Self>, 
[src]

type RStride = U1

The static stride of this storage's rows.

type CStride = Dynamic

The static stride of this storage's columns.

impl<N: Scalar, R: DimName> Storage<N, R, Dynamic> for VecStorage<N, R, Dynamic> where
    DefaultAllocator: Allocator<N, R, Dynamic, Buffer = Self>, 
[src]

type RStride = U1

The static stride of this storage's rows.

type CStride = R

The static stride of this storage's columns.

impl<N: Scalar, C: Dim> StorageMut<N, Dynamic, C> for VecStorage<N, Dynamic, C> where
    DefaultAllocator: Allocator<N, Dynamic, C, Buffer = Self>, 
[src]

impl<N: Scalar, R: DimName> StorageMut<N, R, Dynamic> for VecStorage<N, R, Dynamic> where
    DefaultAllocator: Allocator<N, R, Dynamic, Buffer = Self>, 
[src]

impl<N: Scalar, C: Dim> ContiguousStorage<N, Dynamic, C> for VecStorage<N, Dynamic, C> where
    DefaultAllocator: Allocator<N, Dynamic, C, Buffer = Self>, 
[src]

impl<N: Scalar, R: DimName> ContiguousStorage<N, R, Dynamic> for VecStorage<N, R, Dynamic> where
    DefaultAllocator: Allocator<N, R, Dynamic, Buffer = Self>, 
[src]

impl<N: Scalar, C: Dim> ContiguousStorageMut<N, Dynamic, C> for VecStorage<N, Dynamic, C> where
    DefaultAllocator: Allocator<N, Dynamic, C, Buffer = Self>, 
[src]

impl<N: Scalar, R: DimName> ContiguousStorageMut<N, R, Dynamic> for VecStorage<N, R, Dynamic> where
    DefaultAllocator: Allocator<N, R, Dynamic, Buffer = Self>, 
[src]

impl<N: Eq, R: Eq + Dim, C: Eq + Dim> Eq for VecStorage<N, R, C>[src]

impl<N, R: Dim> Extend<N> for VecStorage<N, R, Dynamic>[src]

fn extend<I: IntoIterator<Item = N>>(&mut self, iter: I)[src]

Extends the number of columns of the VecStorage with elements from the given iterator.

Panics

This function panics if the number of elements yielded by the given iterator is not a multiple of the number of rows of the VecStorage.

impl<N, R, RV, SV> Extend<Matrix<N, RV, U1, SV>> for VecStorage<N, R, Dynamic> where
    N: Scalar,
    R: Dim,
    RV: Dim,
    SV: Storage<N, RV>,
    ShapeConstraint: SameNumberOfRows<R, RV>, 
[src]

fn extend<I: IntoIterator<Item = Vector<N, RV, SV>>>(&mut self, iter: I)[src]

Extends the number of columns of the VecStorage with vectors from the given iterator.

Panics

This function panics if the number of rows of each Vector yielded by the iterator is not equal to the number of rows of this VecStorage.

impl<N> Extend<N> for VecStorage<N, Dynamic, U1>[src]

fn extend<I: IntoIterator<Item = N>>(&mut self, iter: I)[src]

Extends the number of rows of the VecStorage with elements from the given iterator.

impl<N, R: Dim, C: Dim> Into<Vec<N>> for VecStorage<N, R, C>[src]

impl<N: Clone, R: Clone + Dim, C: Clone + Dim> Clone for VecStorage<N, R, C>[src]

impl<N: PartialEq, R: PartialEq + Dim, C: PartialEq + Dim> PartialEq<VecStorage<N, R, C>> for VecStorage<N, R, C>[src]

impl<N, R: Dim, C: Dim> Deref for VecStorage<N, R, C>[src]

type Target = Vec<N>

The resulting type after dereferencing.

impl<N: Debug, R: Debug + Dim, C: Debug + Dim> Debug for VecStorage<N, R, C>[src]

Auto Trait Implementations

impl<N, R, C> Unpin for VecStorage<N, R, C> where
    C: Unpin,
    N: Unpin,
    R: Unpin

impl<N, R, C> Sync for VecStorage<N, R, C> where
    N: Sync

impl<N, R, C> Send for VecStorage<N, R, C> where
    N: Send

impl<N, R, C> UnwindSafe for VecStorage<N, R, C> where
    C: UnwindSafe,
    N: UnwindSafe,
    R: UnwindSafe

impl<N, R, C> RefUnwindSafe for VecStorage<N, R, C> where
    C: RefUnwindSafe,
    N: RefUnwindSafe,
    R: RefUnwindSafe

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 
[src]