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:
+7
-7
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user