Trait grid_2d::coord_system::CoordSystem
source · pub trait CoordSystem {
type CoordIter: Iterator<Item = Coord>;
fn size(&self) -> Size;
fn index_of_coord_unchecked(&self, coord: Coord) -> usize;
fn coord_iter(&self) -> Self::CoordIter;
fn index_of_coord_checked(&self, coord: Coord) -> usize { ... }
fn index_of_coord(&self, coord: Coord) -> Option<usize> { ... }
fn index_of_normalized_coord(&self, coord: Coord) -> usize { ... }
}
Expand description
A mapping from coordinate to position in the Vec backing the grid. Generally implementations will own the size of the grid.
Required Associated Types
Required Methods
sourcefn index_of_coord_unchecked(&self, coord: Coord) -> usize
fn index_of_coord_unchecked(&self, coord: Coord) -> usize
Given a coord, returns the index of the backing Vec which
corresponds to that coordinate. May assume that
coord.is_valid(self.size())
.
sourcefn coord_iter(&self) -> Self::CoordIter
fn coord_iter(&self) -> Self::CoordIter
Returns an iterator over coords