Remove pub from structs and fields that should have been private
Graph fields can now be private because of the new iterators Graph::vertices() and Graph::neighbors(). Without them there was no way to access vertices and incidences without the public Graph fields.
This commit is contained in:
+6
-10
@@ -2,15 +2,12 @@
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
pub struct Vertex(pub usize);
|
||||
|
||||
// TODO: Incidence value must not be public.
|
||||
// TODO: Incidence must not be public.
|
||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||
pub struct Incidence(pub usize);
|
||||
struct Incidence(usize);
|
||||
|
||||
// TODO: VertexIncidenceHeader and its fields must not be public, but without iterators there is currently no other way to access vertex incidences.
|
||||
pub struct VertexIncidenceHeader {
|
||||
struct VertexIncidenceHeader {
|
||||
incidence_count: usize,
|
||||
pub first_incidence: Option<Incidence>,
|
||||
first_incidence: Option<Incidence>,
|
||||
}
|
||||
|
||||
pub struct VertexNeighborIterator<'a> {
|
||||
@@ -28,7 +25,6 @@ impl<'a> Iterator for VertexNeighborIterator<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Graph fields must not be public.
|
||||
// TODO: Add functions to reserve memory for vertices and edges.
|
||||
// TODO: Graph cannot support deleting vertices because of the external indices "Vertex". They could be made stable with e.g. slotmap or generational arena.
|
||||
// TODO: Add function to delete vertices.
|
||||
@@ -36,9 +32,9 @@ impl<'a> Iterator for VertexNeighborIterator<'a> {
|
||||
// TODO: Add iterator of edges.
|
||||
pub struct Graph {
|
||||
// TODO: Index 'incidence_headers' by a 'Vertex' instead of 'Vertex.0'?
|
||||
pub incidence_headers: Vec<VertexIncidenceHeader>,
|
||||
pub next_incidences: Vec<Option<Incidence>>,
|
||||
pub incidence_vertices: Vec<Vertex>,
|
||||
incidence_headers: Vec<VertexIncidenceHeader>,
|
||||
next_incidences: Vec<Option<Incidence>>,
|
||||
incidence_vertices: Vec<Vertex>,
|
||||
}
|
||||
|
||||
impl Graph {
|
||||
|
||||
Reference in New Issue
Block a user