use super::{SimplexId, SimplicialComplex};
pub trait FilteredComplex {
type CellId: Copy + Eq + std::hash::Hash;
fn cells(&self) -> impl Iterator<Item = Self::CellId> + '_;
fn dimension(&self, cell: Self::CellId) -> usize;
fn filtration_value(&self, cell: Self::CellId) -> f64;
fn boundary(&self, cell: Self::CellId) -> impl Iterator<Item = (Self::CellId, i32)> + '_;
}
impl FilteredComplex for SimplicialComplex {
type CellId = SimplexId;
fn cells(&self) -> impl Iterator<Item = SimplexId> + '_ {
(0..self.len()).map(SimplexId)
}
fn dimension(&self, cell: SimplexId) -> usize {
self.simplex(cell).expect("valid simplex ID").dimension()
}
fn filtration_value(&self, cell: SimplexId) -> f64 {
self.simplex(cell).expect("valid simplex ID").value()
}
fn boundary(&self, cell: SimplexId) -> impl Iterator<Item = (SimplexId, i32)> + '_ {
self.boundary(cell)
.expect("valid simplex ID")
.iter()
.map(|term| (term.face, i32::from(term.coefficient)))
}
}