pub struct Tree<T, C = i32> {
pub arena: Vec<Node<T, C>>,
pub free_list: Vec<usize>,
pub root: Option<usize>,
pub item_count: i32,
pub dead_count: i32,
pub extent: KdBox<C>,
pub delete_flip: bool,
}Expand description
A 3D KD-Tree implementation using arena allocation.
The tree stores items of type T associated with a 6-element bounding box
[left, bottom, floor, right, top, ceil].
It uses a Vec-backed arena for node storage to improve performance and cache locality.
Fields§
§arena: Vec<Node<T, C>>§free_list: Vec<usize>§root: Option<usize>§item_count: i32§dead_count: i32§extent: KdBox<C>§delete_flip: boolImplementations§
Source§impl<T: PartialEq + Clone, C: Coord> Tree<T, C>
impl<T: PartialEq + Clone, C: Coord> Tree<T, C>
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a new 3D KD-Tree with a pre-allocated capacity for the node arena.
Sourcepub fn insert(&mut self, item: T, size: KdBox<C>)
pub fn insert(&mut self, item: T, size: KdBox<C>)
Inserts an item into the tree with the given 3D bounding box.
Sourcepub fn is_member(&self, item: &T, size: &KdBox<C>) -> bool
pub fn is_member(&self, item: &T, size: &KdBox<C>) -> bool
Checks if the given item is stored in the tree with the specified bounding box.
Sourcepub fn delete(&mut self, item: &T, size: &KdBox<C>) -> bool
pub fn delete(&mut self, item: &T, size: &KdBox<C>) -> bool
Marks an item as deleted (soft delete).
Sourcepub fn hard_delete(&mut self, item: &T, size: &KdBox<C>) -> bool
pub fn hard_delete(&mut self, item: &T, size: &KdBox<C>) -> bool
Physically deletes an item from the tree and restructures the nodes (hard delete).
pub fn count(&self) -> i32
pub fn badness(&self)
Source§impl<T: PartialEq + Clone, C: Coord> Tree<T, C>
impl<T: PartialEq + Clone, C: Coord> Tree<T, C>
Auto Trait Implementations§
impl<T, C> Freeze for Tree<T, C>where
C: Freeze,
impl<T, C> RefUnwindSafe for Tree<T, C>where
C: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, C> Send for Tree<T, C>
impl<T, C> Sync for Tree<T, C>
impl<T, C> Unpin for Tree<T, C>
impl<T, C> UnsafeUnpin for Tree<T, C>where
C: UnsafeUnpin,
impl<T, C> UnwindSafe for Tree<T, C>where
C: UnwindSafe,
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