mod segment_iter;
#[cfg(test)]
mod tests;
use std::ops::Range;
pub use segment_iter::SegmentIter;
use super::range_map::RangeMap;
use super::range_map::RangeMapBound;
use super::range_map::RangeMapValue;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct MultiRangeMap<Bound, V, const N: usize>
where
Bound: RangeMapBound,
V: RangeMapValue,
{
range_maps: Vec<RangeMap<Bound, V>>,
}
impl<Bound, V, const N: usize> MultiRangeMap<Bound, V, N>
where
Bound: RangeMapBound,
V: RangeMapValue,
{
pub fn new(capacity: usize) -> Self {
Self {
range_maps: (0..N).map(|_| RangeMap::new(capacity)).collect(),
}
}
pub fn get_mut(&mut self, index: usize) -> &mut RangeMap<Bound, V> {
&mut self.range_maps[index]
}
pub fn truncate(&mut self, begin: Bound, since: Bound) {
for range_map in &mut self.range_maps {
range_map.truncate(begin, since);
}
}
pub fn segments<'a>(&'a self, begin: Bound, excluded: &'a [Range<Bound>]) -> SegmentIter<'a, Bound, V, N> {
SegmentIter::new(begin, &self.range_maps, excluded)
}
}