| 244 A: Aggregator, |
244 A: Aggregator, |
| 245 D: 'static + Copy + Send + Sync, |
245 D: 'static + Copy + Send + Sync, |
| 246 { |
246 { |
| 247 /// Creates a new node branching structure, subdividing `domain` based on the |
247 /// Creates a new node branching structure, subdividing `domain` based on the |
| 248 /// [hint][Support::support_hint] of `support`. |
248 /// [hint][Support::support_hint] of `support`. |
| 249 pub(super) fn new_with<S: LocalAnalysis<F, A, N>>(domain: &Cube<F, N>, support: &S) -> Self { |
249 pub(super) fn new_with<S: LocalAnalysis<F, A, N> + Support<F, N>>( |
| |
250 domain: &Cube<F, N>, |
| |
251 support: &S, |
| |
252 ) -> Self { |
| 250 let hint = support.bisection_hint(domain); |
253 let hint = support.bisection_hint(domain); |
| 251 let branch_at = map2(&hint, domain, |h, r| { |
254 let branch_at = map2(&hint, domain, |h, r| { |
| 252 h.unwrap_or_else(|| (r[0] + r[1]) / F::TWO) |
255 h.unwrap_or_else(|| (r[0] + r[1]) / F::TWO) |
| 253 .max(r[0]) |
256 .max(r[0]) |
| 254 .min(r[1]) |
257 .min(r[1]) |
| 327 /// * `d` is the data to be inserted |
330 /// * `d` is the data to be inserted |
| 328 /// * `new_leaf_depth` is the depth relative to `self` at which the data is to be inserted. |
331 /// * `new_leaf_depth` is the depth relative to `self` at which the data is to be inserted. |
| 329 /// * `support` is the [`Support`] that is used determine with which subcubes of `domain` |
332 /// * `support` is the [`Support`] that is used determine with which subcubes of `domain` |
| 330 /// (at subdivision depth `new_leaf_depth`) the data `d` is to be associated with. |
333 /// (at subdivision depth `new_leaf_depth`) the data `d` is to be associated with. |
| 331 /// |
334 /// |
| 332 pub(super) fn insert<'refs, 'scope, M: Depth, S: LocalAnalysis<F, A, N>>( |
335 pub(super) fn insert<'refs, 'scope, M: Depth, S: LocalAnalysis<F, A, N> + Support<F, N>>( |
| 333 &mut self, |
336 &mut self, |
| 334 domain: &Cube<F, N>, |
337 domain: &Cube<F, N>, |
| 335 d: D, |
338 d: D, |
| 336 new_leaf_depth: M, |
339 new_leaf_depth: M, |
| 337 support: &S, |
340 support: &S, |
| 454 /// |
457 /// |
| 455 /// If `self` is already [`NodeOption::Leaf`], the data is inserted directly in this node. |
458 /// If `self` is already [`NodeOption::Leaf`], the data is inserted directly in this node. |
| 456 /// If `self` is a [`NodeOption::Branches`], the data is passed to branches whose subcubes |
459 /// If `self` is a [`NodeOption::Branches`], the data is passed to branches whose subcubes |
| 457 /// `support` intersects. If an [`NodeOption::Uninitialised`] node is encountered, a new leaf is |
460 /// `support` intersects. If an [`NodeOption::Uninitialised`] node is encountered, a new leaf is |
| 458 /// created at a minimum depth of `new_leaf_depth`. |
461 /// created at a minimum depth of `new_leaf_depth`. |
| 459 pub(super) fn insert<'refs, 'scope, M: Depth, S: LocalAnalysis<F, A, N>>( |
462 pub(super) fn insert<'refs, 'scope, M: Depth, S: LocalAnalysis<F, A, N> + Support<F, N>>( |
| 460 &mut self, |
463 &mut self, |
| 461 domain: &Cube<F, N>, |
464 domain: &Cube<F, N>, |
| 462 d: D, |
465 d: D, |
| 463 new_leaf_depth: M, |
466 new_leaf_depth: M, |
| 464 support: &S, |
467 support: &S, |
| 624 |
627 |
| 625 /// Insert the data `d` into the tree for `support`. |
628 /// Insert the data `d` into the tree for `support`. |
| 626 /// |
629 /// |
| 627 /// Every leaf node of the tree that intersects the `support` will contain a copy of |
630 /// Every leaf node of the tree that intersects the `support` will contain a copy of |
| 628 /// `d`. |
631 /// `d`. |
| 629 fn insert<S: LocalAnalysis<F, Self::Agg, N>>(&mut self, d: Self::Data, support: &S); |
632 fn insert<S: LocalAnalysis<F, Self::Agg, N> + Support<F, N>>( |
| |
633 &mut self, |
| |
634 d: Self::Data, |
| |
635 support: &S, |
| |
636 ); |
| 630 |
637 |
| 631 /// Construct a new instance of the tree for a different aggregator |
638 /// Construct a new instance of the tree for a different aggregator |
| 632 /// |
639 /// |
| 633 /// The `generator` is used to convert the data of type [`Self::Data`] contained in the tree |
640 /// The `generator` is used to convert the data of type [`Self::Data`] contained in the tree |
| 634 /// into corresponding [`Support`]s. |
641 /// into corresponding [`Support`]s. |
| 694 type Data = D; |
701 type Data = D; |
| 695 type Depth = M; |
702 type Depth = M; |
| 696 type Agg = A; |
703 type Agg = A; |
| 697 type Converted<ANew> = BT<M,F,D,ANew,$n> where ANew : Aggregator; |
704 type Converted<ANew> = BT<M,F,D,ANew,$n> where ANew : Aggregator; |
| 698 |
705 |
| 699 fn insert<S: LocalAnalysis<F, A, $n>>( |
706 fn insert<S: LocalAnalysis<F, A, $n> + Support<F, $n>>( |
| 700 &mut self, |
707 &mut self, |
| 701 d : D, |
708 d : D, |
| 702 support : &S |
709 support : &S |
| 703 ) { |
710 ) { |
| 704 with_task_budget(|task_budget| |
711 with_task_budget(|task_budget| |