pub struct HGrid<T> { /* private fields */ }
Expand description
A grid based on spacial hashing.
Implementations§
source§impl<T> HGrid<T>
impl<T> HGrid<T>
sourcepub fn new(cell_width: Real) -> Self
pub fn new(cell_width: Real) -> Self
Initialize a grid where each cell has the width cell_width
.
sourcepub fn cell_width(&self) -> Real
pub fn cell_width(&self) -> Real
The width of a cell of this spacial grid.
sourcepub fn key(&self, point: &Point<Real>) -> Point<i64>
pub fn key(&self, point: &Point<Real>) -> Point<i64>
Computes the logical grid cell containing point
.
sourcepub fn insert(&mut self, point: &Point<Real>, element: T)
pub fn insert(&mut self, point: &Point<Real>, element: T)
Inserts the given element
into the cell containing the given point
.
sourcepub fn cell_containing_point(&self, point: &Point<Real>) -> Option<&Vec<T>>
pub fn cell_containing_point(&self, point: &Point<Real>) -> Option<&Vec<T>>
Returns the element attached to the cell containing the given point
.
Returns None
if the cell is empty.
sourcepub fn cells(&self) -> impl Iterator<Item = (&Point<i64>, &Vec<T>)>
pub fn cells(&self) -> impl Iterator<Item = (&Point<i64>, &Vec<T>)>
An iterator through all the non-empty cells of this grid.
The returned tuple include the cell indentifier, and the elements attached to this cell.
sourcepub fn inner_table(&self) -> &HashMap<Point<i64>, Vec<T>, DeterministicState>
pub fn inner_table(&self) -> &HashMap<Point<i64>, Vec<T>, DeterministicState>
The underlying hash map of this spacial grid.
sourcepub fn cell(&self, key: &Point<i64>) -> Option<&Vec<T>>
pub fn cell(&self, key: &Point<i64>) -> Option<&Vec<T>>
Get the content of the logical cell identified by key
.
Trait Implementations§
source§impl<T: PartialEq> PartialEq for HGrid<T>
impl<T: PartialEq> PartialEq for HGrid<T>
impl<T> StructuralPartialEq for HGrid<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for HGrid<T>where
T: RefUnwindSafe,
impl<T> Send for HGrid<T>where
T: Send,
impl<T> Sync for HGrid<T>where
T: Sync,
impl<T> Unpin for HGrid<T>where
T: Unpin,
impl<T> UnwindSafe for HGrid<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
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.