-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from bmatthieu3/overlap
Add a overlapped_by_iter method in RangeMOC and BorrowedRangeMOC.
- Loading branch information
Showing
4 changed files
with
347 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use std::{marker::PhantomData, ops::Range}; | ||
|
||
use crate::{ | ||
elemset::range::BorrowedMocRanges, | ||
idx::Idx, | ||
moc::{range::RangeRefMocIter, HasMaxDepth, NonOverlapping, RangeMOCIntoIterator, ZSorted}, | ||
qty::MocQty, | ||
}; | ||
|
||
pub struct BorrowedRangeMOC<'a, T: Idx, Q: MocQty<T>> { | ||
depth_max: u8, | ||
ranges: BorrowedMocRanges<'a, T, Q>, | ||
} | ||
|
||
impl<'a, T: Idx, Q: MocQty<T>> BorrowedRangeMOC<'a, T, Q> { | ||
pub fn new(depth_max: u8, ranges: BorrowedMocRanges<'a, T, Q>) -> Self { | ||
Self { depth_max, ranges } | ||
} | ||
} | ||
|
||
impl<'a, T: Idx, Q: MocQty<T>> HasMaxDepth for BorrowedRangeMOC<'a, T, Q> { | ||
fn depth_max(&self) -> u8 { | ||
self.depth_max | ||
} | ||
} | ||
impl<'a, T: Idx, Q: MocQty<T>> ZSorted for BorrowedRangeMOC<'a, T, Q> {} | ||
impl<'a, T: Idx, Q: MocQty<T>> NonOverlapping for BorrowedRangeMOC<'a, T, Q> {} | ||
|
||
impl<'a, T: Idx, Q: MocQty<T>> RangeMOCIntoIterator<T> for BorrowedRangeMOC<'a, T, Q> { | ||
type Qty = Q; | ||
type IntoRangeMOCIter = RangeRefMocIter<'a, T, Self::Qty>; | ||
|
||
fn into_range_moc_iter(self) -> Self::IntoRangeMOCIter { | ||
let l = self.ranges.0 .0.len(); | ||
let last: Option<Range<T>> = if l > 0 { | ||
Some(self.ranges.0 .0[l - 1].clone()) | ||
} else { | ||
None | ||
}; | ||
RangeRefMocIter { | ||
depth_max: self.depth_max, | ||
iter: self.ranges.0 .0.iter(), | ||
last, | ||
_qty: PhantomData, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,5 @@ pub mod or; // <=> union | |
pub mod xor; // <=> Aladin Difference | ||
|
||
pub mod multi_op; | ||
|
||
pub mod overlap; |
Oops, something went wrong.