triangulation: for refs consistently use structs instead of tuples

This commit is contained in:
Mikolaj Wielgus 2024-04-22 01:31:02 +02:00
parent 8d59242f3f
commit 44bbb20e62
1 changed files with 13 additions and 13 deletions

View File

@ -175,13 +175,13 @@ impl<'a, I: Copy + PartialEq + GetNodeIndex, W: GetVertexIndex<I> + HasPosition<
} }
} }
/*#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]
pub struct TriangulationVertexReference<I: Copy, W> { pub struct TriangulationVertexReference<'a, I: Copy, W> {
index: I, index: I,
weight: &'a W, weight: &'a W,
} }
impl<I: Copy> visit::NodeRef for TriangulationVertexReference<I, W> { impl<'a, I: Copy, W: Copy> visit::NodeRef for TriangulationVertexReference<'a, I, W> {
type NodeId = I; type NodeId = I;
type Weight = W; type Weight = W;
@ -192,25 +192,25 @@ impl<I: Copy> visit::NodeRef for TriangulationVertexReference<I, W> {
fn weight(&self) -> &Self::Weight { fn weight(&self) -> &Self::Weight {
self.weight self.weight
} }
}*/ }
impl<'a, I: Copy + PartialEq + GetNodeIndex, W: GetVertexIndex<I> + HasPosition<Scalar = f64>> impl<
visit::IntoNodeReferences for &'a Triangulation<I, W> 'a,
I: Copy + PartialEq + GetNodeIndex,
W: Copy + GetVertexIndex<I> + HasPosition<Scalar = f64>,
> visit::IntoNodeReferences for &'a Triangulation<I, W>
{ {
/*type NodeRef = TriangulationVertexReference<I, W>; type NodeRef = TriangulationVertexReference<'a, I, W>;
type NodeReferences = Box<dyn Iterator<Item = TriangulationVertexReference<I, W>> + 'a>;*/ type NodeReferences = Box<dyn Iterator<Item = TriangulationVertexReference<'a, I, W>> + 'a>;
type NodeRef = (I, &'a W);
type NodeReferences = Box<dyn Iterator<Item = (I, &'a W)> + 'a>;
fn node_references(self) -> Self::NodeReferences { fn node_references(self) -> Self::NodeReferences {
Box::new( Box::new(
spade::Triangulation::fixed_vertices(&self.triangulation).map(|vertex| { spade::Triangulation::fixed_vertices(&self.triangulation).map(|vertex| {
let weight = spade::Triangulation::s(&self.triangulation).vertex_data(vertex); let weight = spade::Triangulation::s(&self.triangulation).vertex_data(vertex);
/*TriangulationVertexReference { TriangulationVertexReference {
index: weight.vertex_index(), index: weight.vertex_index(),
weight, weight,
}*/ }
(weight.vertex_index(), weight)
}), }),
) )
} }