Add len() for VertexMap and EdgeMap
This commit is contained in:
+14
@@ -13,6 +13,11 @@ impl<V: Copy, T: Clone> VertexMap<V, T> {
|
||||
}
|
||||
}
|
||||
|
||||
// Reads beyond len() are valid and return the default value.
|
||||
pub fn len(&self) -> usize {
|
||||
self.inner.len()
|
||||
}
|
||||
|
||||
pub fn sync<G: GraphTopology<Vertex = V>>(&mut self, graph: &G) {
|
||||
self.inner.resize(graph.vertex_capacity());
|
||||
}
|
||||
@@ -43,6 +48,11 @@ impl<E: Copy, T: Clone> EdgeMap<E, T> {
|
||||
}
|
||||
}
|
||||
|
||||
// Reads beyond len() are valid and return the default value.
|
||||
pub fn len(&self) -> usize {
|
||||
self.inner.len()
|
||||
}
|
||||
|
||||
pub fn sync<G: GraphTopology<Edge = E>>(&mut self, graph: &G) {
|
||||
self.inner.resize(graph.edge_capacity());
|
||||
}
|
||||
@@ -77,6 +87,10 @@ impl<E: Copy, T: Clone> EntityMap<E, T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn len(&self) -> usize {
|
||||
self.data.len()
|
||||
}
|
||||
|
||||
pub fn resize(&mut self, capacity: usize) {
|
||||
if capacity > self.data.len() {
|
||||
self.data.resize(capacity, self.default.clone());
|
||||
|
||||
Reference in New Issue
Block a user