diff --git a/Cargo.toml b/Cargo.toml index e916941..c4b2dd8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "regioners" -version = "0.3.0" +version = "0.3.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/overlappers.rs b/src/overlappers.rs index 42f4855..aba41de 100644 --- a/src/overlappers.rs +++ b/src/overlappers.rs @@ -16,19 +16,19 @@ pub enum Overlapper { impl Overlapper { pub fn ovl(&self, a_intv: &Lapper, b_intv: &Lapper) -> u64 { match self { - /* Return number of A intervals intersecting a B intervals */ + /* Return number of B intervals intersecting each A interval */ Overlapper::All => a_intv + .iter() + .map(|i| b_intv.find(i.start, i.stop).count() as u64) + .sum(), + /* Return number of A intervals intersecting a B intervals */ + Overlapper::Any => a_intv .iter() .map(|i| match b_intv.find(i.start, i.stop).next() { Some(_) => 1, None => 0, }) .sum(), - /* Return number of b intervals intersecting each of a's intervals */ - Overlapper::Any => a_intv - .iter() - .map(|i| b_intv.find(i.start, i.stop).count() as u64) - .sum(), } } }