pub struct Grid<T> {
pub x_size: usize,
pub y_size: usize,
pub z_size: usize,
pub items: Vec<T>,
}Expand description
A discrete, protected 3D data structure Protected in the sense that it always checks bounds, even in production.
IDEAS: sparce matrix? chunked matrix?
Fields§
§x_size: usize§y_size: usize§z_size: usize§items: Vec<T>Implementations§
Source§impl<T: Clone + Copy> Grid<T>
impl<T: Clone + Copy> Grid<T>
pub fn new(x: usize, y: usize, z: usize, default_value: T) -> Self
pub fn size(&self) -> usize
pub fn size_vec(&self) -> IVec3
pub fn set(&mut self, x: i32, y: i32, z: i32, tile: T) -> Option<usize>
pub fn set_at(&mut self, pos: IVec3, tile: T) -> Option<usize>
pub fn get(&self, x: i32, y: i32, z: i32) -> Option<T>
pub fn get_at(&self, pos: IVec3) -> Option<T>
pub fn is_on_grid(&self, x: i32, y: i32, z: i32) -> bool
pub fn to_index(&self, x: i32, y: i32, z: i32) -> Option<usize>
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> 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