Merge branch 'main' into release-0.3.0
This commit is contained in:
+6
-6
@@ -12,9 +12,9 @@ use std::ops::{Index, IndexMut};
|
||||
/// which means that the provided index conversion function should map entities to contiguous
|
||||
/// indices, or indices with relatively few gaps.
|
||||
///
|
||||
/// Data allocation happens as copy-on-write, i.e. the backing [`Vec`] is only resized if a value
|
||||
/// beyond current capacity is written, but the `default` value can transparently be read. No bound
|
||||
/// or validity checks are performed by the map on the provided entities.
|
||||
/// Data allocation happens as copy-on-write, i.e. the backing [`Vec`] is only resized if a value is
|
||||
/// written beyond current capacity, but the `default` value can transparently be read. No bound or
|
||||
/// validity checks are performed by the map on the provided entity handles.
|
||||
///
|
||||
/// Use [`GraphTopology::vertex_map`] or [`GraphTopology::edge_map`] to obtain an `EntityMap` for
|
||||
/// vertices or edges, respectively.
|
||||
@@ -41,12 +41,12 @@ impl<E: Copy, T: Clone> EntityMap<E, T> {
|
||||
self.data.capacity()
|
||||
}
|
||||
|
||||
/// Extends the internal data storage of the map to `capacity`, pre-filling any new slots with
|
||||
/// the default value.
|
||||
/// Expands the internal data storage capacity of the map to `capacity`, Does nothing if
|
||||
/// capacity is already sufficient.
|
||||
///
|
||||
/// Use this before writing data for new graph entities to avoid incremental growth on the first
|
||||
/// write to each new entity.
|
||||
pub fn extend(&mut self, capacity: usize) {
|
||||
pub fn expand(&mut self, capacity: usize) {
|
||||
if capacity > self.data.len() {
|
||||
self.data.resize(capacity, self.default.clone());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user