Struct Grid

Source
pub struct Grid<T> {
    pub rows: usize,
    pub cols: usize,
    pub cells: Vec<Vec<T>>,
}

Fields§

§rows: usize§cols: usize§cells: Vec<Vec<T>>

Implementations§

Source§

impl<T> Grid<T>
where T: Debug + Clone,

Source

pub fn new(rows: usize, cols: usize, default: T) -> Self

Source§

impl<T> Grid<T>
where T: Debug,

Source

pub fn new_from(data: Vec<Vec<T>>) -> Self

Source

pub fn iter(&self) -> impl Iterator<Item = &T>

Source

pub fn rows(&self) -> impl Iterator<Item = &Vec<T>>

Source

pub fn cols<'a>(&'a self) -> impl Iterator<Item = impl Iterator<Item = &'a T>>

Source

pub fn get(&self, row_index: usize, col_index: usize) -> Option<&T>

Source

pub fn eight_neighbors<'a>( &'a self, row_origin: usize, col_origin: usize, ) -> impl Iterator<Item = &'a T>

Source

pub fn l1_dist(&self, pt1: GridPt, pt2: GridPt) -> usize

Source

pub fn right_from(&self, row: usize, col: usize) -> impl Iterator<Item = &T>

Source

pub fn left_from(&self, row: usize, col: usize) -> impl Iterator<Item = &T>

Source

pub fn up_from(&self, row: usize, col: usize) -> impl Iterator<Item = &T>

Source

pub fn down_from(&self, row: usize, col: usize) -> impl Iterator<Item = &T>

Trait Implementations§

Source§

impl<T: Debug> Debug for Grid<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Grid<T>

§

impl<T> RefUnwindSafe for Grid<T>
where T: RefUnwindSafe,

§

impl<T> Send for Grid<T>
where T: Send,

§

impl<T> Sync for Grid<T>
where T: Sync,

§

impl<T> Unpin for Grid<T>
where T: Unpin,

§

impl<T> UnwindSafe for Grid<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.