use super::JobCostModel;
use crate::time::Service;
#[derive(Debug, Clone)]
pub struct Multiframe {
costs: Vec<Service>,
}
impl Multiframe {
pub fn new(costs: Vec<Service>) -> Self {
Multiframe { costs }
}
}
impl JobCostModel for Multiframe {
fn job_cost_iter<'a>(&'a self) -> Box<dyn Iterator<Item = Service> + 'a> {
Box::new(self.costs.iter().copied().cycle())
}
fn least_wcet(&self, n: usize) -> Service {
self.costs
.iter()
.take(n)
.copied()
.min()
.unwrap_or_else(Service::none)
}
}