Add reserve_vertices and reserve_edges to GraphTopologyAddition
This commit is contained in:
+14
-1
@@ -174,7 +174,6 @@ pub trait GraphTopology {
|
||||
fn incidence_cursor(&self, v: Self::Vertex) -> Self::IncidenceCursor;
|
||||
}
|
||||
|
||||
// TODO: Add functions to reserve memory for vertices and edges.
|
||||
/// A trait that adds construction operations to an undirected graph topology.
|
||||
///
|
||||
/// This trait provides methods for addition of vertices and edges, and capacity management in an
|
||||
@@ -186,6 +185,20 @@ pub trait GraphTopologyAddition: GraphTopology {
|
||||
/// Returns the total number of edges the graph can hold without reallocating.
|
||||
fn edge_capacity(&self) -> usize;
|
||||
|
||||
/// Reserves capacity for at least `additional` more vertices. Does nothing if capacity is
|
||||
/// already sufficient.
|
||||
///
|
||||
/// Use this before adding multiple vertices to avoid incremental growth on each call to
|
||||
/// [`add_vertex`].
|
||||
fn reserve_vertices(&mut self, additional: usize);
|
||||
|
||||
/// Reserves capacity for at least `additional` more edges. Does nothing if capacity is already
|
||||
/// sufficient.
|
||||
///
|
||||
/// Use this before adding multiple edges to avoid incremental growth on each call to
|
||||
/// [`add_edge`].
|
||||
fn reserve_edges(&mut self, additional: usize);
|
||||
|
||||
/// Adds a new isolated vertex and returns its handle.
|
||||
fn add_vertex(&mut self) -> Self::Vertex;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user