[][src]Struct broccoli::query::QueryBuilder

pub struct QueryBuilder<'a, 'b: 'a, A: Axis, T: Aabb> { /* fields omitted */ }

Builder for a query on a DinoTree.

Implementations

impl<'a, 'b: 'a, A: Axis, T: Aabb + Send + Sync> QueryBuilder<'a, 'b, A, T> where
    T::Num: Send + Sync
[src]

pub fn query_par(
    self,
    func: impl Fn(PMut<'_, T>, PMut<'_, T>) + Clone + Send + Sync
)
[src]

Perform the query in parallel

pub fn query_par_ext<B: Send + Sync>(
    self,
    split: impl Fn(&mut B) -> (B, B) + Send + Sync + Copy,
    fold: impl Fn(&mut B, B, B) + Send + Sync + Copy,
    collision: impl Fn(&mut B, PMut<'_, T>, PMut<'_, T>) + Send + Sync + Copy,
    acc: B
) -> B where
    T: Send + Sync,
    T::Num: Send + Sync
[src]

An extended version of find_colliding_pairs. where the user can supply callbacks to when new worker tasks are spawned and joined by rayon. Allows the user to potentially collect some aspect of every aabb collision in parallel.

Examples

 use broccoli::{prelude::*,bbox,rect};
 let mut bots = [bbox(rect(0,10,0,10),0u8),bbox(rect(5,15,5,15),1u8)];
 let mut tree = broccoli::new(&mut bots);
 let intersections=tree.new_colfind_builder().query_par_ext(
     |_|(Vec::new(),Vec::new()),              //Start a new thread
     |a,mut b,mut c|{a.append(&mut b);a.append(&mut c)},  //Combine two threads
     |v,a,b|v.push((*a.unpack_inner(),*b.unpack_inner())),     //What to do for each intersection for a thread.
     Vec::new()                  //Starting thread
 );

 assert_eq!(intersections.len(),1);

pub fn query_splitter_par<C: ColMulti<T = T> + Splitter + Send + Sync>(
    self,
    clos: C
) -> C
[src]

Trait version of QueryBuilder::query_par_ext. The user has more control using this version of the query. The splitter will split and add at every level. The clos will split and add only at levels that are handled in parallel. The leaf_start function will get called right before sequential processing. The leaf end function will get called when the sequential processing finishes. This can be useful if the use wants to create a list of colliding pair indicies, but still wants paralleism.

impl<'a, 'b: 'a, A: Axis, T: Aabb> QueryBuilder<'a, 'b, A, T>[src]

#[must_use]pub fn new(
    axis: A,
    vistr: VistrMut<'a, Node<'b, T>>
) -> QueryBuilder<'a, 'b, A, T>
[src]

Create the builder.

#[must_use]pub fn with_switch_height(self, height: usize) -> Self[src]

Choose a custom height at which to switch from parallel to sequential. If you end up building sequentially, this option is ignored.

pub fn query_seq(self, func: impl FnMut(PMut<'_, T>, PMut<'_, T>))[src]

Perform the query sequentially.

pub fn query_with_splitter_seq(
    self,
    func: impl FnMut(PMut<'_, T>, PMut<'_, T>),
    splitter: &mut impl Splitter
)
[src]

Perform the query sequentially with a splitter.

Auto Trait Implementations

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

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

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

impl<'a, 'b, A, T> Unpin for QueryBuilder<'a, 'b, A, T> where
    A: Unpin,
    'b: 'a, 
[src]

impl<'a, 'b, A, T> !UnwindSafe for QueryBuilder<'a, 'b, 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.