1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
use crate::refinement::termination::Termination;
use crate::refinement::{Individuum, RefinementContext};

/// Stops when quota is reached.
pub struct QuotaReached {}

impl Default for QuotaReached {
    fn default() -> Self {
        Self {}
    }
}

impl Termination for QuotaReached {
    fn is_termination(&self, refinement_ctx: &mut RefinementContext, _: (&Individuum, bool)) -> bool {
        refinement_ctx.get_quota().map_or(false, |quota| quota.is_reached())
    }
}