[−][src]Trait broccoli::query::Queries
Query functions. User defines vistr()
functions, and the query functions
are automatically provided by this trait.
Associated Types
Loading content...Required methods
#[must_use]pub fn vistr_mut(&mut self) -> VistrMut<'_, NodeMut<'a, Self::T>>
[src]
Examples
use broccoli::{prelude::*,bbox,rect}; let mut bots = [bbox(rect(0,10,0,10),0)]; let mut tree = broccoli::new(&mut bots); use compt::Visitor; for mut b in tree.vistr_mut().dfs_preorder_iter().flat_map(|n|n.get_mut().bots.iter_mut()){ *b.inner_mut()+=1; } assert_eq!(bots[0].inner,1);
#[must_use]pub fn vistr(&self) -> Vistr<'_, NodeMut<'a, Self::T>>
[src]
Examples
use broccoli::{prelude::*,bbox,rect}; let mut bots = [rect(0,10,0,10)]; let mut tree = broccoli::new(&mut bots); use compt::Visitor; let mut test = Vec::new(); for b in tree.vistr().dfs_preorder_iter().flat_map(|n|n.get().bots.iter()){ test.push(b); } assert_eq!(test[0],&axgeom::rect(0,10,0,10));
#[must_use]pub fn axis(&self) -> Self::A
[src]
Examples
use broccoli::{prelude::*,bbox,rect}; let mut bots = [rect(0,10,0,10)]; let mut tree = broccoli::new(&mut bots); use axgeom::Axis; assert!(tree.axis().is_equal_to(broccoli::default_axis()));
Provided methods
pub fn draw_divider(
&self,
drawer: &mut impl DividerDrawer<N = Self::Num>,
rect: &Rect<Self::Num>
)
[src]
&self,
drawer: &mut impl DividerDrawer<N = Self::Num>,
rect: &Rect<Self::Num>
)
Examples
use broccoli::{prelude::*,bbox,rect}; struct Drawer; impl broccoli::query::DividerDrawer for Drawer{ type N=i32; fn draw_divider<A:axgeom::Axis>( &mut self, axis:A, div:Self::N, cont:[Self::N;2], length:[Self::N;2], depth:usize) { if axis.is_xaxis(){ //draw vertical line }else{ //draw horizontal line } } } let border=rect(0,100,0,100); let mut bots =[rect(0,10,0,10)]; let tree=broccoli::new(&mut bots); tree.draw_divider(&mut Drawer,&border);
pub fn find_colliding_pairs_pmut(
&mut self,
func: impl FnMut(PMut<'_, Self::T>, PMut<'_, Self::T>)
)
[src]
&mut self,
func: impl FnMut(PMut<'_, Self::T>, PMut<'_, Self::T>)
)
Find all aabb intersections and return a PMutfind_colliding_pairs_mut
, this allows the
user to access a read only reference of the AABB.
Examples
use broccoli::{prelude::*,bbox,rect}; let mut bots = [bbox(rect(0,10,0,10),0u8),bbox(rect(5,15,5,15),0u8)]; let mut tree = broccoli::new(&mut bots); tree.find_colliding_pairs_pmut(|mut a,mut b|{ *a.inner_mut()+=1; *b.inner_mut()+=1; }); assert_eq!(bots[0].inner,1); assert_eq!(bots[1].inner,1);
pub fn find_colliding_pairs_pmut_par(
&mut self,
func: impl Fn(PMut<'_, Self::T>, PMut<'_, Self::T>) + Send + Sync + Copy
) where
Self::T: Send + Sync,
[src]
&mut self,
func: impl Fn(PMut<'_, Self::T>, PMut<'_, Self::T>) + Send + Sync + Copy
) where
Self::T: Send + Sync,
The parallel version of Queries::find_colliding_pairs_pmut
.
Examples
use broccoli::{prelude::*,bbox,rect}; let mut bots = [bbox(rect(0,10,0,10),0u8),bbox(rect(5,15,5,15),0u8)]; let mut tree = broccoli::new(&mut bots); tree.find_colliding_pairs_pmut_par(|mut a,mut b|{ *a.inner_mut()+=1; *b.inner_mut()+=1; }); assert_eq!(bots[0].inner,1); assert_eq!(bots[1].inner,1);
pub fn new_colfind_builder(
&mut self
) -> QueryBuilder<'_, Self::A, NodeMut<'a, Self::T>>
[src]
&mut self
) -> QueryBuilder<'_, Self::A, NodeMut<'a, Self::T>>
For analysis, allows the user to query with custom settings
Examples
use broccoli::{prelude::*,bbox,rect}; let mut bots = [bbox(rect(0,10,0,10),0u8),bbox(rect(5,15,5,15),0u8)]; let mut tree = broccoli::new(&mut bots); let builder=tree.new_colfind_builder(); let builder=builder.with_switch_height(4); builder.query_seq(|mut a,mut b|{ *a.inner_mut()+=1; *b.inner_mut()+=1; }); assert_eq!(bots[0].inner,1); assert_eq!(bots[1].inner,1);
#[must_use]pub fn multi_rect(&mut self) -> MultiRectMut<'_, Self::A, NodeMut<'a, Self::T>>
[src]
Examples
use broccoli::{prelude::*,bbox,rect}; let mut bots1 = [bbox(rect(0,10,0,10),0u8)]; let mut tree = broccoli::new(&mut bots1); let mut multi = tree.multi_rect(); multi.for_all_in_rect_mut(rect(0,10,0,10),|a|{}).unwrap(); let res = multi.for_all_in_rect_mut(rect(5,15,5,15),|a|{}); assert_eq!(res,Err(broccoli::query::RectIntersectErr));
pub fn for_all_intersect_rect<'b>(
&'b self,
rect: &Rect<Self::Num>,
func: impl FnMut(&'b Self::T)
) where
'a: 'b,
[src]
&'b self,
rect: &Rect<Self::Num>,
func: impl FnMut(&'b Self::T)
) where
'a: 'b,
Examples
use broccoli::{prelude::*,bbox,rect}; let mut bots = [rect(0,10,0,10),rect(20,30,20,30)]; let mut tree = broccoli::new(&mut bots); let mut test = Vec::new(); tree.for_all_intersect_rect(&rect(9,20,9,20),|a|{ test.push(a); }); assert_eq!(test[0],&rect(0,10,0,10));
pub fn for_all_in_rect<'b>(
&'b self,
rect: &Rect<Self::Num>,
func: impl FnMut(&'b Self::T)
) where
'a: 'b,
[src]
&'b self,
rect: &Rect<Self::Num>,
func: impl FnMut(&'b Self::T)
) where
'a: 'b,
Examples
use broccoli::{prelude::*,bbox,rect}; let mut bots = [rect(0,10,0,10),rect(20,30,20,30)]; let mut tree = broccoli::new(&mut bots); let mut test = Vec::new(); tree.for_all_in_rect(&rect(0,20,0,20),|a|{ test.push(a); }); assert_eq!(test[0],&rect(0,10,0,10));
pub fn nbody_mut<X: NodeMassTrait<Num = Self::Num, Item = Self::T> + Send + Sync>(
&mut self,
ncontext: &X,
rect: Rect<Self::Num>
) where
X::No: Send,
Self::T: HasInner + Send + Sync,
[src]
&mut self,
ncontext: &X,
rect: Rect<Self::Num>
) where
X::No: Send,
Self::T: HasInner + Send + Sync,
Experimental. See broccoli demo
pub fn nbody_mut_par<X: NodeMassTrait<Num = Self::Num, Item = Self::T> + Sync + Send>(
&mut self,
ncontext: &X,
rect: Rect<Self::Num>
) where
X::No: Send,
Self::T: HasInner + Send + Sync,
[src]
&mut self,
ncontext: &X,
rect: Rect<Self::Num>
) where
X::No: Send,
Self::T: HasInner + Send + Sync,
Experimental. See broccoli demo