willow_data_model/grouping/
area_of_interest.rs1use crate::grouping::area::Area;
2
3#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Ord, Hash)]
7pub struct AreaOfInterest<const MCL: usize, const MCC: usize, const MPL: usize, S> {
8 pub area: Area<MCL, MCC, MPL, S>,
10 pub max_count: u64,
12 pub max_size: u64,
14}
15
16impl<const MCL: usize, const MCC: usize, const MPL: usize, S> AreaOfInterest<MCL, MCC, MPL, S> {
17 pub fn new(area: Area<MCL, MCC, MPL, S>, max_count: u64, max_size: u64) -> Self {
19 Self {
20 area,
21 max_count,
22 max_size,
23 }
24 }
25}
26
27impl<const MCL: usize, const MCC: usize, const MPL: usize, S> AreaOfInterest<MCL, MCC, MPL, S>
28where
29 S: PartialOrd + Clone,
30{
31 pub fn intersection(
35 &self,
36 other: &AreaOfInterest<MCL, MCC, MPL, S>,
37 ) -> Option<AreaOfInterest<MCL, MCC, MPL, S>> {
38 self.area
39 .intersection(&other.area)
40 .map(|area_intersection| Self {
41 area: area_intersection,
42 max_count: core::cmp::min(self.max_count, other.max_count),
43 max_size: self.max_size.min(other.max_size),
44 })
45 }
46}