[][src]Struct aabb_quadtree::QuadTree

pub struct QuadTree<T, S, A: Array<Item = (ItemId, TypedRect<f32, S>)>> { /* fields omitted */ }

The main QuadTree structure. Mainly supports inserting, removing, and querying objects in 3d space.

Methods

impl<T, S, A: Array<Item = (ItemId, TypedRect<f32, S>)>> QuadTree<T, S, A>[src]

pub fn new(
    size: TypedRect<f32, S>,
    allow_duplicates: bool,
    min_children: usize,
    max_children: usize,
    max_depth: usize,
    size_hint: usize
) -> QuadTree<T, S, A>
[src]

Constructs a new QuadTree with customizable options.

  • size: the enclosing space for the quad-tree.
  • allow_duplicates: if false, the quadtree will remove objects that have the same bounding box.
  • min_children: the minimum amount of children that a tree node will have. * max_children: the maximum amount of children that a tree node will have before it gets split. * max_depth: the maximum depth that the tree can grow before it stops.

pub fn default(size: TypedRect<f32, S>, size_hint: usize) -> QuadTree<T, S, A>[src]

Constructs a new QuadTree with customizable options.

  • size: the enclosing space for the quad-tree.

Defauts

  • allow_duplicates: true
  • min_children: 4
  • max_children: 16
  • max_depth: 8

pub fn insert_with_box(
    &mut self,
    t: T,
    aabb: TypedRect<f32, S>
) -> Option<ItemId>
[src]

Inserts an element with the provided bounding box.

pub fn first(&self) -> Option<ItemId>[src]

Returns an ItemId for the first element that was inserted into the tree.

pub fn insert(&mut self, t: T) -> Option<ItemId> where
    T: Spatial<S>, 
[src]

Inserts an element into the tree.

pub fn get(&self, id: ItemId) -> Option<&T>[src]

Retrieves an element by looking it up from the ItemId.

pub fn query(
    &self,
    bounding_box: TypedRect<f32, S>
) -> SmallVec<[(&T, TypedRect<f32, S>, ItemId); 3]> where
    T: Debug
[src]

Returns an iterator of (element, bounding-box, id) for each element whose bounding box intersects with bounding_box.

pub fn custom_query<'a, B, F>(
    &'a self,
    query_aabb: TypedRect<f32, S>,
    on_find: &mut F
) -> QueryResult<B> where
    F: FnMut(ItemId, TypedRect<f32, S>) -> QueryResult<B>, 
[src]

Executes 'on_find' for every element found in the bounding-box

pub fn remove(&mut self, item_id: ItemId) -> Option<(T, TypedRect<f32, S>)>[src]

Attempts to remove the item with id item_id from the tree. If that item was present, it returns a tuple of (element, bounding-box)

pub fn iter(&self) -> Iter<ItemId, (T, TypedRect<f32, S>)>[src]

Returns an iterator over all the items in the tree.

pub fn inspect<F: FnMut(&TypedRect<f32, S>, usize, bool)>(&self, f: F)[src]

Calls f repeatedly for every node in the tree with these arguments

  • &Rect: The boudning box of that tree node
  • usize: The current depth
  • bool: True if the node is a leaf-node, False if the node is a branch node.

pub fn len(&self) -> usize[src]

Returns the number of elements in the tree

pub fn is_empty(&self) -> bool[src]

Returns true if the tree is empty.

pub fn bounding_box(&self) -> TypedRect<f32, S>[src]

Returns the enclosing bounding-box for the entire tree.

Trait Implementations

impl<T: Clone, S: Clone, A: Clone + Array<Item = (ItemId, TypedRect<f32, S>)>> Clone for QuadTree<T, S, A>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<T: Debug, S, A: Array<Item = (ItemId, TypedRect<f32, S>)>> Debug for QuadTree<T, S, A>[src]

Auto Trait Implementations

impl<T, S, A> Send for QuadTree<T, S, A> where
    S: Send,
    T: Send

impl<T, S, A> Sync for QuadTree<T, S, A> where
    A: Sync,
    S: Sync,
    T: Sync

Blanket Implementations

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]