pub struct HashCell<K, const D: usize>{ /* private fields */ }Expand description
Bucket sort points into cubes with HashMap-backed storage
See VecCell for a complete description of the algorithm. Use VecCell
for dense, bounded collections of points. Use HashMap for sparse and/or
unbounded collections of points.
§Examples
The default HashCell set both the nominal and maximum search radii to 1.0.
use hoomd_spatial::HashCell;
let hash_cell = HashCell::<usize, 3>::default();Use the builder API to set any or all parameters:
use hoomd_spatial::HashCell;
let hash_cell = HashCell::<usize, 3>::builder()
.nominal_search_radius(2.5.try_into()?)
.maximum_search_radius(7.5)
.build();Implementations§
Source§impl<K, const D: usize> HashCell<K, D>
impl<K, const D: usize> HashCell<K, D>
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Remove excess capacity from dynamically allocated arrays.
Sourcepub fn builder() -> HashCellBuilder<K, D>
pub fn builder() -> HashCellBuilder<K, D>
Trait Implementations§
Source§impl<'de, K, const D: usize> Deserialize<'de> for HashCell<K, D>
impl<'de, K, const D: usize> Deserialize<'de> for HashCell<K, D>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<K, const D: usize> Display for HashCell<K, D>
impl<K, const D: usize> Display for HashCell<K, D>
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Summarize the contents of the cell list.
This is a slow operation. It is meant to be printed to logs only occasionally, such as at the end of a benchmark or simulation.
§Example
use hoomd_spatial::HashCell;
use log::info;
let vec_cell = HashCell::<usize, 3>::default();
info!("{vec_cell}");Source§impl<K, const D: usize> PointUpdate<Cartesian<D>, K> for HashCell<K, D>
impl<K, const D: usize> PointUpdate<Cartesian<D>, K> for HashCell<K, D>
Source§fn insert(&mut self, key: K, position: Cartesian<D>)
fn insert(&mut self, key: K, position: Cartesian<D>)
Insert or update a point identified by a key.
§Example
use hoomd_spatial::{HashCell, PointUpdate};
let mut hash_cell = HashCell::default();
hash_cell.insert(0, [1.25, 2.5].into());Source§fn remove(&mut self, key: &K)
fn remove(&mut self, key: &K)
Remove the point with the given key.
§Example
use hoomd_spatial::{HashCell, PointUpdate};
let mut hash_cell = HashCell::default();
hash_cell.insert(0, [1.25, 2.5].into());
hash_cell.remove(&0)Source§fn len(&self) -> usize
fn len(&self) -> usize
Get the number of points in the spatial data structure.
§Example
use hoomd_spatial::{HashCell, PointUpdate};
let mut hash_cell = HashCell::default();
hash_cell.insert(0, [1.25, 2.5].into());
assert_eq!(hash_cell.len(), 1)Source§fn is_empty(&self) -> bool
fn is_empty(&self) -> bool
Test if the spatial data structure is empty.
§Example
use hoomd_spatial::{HashCell, PointUpdate};
let mut hash_cell = HashCell::default();
assert!(hash_cell.is_empty());Source§fn contains_key(&self, key: &K) -> bool
fn contains_key(&self, key: &K) -> bool
Test if the spatial data structure contains a key.
use hoomd_spatial::{HashCell, PointUpdate};
let mut hash_cell = HashCell::default();
hash_cell.insert(0, [1.25, 2.5].into());
assert!(hash_cell.contains_key(&0));Source§impl<const D: usize, K> PointsNearBall<Cartesian<D>, K> for HashCell<K, D>
impl<const D: usize, K> PointsNearBall<Cartesian<D>, K> for HashCell<K, D>
Source§fn points_near_ball(
&self,
position: &Cartesian<D>,
radius: f64,
) -> impl Iterator<Item = K>
fn points_near_ball( &self, position: &Cartesian<D>, radius: f64, ) -> impl Iterator<Item = K>
Find all the points that might be in the given ball.
points_near_ball will iterate over all points in the given ball and
possibly others as well. HashCell may iterate over the points in
any order.
§Example
use hoomd_spatial::{HashCell, PointUpdate, PointsNearBall};
let mut hash_cell = HashCell::default();
hash_cell.insert(0, [1.25, 0.0].into());
hash_cell.insert(1, [3.25, 0.75].into());
hash_cell.insert(2, [-10.0, 12.0].into());
for key in hash_cell.points_near_ball(&[2.0, 0.0].into(), 1.0) {
println!("{key}");
}Prints (in any order):
0
1§Panics
Panics when radius is larger than the maximum search radius
provided at construction, rounded up to the nearest integer multiple
of the nominal search radius.
Source§fn is_all_pairs() -> bool
fn is_all_pairs() -> bool
AllPairs?