pub struct DynamicGrid<T> { /* private fields */ }
Expand description
Dynamic Grid
Implementations§
Source§impl<T> DynamicGrid<T>where
T: Clone,
impl<T> DynamicGrid<T>where
T: Clone,
Sourcepub fn init(row: usize, col: usize, value: T) -> Self
pub fn init(row: usize, col: usize, value: T) -> Self
Init a grid of size rows x columns with the given data element
§Arguments
row
- number of rowscol
- number columnsvalue
- default value
Sourcepub fn row_size_unchecked(&self, index_row: usize) -> usize
pub fn row_size_unchecked(&self, index_row: usize) -> usize
Returns the size of the row indicate by the index, without bound checking
§Arguments
index
- rows index
Sourcepub fn push(&mut self, value: T) -> (usize, usize)
pub fn push(&mut self, value: T) -> (usize, usize)
push value in the last position of last row
value
- value to push
Sourcepub fn push_at_row(
&mut self,
index_row: usize,
value: T,
) -> Option<(usize, usize)>
pub fn push_at_row( &mut self, index_row: usize, value: T, ) -> Option<(usize, usize)>
push value in the last position at row mentioned
§Argument
- index_row - index of row
- value - value to push
Sourcepub fn push_new_row(&mut self, value: T) -> (usize, usize)
pub fn push_new_row(&mut self, value: T) -> (usize, usize)
push a new empty row
Sourcepub fn remove_row(&mut self, index_row: usize)
pub fn remove_row(&mut self, index_row: usize)
remove the last row
Sourcepub unsafe fn get_unchecked(&self, index_row: usize, index_col: usize) -> &T
pub unsafe fn get_unchecked(&self, index_row: usize, index_col: usize) -> &T
Sourcepub unsafe fn get_unchecked_mut(
&mut self,
index_row: usize,
index_col: usize,
) -> &mut T
pub unsafe fn get_unchecked_mut( &mut self, index_row: usize, index_col: usize, ) -> &mut T
Sourcepub fn iter(&self) -> Iter<'_, T>
pub fn iter(&self) -> Iter<'_, T>
Returns an iterator over the whole grid, starting from the first row and column.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, T>
pub fn iter_mut(&mut self) -> IterMut<'_, T>
Returns an mutable iterator over the whole grid that allows modifying each value.
Sourcepub fn iter_row_mut(&mut self, index_row: usize) -> IterMut<'_, T>
pub fn iter_row_mut(&mut self, index_row: usize) -> IterMut<'_, T>
Trait Implementations§
Source§impl<T: Clone> Clone for DynamicGrid<T>
impl<T: Clone> Clone for DynamicGrid<T>
Source§fn clone(&self) -> DynamicGrid<T>
fn clone(&self) -> DynamicGrid<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T: Debug> Debug for DynamicGrid<T>
impl<T: Debug> Debug for DynamicGrid<T>
Source§impl<T: Default> Default for DynamicGrid<T>
impl<T: Default> Default for DynamicGrid<T>
Source§fn default() -> DynamicGrid<T>
fn default() -> DynamicGrid<T>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<T> Freeze for DynamicGrid<T>
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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more