pub trait Grid<T: Clone + Copy> {
Show 14 methods
fn new(width: usize, height: usize, default_value: T) -> Self;
fn get(&self, x: usize, y: usize) -> T;
fn set(&mut self, x: usize, y: usize, value: T);
fn width(&self) -> usize;
fn height(&self) -> usize;
fn get_point(&self, point: Point) -> T { ... }
fn set_point(&mut self, point: Point, value: T) { ... }
fn get_ix(&self, x: usize, y: usize) -> usize { ... }
fn get_ix_point(&self, point: &Point) -> usize { ... }
fn point_in_bounds(&self, point: Point) -> bool { ... }
fn index_in_bounds(&self, x: usize, y: usize) -> bool { ... }
fn set_rectangle(&mut self, rect: &Rect, value: T) { ... }
fn rect(&self) -> Rect { ... }
fn get_rect(&self, rect: Rect) -> Vec<T> { ... }
}
Expand description
Required Methods
Provided Methods
Gets the index corresponding to a coordinate, which is row-wise.
fn get_ix_point(&self, point: &Point) -> usize
fn point_in_bounds(&self, point: Point) -> bool
fn point_in_bounds(&self, point: Point) -> bool
Tests whether a point is in bounds.
fn index_in_bounds(&self, x: usize, y: usize) -> bool
fn index_in_bounds(&self, x: usize, y: usize) -> bool
Tests whether an index is in bounds.
fn set_rectangle(&mut self, rect: &Rect, value: T)
fn set_rectangle(&mut self, rect: &Rect, value: T)
Sets a given rectangle on the grid to the value.
Retrieves the rectangle corresponding to the grid dimensions at the origin.