Struct flat_spatial::storage::SparseStorage
source · pub struct SparseStorage<T: Default> {
pub cell_size: i32,
pub cells: FnvHashMap<CellIdx, T>,
}
Expand description
SparseStorage
stores cells in a FastMap
to be used in a Grid.
It is Sparse because cells are eagerly allocated, and cleaned when they are empty.
It implements the Storage trait.
Fields§
§cell_size: i32
§cells: FnvHashMap<CellIdx, T>
Implementations§
source§impl<T: Default> SparseStorage<T>
impl<T: Default> SparseStorage<T>
pub fn new(cell_size: i32) -> Self
pub fn cell_size(&self) -> i32
pub fn modify(&mut self, f: impl FnMut(&mut T) -> bool)
pub fn cell_mut<V2: Vec2>(&mut self, pos: V2) -> (CellIdx, &mut T)
pub fn cell_mut_unchecked(&mut self, id: CellIdx) -> &mut T
pub fn cell(&self, id: CellIdx) -> Option<&T>
pub fn cell_id<V2: Vec2>(&self, pos: V2) -> CellIdx
Trait Implementations§
Auto Trait Implementations§
impl<T> RefUnwindSafe for SparseStorage<T>where T: RefUnwindSafe,
impl<T> Send for SparseStorage<T>where T: Send,
impl<T> Sync for SparseStorage<T>where T: Sync,
impl<T> Unpin for SparseStorage<T>where T: Unpin,
impl<T> UnwindSafe for SparseStorage<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