Topology
This commit is contained in:
parent
62c2192541
commit
16a54b3912
@ -18,12 +18,37 @@ pub trait MentionableTop<'a, Ctx: Context<'a>>: 'a {
|
||||
fn points_typed(&self, points: &mut impl PointsVisitor<'a, Ctx>)
|
||||
where
|
||||
Self: Mentionable<'a, Ctx>;
|
||||
|
||||
fn topology(&self) -> Arc<dyn Topology<'a, Ctx>>
|
||||
where
|
||||
Self: Mentionable<'a, Ctx>,
|
||||
{
|
||||
let mut vec: TopoVec<'a, Ctx> = Vec::new();
|
||||
self.points_typed(&mut vec);
|
||||
Arc::new(vec)
|
||||
}
|
||||
}
|
||||
|
||||
pub type TopoVec<'a, Ctx> = Vec<Arc<dyn SingularResolution<'a, Ctx>>>;
|
||||
|
||||
impl<'a, Ctx: Context<'a>> PointsVisitor<'a, Ctx> for TopoVec<'a, Ctx> {
|
||||
fn visit<A: Mentionable<'a, Ctx>>(&mut self, point: &Point<'a, Ctx, A>) {
|
||||
self.push(Arc::new(point.clone()) as _);
|
||||
self.push(Arc::new(point.clone()));
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Topology<'a, Ctx: Context<'a>>: 'a {
|
||||
fn points_count(&self) -> usize;
|
||||
|
||||
fn point_at(&self, index: usize) -> Option<Arc<dyn SingularResolution<'a, Ctx>>>;
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>> Topology<'a, Ctx> for TopoVec<'a, Ctx> {
|
||||
fn points_count(&self) -> usize {
|
||||
self.len()
|
||||
}
|
||||
|
||||
fn point_at(&self, index: usize) -> Option<Arc<dyn SingularResolution<'a, Ctx>>> {
|
||||
self.get(index).cloned()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user