[][src]Struct vec2dim::Vec2d

pub struct Vec2d<T> { /* fields omitted */ }

A two-dimensional array. Unlike a standard vector, Vec2d must maintain a constant number of elements equal to its number of rows times its number of columns.

Methods

impl<T: Default> Vec2d<T>[src]

pub fn new_with_default(rows: usize, cols: usize) -> Vec2d<T>[src]

Creates a new Vec2d<T> and initializes all the values to T::default().

pub fn add_row_of_default(&mut self)[src]

Adds a new row to the vector and sets all elements of that row to T::default(). If the array is empty, creates a row of one element.

pub fn add_col_of_default(&mut self)[src]

Adds a new column to the array and sets all elements of the column to T::default().

impl<T: Copy> Vec2d<T>[src]

pub fn new_with_value(rows: usize, cols: usize, val: T) -> Vec2d<T>[src]

Creates a new Vec2d<T> and initializes all the values to a copy of val.

pub fn from(width: usize, arr: &[T]) -> Vec2d<T>[src]

Creates a new Vec2d<T> from an array slice. The slice must have a length that is divisible by cols in order to fill the new array. The array is filled left to right, top to bottom.

pub fn insert_col(&mut self, index: usize, data: &[T])[src]

Inserts a column of data before the columns indicated by index.

pub fn insert_row(&mut self, index: usize, data: &[T])[src]

Inserts a row of data before the row indicated by index. If index is 0, calls push_row(data).

pub fn push_col(&mut self, data: &[T])[src]

Adds a new column of data to the right edge of the array. The length of the slice data must be exactly equal to the height of the array.

pub fn push_row(&mut self, data: &[T])[src]

Adds a row of data at the bottom of the array. The length of the slice data must be exactly equal to the array width or the method will panic.

impl<T: PartialEq> Vec2d<T>[src]

pub fn contains(&self, val: &T) -> bool[src]

Checks if val is equivalent to any of the elements in the array. Returns true if there is a match, false otherwise.

impl<T> Vec2d<T>[src]

pub fn new() -> Vec2d<T>[src]

Creates a new Vec2d<T> with no rows, columns, or elements.

pub fn from_fn(
    rows: usize,
    cols: usize,
    initializer: &dyn Fn(usize, usize) -> T
) -> Vec2d<T>
[src]

Creates a new Vec2d<T> and initializes its values from initializer, a passed-in function that takes the current cell index (row and column) and returns a T.

pub fn as_ptr(&self) -> *const T[src]

Returns a raw pointer to the underlying vector's buffer.

pub fn as_vec(&self) -> &Vec<T>[src]

Returns a reference to the underlying vector.

pub fn count(&self) -> usize[src]

Returns the number of elements in the array. Equal to the number of rows times the number of columns.

pub fn count_cols(&self) -> usize[src]

Returns the number of columns of the array.

pub fn count_rows(&self) -> usize[src]

Returns the number of rows of the array.

pub fn size(&self) -> (usize, usize)[src]

Returns the dimensions of the array as a tuple of (row, col).

Trait Implementations

impl<T: Clone> Clone for Vec2d<T>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<T> Index<usize> for Vec2d<T>[src]

type Output = [T]

The returned type after indexing.

impl<T> IndexMut<usize> for Vec2d<T>[src]

Auto Trait Implementations

impl<T> Unpin for Vec2d<T> where
    T: Unpin

impl<T> Sync for Vec2d<T> where
    T: Sync

impl<T> Send for Vec2d<T> where
    T: Send

impl<T> UnwindSafe for Vec2d<T> where
    T: UnwindSafe

impl<T> RefUnwindSafe for Vec2d<T> where
    T: RefUnwindSafe

Blanket Implementations

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

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

type Owned = T

The resulting type after obtaining ownership.

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> Borrow<T> for T where
    T: ?Sized
[src]

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

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