Renamed len() to capacity() in EntityMap, VertexMap, and EdgeMap

len() is generally expected to describe the number of elements in a collection,
but in this case elements beyond len() are accessible without restriction.
capacity() is a better name because it describes data storage size.
This commit is contained in:
2026-07-10 11:58:45 +02:00
parent dd0399dcdd
commit fb9dfe8280
2 changed files with 15 additions and 15 deletions
+7 -7
View File
@@ -13,9 +13,9 @@ 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()
// Reads beyond capacity() are valid and return the default value.
pub fn capacity(&self) -> usize {
self.inner.capacity()
}
pub fn sync<G: GraphTopology<Vertex = V>>(&mut self, graph: &G) {
@@ -48,9 +48,9 @@ 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()
// Reads beyond capacity() are valid and return the default value.
pub fn capacity(&self) -> usize {
self.inner.capacity()
}
pub fn sync<G: GraphTopology<Edge = E>>(&mut self, graph: &G) {
@@ -87,7 +87,7 @@ impl<E: Copy, T: Clone> EntityMap<E, T> {
}
}
pub fn len(&self) -> usize {
pub fn capacity(&self) -> usize {
self.data.len()
}