[−][src]Trait broccoli::query::from_slice::FromSlice
A trait indicating that this is a tree that is composed of pointers to the same underlying slice. Unsafe because the user must guarantee that all the pointers in the tree originate from the same slice.
Associated Types
type T: Aabb<Num = Self::Num> + HasInner<Inner = &'a mut Self::Inner> + 'b
[src]
The tree must be filled with T, which must have a pointer to Self::Inner
.
type Num: Num
[src]
The number type of the aabb.
type Inner: 'a
[src]
The type that the pointers are pointing to. The original slice is composed of this.
Required methods
fn get_tree_mut(&mut self) -> &mut Tree<'b, Self::T>
[src]
Return a reference to the underlying tree.
Examples
use broccoli::prelude::*; let mut aabbs = [ broccoli::bbox(broccoli::rect(0isize, 10, 0, 10), 0), ]; let mut base=broccoli::container::TreeIndBase::new(&mut aabbs,|a|a.rect); let mut tree_cont = base.build(); tree_cont.get_tree_mut().find_colliding_pairs_mut(|a,b|{});
fn get_inner_elements(&self) -> &[Self::Inner]ⓘ
[src]
Retrieve the underlying list of elements.
Unlike Tree::get_elements_mut()
which
returns the aabbs of the tree, this returns the
list of T that each aabb points to.
Examples
use broccoli::prelude::*; let mut aabbs = [ broccoli::bbox(broccoli::rect(0isize, 10, 0, 10), 0), ]; let mut base=broccoli::container::TreeIndBase::new(&mut aabbs,|a|a.rect); let mut tree = base.build(); let bots=tree.get_inner_elements();
fn get_inner_elements_mut(&mut self) -> &mut [Self::Inner]ⓘ
[src]
Retrieve the underlying list of elements.
Unlike Tree::get_elements_mut()
which
returns the aabbs of the tree, this returns the
list of T that each aabb points to.
Examples
use broccoli::prelude::*; let mut aabbs = [ broccoli::bbox(broccoli::rect(0isize, 10, 0, 10), 0), ]; let mut base=broccoli::container::TreeIndBase::new(&mut aabbs,|a|a.rect); let mut tree = base.build(); let bots=tree.get_inner_elements_mut();
Provided methods
fn collect_all<D: Send + Sync>(
&mut self,
mut func: impl FnMut(&Rect<Self::Num>, &mut Self::Inner) -> Option<D>
) -> FilteredElements<Self::Inner, D>
[src]
&mut self,
mut func: impl FnMut(&Rect<Self::Num>, &mut Self::Inner) -> Option<D>
) -> FilteredElements<Self::Inner, D>
Collect all elements based off of a predicate and return a FilteredElements
.
Examples
use broccoli::prelude::*; let mut aabbs = [ broccoli::bbox(broccoli::rect(0isize, 10, 0, 10), 0), broccoli::bbox(broccoli::rect(15, 20, 15, 20), 1), broccoli::bbox(broccoli::rect(5, 15, 5, 15), 2), ]; let mut base=broccoli::container::TreeIndBase::new(&mut aabbs,|a|a.rect); let mut tree = base.build(); //Find a group of elements only once. let mut pairs=tree.collect_all(|_,b| { if b.inner % 2 ==0{ Some(()) }else{ None } }); //Iterate over that group multiple times for _ in 0..3{ //mutate every colliding pair. for (a,()) in pairs.get_mut(&mut aabbs){ a.inner+=1; } }
fn collect_colliding_pairs<D: Send + Sync>(
&mut self,
mut func: impl FnMut(&mut Self::Inner, &mut Self::Inner) -> Option<D> + Send + Sync
) -> CollidingPairs<Self::Inner, D>
[src]
&mut self,
mut func: impl FnMut(&mut Self::Inner, &mut Self::Inner) -> Option<D> + Send + Sync
) -> CollidingPairs<Self::Inner, D>
Find all colliding pairs based on a predicate and return a CollidingPairs
.
Examples
use broccoli::prelude::*; let mut aabbs = [ broccoli::bbox(broccoli::rect(0isize, 10, 0, 10), 0), broccoli::bbox(broccoli::rect(15, 20, 15, 20), 1), broccoli::bbox(broccoli::rect(5, 15, 5, 15), 2), ]; let mut base=broccoli::container::TreeIndBase::new(&mut aabbs,|a|a.rect); let mut tree = base.build(); //Find all colliding aabbs only once. let mut pairs=tree.collect_colliding_pairs(|a, b| { a.inner += 1; b.inner += 1; Some(()) }); //Iterate over the pairs multiple times for _ in 0..3{ //mutate every colliding pair. pairs.for_every_pair_mut(&mut aabbs,|a,b,()|{ a.inner+=1; b.inner+=1; }) }
fn collect_colliding_pairs_par<D: Send + Sync>(
&mut self,
joiner: impl Joinable,
func: impl Fn(&mut Self::Inner, &mut Self::Inner) -> Option<D> + Send + Sync + Copy
) -> CollidingPairsPar<Self::Inner, D> where
Self::T: Send + Sync,
Self::Num: Send + Sync,
[src]
&mut self,
joiner: impl Joinable,
func: impl Fn(&mut Self::Inner, &mut Self::Inner) -> Option<D> + Send + Sync + Copy
) -> CollidingPairsPar<Self::Inner, D> where
Self::T: Send + Sync,
Self::Num: Send + Sync,
The parallel version of FromSlice::collect_colliding_pairs
that instead
returns a CollidingPairsPar
.
Examples
use broccoli::{RayonJoin,prelude::*}; let mut aabbs = [ broccoli::bbox(broccoli::rect(0isize, 10, 0, 10), 0), broccoli::bbox(broccoli::rect(15, 20, 15, 20), 1), broccoli::bbox(broccoli::rect(5, 15, 5, 15), 2), ]; let mut base=broccoli::container::TreeIndBase::new(&mut aabbs,|a|a.rect); let mut tree = base.build_par(RayonJoin); //Find all colliding aabbs only once. let mut pairs=tree.collect_colliding_pairs_par(RayonJoin,|a, b| { a.inner += 1; b.inner += 1; Some(()) }); //Iterate over the pairs multiple times for _ in 0..3{ //mutate every colliding pair. pairs.for_every_pair_mut_par(RayonJoin,&mut aabbs,|a,b,()|{ a.inner+=1; b.inner+=1; }) }