pub struct HashedOctree<T: Copy> { /* private fields */ }
Expand description
A hashed (linear) octree implementation which uses MortonKey
for indexing.
This type supports concurrent access and uses a fast hashing algorithm for best performance.
§Example
use dmc::octree::*;
let mut octree = HashedOctree::new(0usize);
let mut i = 0;
octree.subdivide(MortonKey::root()).for_each(|child| {
*octree.value_mut(child).unwrap() = i; i += 1;
});
dbg!(octree);
Implementations§
Source§impl<T: Copy> HashedOctree<T>
impl<T: Copy> HashedOctree<T>
Sourcepub fn value(
&self,
key: MortonKey,
) -> Option<Ref<'_, MortonKey, T, RandomState>>
pub fn value( &self, key: MortonKey, ) -> Option<Ref<'_, MortonKey, T, RandomState>>
Returns a reference to a node if it exists.
§Concurrent Behaviour
May deadlock if called when holding a mutable reference into the octree.
Sourcepub fn value_mut(
&mut self,
key: MortonKey,
) -> Option<RefMut<'_, MortonKey, T, RandomState>>
pub fn value_mut( &mut self, key: MortonKey, ) -> Option<RefMut<'_, MortonKey, T, RandomState>>
Returns a mutable reference to a node if it exists.
§Concurrent Behaviour
May deadlock if called when holding any sort of reference into the octree.
Sourcepub fn subdivide(&mut self, key: MortonKey) -> impl Iterator<Item = MortonKey>
pub fn subdivide(&mut self, key: MortonKey) -> impl Iterator<Item = MortonKey>
Subdivides a node and returns an iterator over its newly created children. The value of the children will be copied from the parent.
§Panics
Panics if the node passed is already subdivided.
Sourcepub fn children(
&self,
key: MortonKey,
) -> Option<impl Iterator<Item = MortonKey>>
pub fn children( &self, key: MortonKey, ) -> Option<impl Iterator<Item = MortonKey>>
Returns an iterator over the children of a node, or None if the children (or parent) don’t exist.
Sourcepub fn node_exists(&self, key: MortonKey) -> bool
pub fn node_exists(&self, key: MortonKey) -> bool
Returns true if a node exists.
Sourcepub fn is_subdivided(&self, key: MortonKey) -> bool
pub fn is_subdivided(&self, key: MortonKey) -> bool
Returns true if the children of a node exists.
§Panics
Panics if the level of the key given is equal to the maximum level possible.
Sourcepub fn leaves(&self, parent: MortonKey) -> Vec<MortonKey>
pub fn leaves(&self, parent: MortonKey) -> Vec<MortonKey>
Finds all the leaf nodes belonging to parent
and returns a vector with a key for each of
them.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Returns the total node count, including leaf and branch nodes.
Trait Implementations§
Source§impl<T: Clone + Copy> Clone for HashedOctree<T>
impl<T: Clone + Copy> Clone for HashedOctree<T>
Source§fn clone(&self) -> HashedOctree<T>
fn clone(&self) -> HashedOctree<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl<T> Freeze for HashedOctree<T>
impl<T> !RefUnwindSafe for HashedOctree<T>
impl<T> Send for HashedOctree<T>where
T: Send,
impl<T> Sync for HashedOctree<T>
impl<T> Unpin for HashedOctree<T>
impl<T> UnwindSafe for HashedOctree<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more