Joint set iteration: also yield the joint handle.

This commit is contained in:
Crozet Sébastien
2020-10-05 16:51:16 +02:00
parent 9c22e59416
commit d8dfd864a4
2 changed files with 11 additions and 7 deletions

View File

@@ -66,17 +66,21 @@ impl JointSet {
}
/// Iterates through all the joint on this set.
pub fn iter(&self) -> impl Iterator<Item = &Joint> {
self.joint_graph.graph.edges.iter().map(|e| &e.weight)
pub fn iter(&self) -> impl Iterator<Item = (JointHandle, &Joint)> {
self.joint_graph
.graph
.edges
.iter()
.map(|e| (e.weight.handle, &e.weight))
}
/// Iterates mutably through all the joint on this set.
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut Joint> {
pub fn iter_mut(&mut self) -> impl Iterator<Item = (JointHandle, &mut Joint)> {
self.joint_graph
.graph
.edges
.iter_mut()
.map(|e| &mut e.weight)
.map(|e| (e.weight.handle, &mut e.weight))
}
// /// The set of joints as an array.