Struct dynamic_grid::DynamicGrid[][src]

pub struct DynamicGrid<T> { /* fields omitted */ }
Expand description

Dynamic Grid

Implementations

impl<T> DynamicGrid<T> where
    T: Clone
[src]

pub fn new() -> Self[src]

Constructor, Returns a dynamic grid

pub fn init(row: usize, col: usize, value: T) -> Self[src]

Init a grid of size rows x columns with the given data element

Arguments

  • row - number of rows
  • col - number columns
  • value - default value

pub fn from_vec(vec: Vec<Vec<T>>) -> Self[src]

Returns a grid from a vector of vector

Arguments

  • vec - Vector which represent a grid

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

Returns number of rows of the grid

pub fn row_size(&self, index_row: usize) -> Option<usize>[src]

Returns the size of the row indicate by the index

Arguments

  • index - rows index

pub fn row_size_unchecked(&self, index_row: usize) -> usize[src]

Returns the size of the row indicate by the index, without bound checking

Arguments

  • index - rows index

pub fn push(&mut self, value: T) -> (usize, usize)[src]

push value in the last position of last row

  • value - value to push

pub fn push_at_row(
    &mut self,
    index_row: usize,
    value: T
) -> Option<(usize, usize)>
[src]

push value in the last position at row mentioned

Argument

  • index_row - index of row
  • value - value to push

pub fn insert(&mut self, index_row: usize, index_col: usize, value: T)[src]

insert value at position

Argument

  • index_row - index of row
  • index_col - index of col
  • value - value to insert

Panics

Panics if the row and the col index are out of bounds.

pub fn swap(
    &mut self,
    first_position: (usize, usize),
    second_position: (usize, usize)
)
[src]

swap two element in the grid

Argument

  • first_position - position of the first element
  • second_position - position of the second element

Panics

Panics if the row and the col index are out of bounds.

pub fn push_new_row(&mut self, value: T) -> (usize, usize)[src]

push a new empty row

pub fn remove(&mut self)[src]

remove the last value of the last row

pub fn remove_row(&mut self, index_row: usize)[src]

remove the last row

pub unsafe fn get_unchecked(&self, index_row: usize, index_col: usize) -> &T[src]

Returns a reference to an element, without doing bound checking.

Arguments

index_row - index of row index_col - index of column

Example

pub unsafe fn get_unchecked_mut(
    &mut self,
    index_row: usize,
    index_col: usize
) -> &mut T
[src]

Return a mutable reference to an element, without doing bound checking.

Arguments

index_row - index of row index_col - index of column

Example

pub fn get(&self, index_row: usize, index_col: usize) -> Option<&T>[src]

Returns a reference to an element.

Arguments

index_row - index of row index_col - index of column

Example

pub fn get_mut(&mut self, index_row: usize, index_col: usize) -> Option<&mut T>[src]

Returns a reference to an element.

Arguments

index_row - index of row index_col - index of column

Example

pub fn iter(&self) -> Iter<'_, T>[src]

Returns an iterator over the whole grid, starting from the first row and column.

pub fn iter_mut(&mut self) -> IterMut<'_, T>[src]

Returns an mutable iterator over the whole grid that allows modifying each value.

pub fn iter_row(&self, index_row: usize) -> Iter<'_, T>[src]

Returns a row Iterator

Panics

Panics if the row index is out of bounds.

pub fn iter_row_mut(&mut self, index_row: usize) -> IterMut<'_, T>[src]

Returns a mutable row Iterator

Panics

Panics if the row index is out of bounds.

Trait Implementations

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

fn clone(&self) -> DynamicGrid<T>[src]

Returns a copy of the value. Read more

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

Performs copy-assignment from source. Read more

impl<T: Debug> Debug for DynamicGrid<T>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<T: Default> Default for DynamicGrid<T>[src]

fn default() -> DynamicGrid<T>[src]

Returns the “default value” for a type. Read more

impl<T> Display for DynamicGrid<T> where
    T: Clone + ToString
[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

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

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

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

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

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

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

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

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Owned = T

The resulting type after obtaining ownership.

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

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T> ToString for T where
    T: Display + ?Sized
[src]

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.