[][src]Trait broccoli::query::rect::RectQuery

pub trait RectQuery<'a>: Queries<'a> {
    fn for_all_intersect_rect<'b>(
        &'b self,
        rect: &Rect<Self::Num>,
        func: impl FnMut(&'b Self::T)
    )
    where
        'a: 'b
, { ... }
fn for_all_intersect_rect_mut<'b>(
        &'b mut self,
        rect: &Rect<Self::Num>,
        mut func: impl FnMut(PMut<'b, Self::T>)
    )
    where
        'a: 'b
, { ... }
fn for_all_in_rect<'b>(
        &'b self,
        rect: &Rect<Self::Num>,
        func: impl FnMut(&'b Self::T)
    )
    where
        'a: 'b
, { ... }
fn for_all_in_rect_mut<'b>(
        &'b mut self,
        rect: &Rect<Self::Num>,
        mut func: impl FnMut(PMut<'b, Self::T>)
    )
    where
        'a: 'b
, { ... }
fn for_all_not_in_rect_mut<'b>(
        &'b mut self,
        rect: &Rect<Self::Num>,
        mut func: impl FnMut(PMut<'b, Self::T>)
    )
    where
        'a: 'b
, { ... }
#[must_use] fn multi_rect<'c>(&'c mut self) -> MultiRect<'c, 'a, Self::T> { ... } }

Rect functions that can be called on a tree.

Provided methods

fn for_all_intersect_rect<'b>(
    &'b self,
    rect: &Rect<Self::Num>,
    func: impl FnMut(&'b Self::T)
) where
    'a: 'b, 
[src]

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));

fn for_all_intersect_rect_mut<'b>(
    &'b mut self,
    rect: &Rect<Self::Num>,
    mut func: impl FnMut(PMut<'b, Self::T>)
) where
    'a: 'b, 
[src]

Examples

 use broccoli::{prelude::*,bbox,rect};
 let mut bots = [bbox(rect(0,10,0,10),0u8)];
 let mut tree = broccoli::new(&mut bots);
 tree.for_all_intersect_rect_mut(&rect(9,20,9,20),|a|{
    *a.unpack_inner()+=1;    
 });

 assert_eq!(bots[0].inner,1);

fn for_all_in_rect<'b>(
    &'b self,
    rect: &Rect<Self::Num>,
    func: impl FnMut(&'b Self::T)
) where
    'a: 'b, 
[src]

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));

fn for_all_in_rect_mut<'b>(
    &'b mut self,
    rect: &Rect<Self::Num>,
    mut func: impl FnMut(PMut<'b, Self::T>)
) where
    'a: 'b, 
[src]

Examples

 use broccoli::{prelude::*,bbox,rect};
 let mut bots = [bbox(rect(0,10,0,10),0u8)];
 let mut tree = broccoli::new(&mut bots);
 tree.for_all_in_rect_mut(&rect(0,10,0,10),|a|{
    *a.unpack_inner()+=1;    
 });

 assert_eq!(bots[0].inner,1);

fn for_all_not_in_rect_mut<'b>(
    &'b mut self,
    rect: &Rect<Self::Num>,
    mut func: impl FnMut(PMut<'b, Self::T>)
) where
    'a: 'b, 
[src]

Examples

 use broccoli::{prelude::*,bbox,rect};
 let mut bots = [bbox(rect(0,10,0,10),0u8)];
 let mut tree = broccoli::new(&mut bots);
 tree.for_all_not_in_rect_mut(&rect(10,20,10,20),|a|{
    *a.unpack_inner()+=1;    
 });

 assert_eq!(bots[0].inner,1);

#[must_use]fn multi_rect<'c>(&'c mut self) -> MultiRect<'c, 'a, Self::T>[src]

If we have two non intersecting rectangles, it is safe to return to the user two sets of mutable references of the bots strictly inside each rectangle since it is impossible for a bot to belong to both sets.

Safety

Unsafe code is used. We unsafely convert the references returned by the rect query closure to have a longer lifetime. This allows the user to store mutable references of non intersecting rectangles at the same time. If two requested rectangles intersect, an error is returned.

Handles a multi rect mut "sessions" within which the user can query multiple non intersecting rectangles.

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::rect::RectIntersectErr));
Loading content...

Implementors

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

Loading content...