[][src]Struct broccoli::Tree

#[repr(C)]pub struct Tree<'a, T: Aabb> { /* fields omitted */ }

A space partitioning tree.

Implementations

impl<'a, T: Aabb> Tree<'a, T>[src]

pub fn new(bots: &'a mut [T]) -> Tree<'a, T>[src]

Create a Tree.

Examples

 let mut bots = [axgeom::rect(0,10,0,10)];
 let tree = broccoli::Tree::new(&mut bots);

pub fn new_par(joiner: impl Joinable, bots: &'a mut [T]) -> Tree<'a, T> where
    T: Send + Sync,
    T::Num: Send + Sync
[src]

Create a Tree in parallel.

Examples

 let mut bots = [axgeom::rect(0,10,0,10)];
 let tree = broccoli::Tree::new_par(broccoli::RayonJoin,&mut bots);

#[must_use]pub fn get_height(&self) -> usize[src]

Examples

 use broccoli::build;
 const NUM_ELEMENT:usize=40;
 let mut bots = [axgeom::rect(0,10,0,10);NUM_ELEMENT];
 let mut tree = broccoli::new(&mut bots);

 assert_eq!(tree.get_height(),build::TreePreBuilder::new(NUM_ELEMENT).get_height());

#[must_use]pub fn into_inner(self) -> CompleteTreeContainer<Node<'a, T>, PreOrder>[src]

Examples

 use broccoli::build;
 const NUM_ELEMENT:usize=7;
 let mut bots = [axgeom::rect(0,10,0,10);NUM_ELEMENT];
 let mut tree = broccoli::new(&mut bots);
 let inner =tree.into_inner();
 assert_eq!(inner.into_nodes().len(),1);

#[must_use]pub fn num_aabbs(&self) -> usize[src]

Examples

 use broccoli::build;
 const NUM_ELEMENT:usize=7;
 let mut bots = [axgeom::rect(0,10,0,10);NUM_ELEMENT];
 let mut tree = broccoli::new(&mut bots);

 assert_eq!(tree.num_aabbs(),7);

pub unsafe fn from_raw_parts(
    inner: CompleteTreeContainer<Node<'a, T>, PreOrder>,
    num_aabbs: usize
) -> Self
[src]

Examples

 use broccoli::build;
 const NUM_ELEMENT:usize=7;
 let mut bots = [axgeom::rect(0,10,0,10);NUM_ELEMENT];
 let mut tree = broccoli::new(&mut bots);
 let num_aabbs=tree.num_aabbs();
 let inner =tree.into_inner();
 let tree=unsafe{broccoli::Tree::from_raw_parts(inner,num_aabbs)};
 assert_eq!(tree.num_aabbs(),7);

Safety

Unsafe, since the user may pass a number of aabbs that does not reflect the true number of aabbs in every node.

#[must_use]pub fn num_nodes(&self) -> usize[src]

Examples

 use broccoli::build;
 let mut bots = [axgeom::rect(0,10,0,10)];
 let mut tree = broccoli::new(&mut bots);

 assert_eq!(tree.num_nodes(),build::TreePreBuilder::new(1).num_nodes());

#[must_use]pub fn get_nodes(&self) -> &[Node<'a, T>]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

Examples

 let mut bots = [axgeom::rect(0,10,0,10)];
 let mut tree = broccoli::new(&mut bots);

 assert_eq!(tree.get_nodes()[0].range[0], axgeom::rect(0,10,0,10));

#[must_use]pub fn get_nodes_mut(&mut self) -> PMut<'_, [Node<'a, T>]>[src]

Examples

 let mut bots = [axgeom::rect(0,10,0,10)];
 let mut tree = broccoli::new(&mut bots);

 assert_eq!(tree.get_nodes_mut().get_index_mut(0).range[0], axgeom::rect(0,10,0,10));

#[must_use]pub fn get_elements_mut(&mut self) -> PMut<'_, [T]>[src]

Return the underlying slice of aabbs in the order sorted during tree construction.

Examples

 let mut bots = [axgeom::rect(0,10,0,10)];
 let mut tree = broccoli::new(&mut bots);

 assert_eq!(*tree.get_elements_mut().get_index_mut(0), axgeom::rect(0,10,0,10));

#[must_use]pub fn get_elements(&self) -> &[T]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

Return the underlying slice of aabbs in the order sorted during tree construction.

Examples

 let mut bots = [axgeom::rect(0,10,0,10)];
 let tree = broccoli::new(&mut bots);

 assert_eq!(tree.get_elements()[0], axgeom::rect(0,10,0,10));

Trait Implementations

impl<'a, T: Aabb> ColfindQuery<'a> for Tree<'a, T>[src]

impl<'a, T: Aabb> DrawQuery<'a> for Tree<'a, T>[src]

impl<'a, 'b, N: Num, T> From<TreeInd<'a, 'b, N, T>> for Tree<'b, BBox<N, &'a mut T>>[src]

impl<'a, T: Aabb> IntersectQuery<'a> for Tree<'a, T>[src]

impl<'a, T: Aabb> KnearestQuery<'a> for Tree<'a, T>[src]

impl<'a, T: Aabb> Queries<'a> for Tree<'a, T>[src]

type T = T

type Num = T::Num

impl<'a, T: Aabb> RaycastQuery<'a> for Tree<'a, T>[src]

impl<'a, T: Aabb> RectQuery<'a> for Tree<'a, T>[src]

Auto Trait Implementations

impl<'a, T> RefUnwindSafe for Tree<'a, T> where
    T: RefUnwindSafe,
    <T as Aabb>::Num: RefUnwindSafe
[src]

impl<'a, T> Send for Tree<'a, T> where
    T: Send,
    <T as Aabb>::Num: Send
[src]

impl<'a, T> Sync for Tree<'a, T> where
    T: Sync,
    <T as Aabb>::Num: Sync
[src]

impl<'a, T> Unpin for Tree<'a, T>[src]

impl<'a, T> !UnwindSafe for Tree<'a, T>[src]

Blanket Implementations

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

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

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

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

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

impl<T> Pointable for T

type Init = T

The type for initializers.

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.