diff --git a/graph.hpp b/graph.hpp index d759851..fd94b2f 100644 --- a/graph.hpp +++ b/graph.hpp @@ -77,8 +77,8 @@ public: // Lookup bool contains(const_reference data) const { return find(data) != m_vertices.end(); } - std::vector vertices() const; - std::vector neighboursOf(const_reference data) const; + std::vector vertices() const; + std::vector neighboursOf(const_reference data) const; /// @todo come up with a more clear name std::vector edgesBetween(const_reference source, const_reference destination) const; @@ -441,9 +441,9 @@ inline bool Graph::removeVertex(const_reference data) if (it == m_vertices.end()) return false; - std::vector neighbours = neighboursOf(data); + std::vector neighbours = neighboursOf(data); std::for_each(neighbours.begin(), neighbours.end(), - [this, &data] (pointer vertex) + [this, &data] (const_pointer vertex) { this->removeAllEdges(*vertex, data); } ); m_vertices.erase(it); @@ -505,9 +505,9 @@ inline bool Graph::removeAllEdges(const_reference source, const_ref } template -inline std::vector::pointer> Graph::vertices() const +inline std::vector::const_pointer> Graph::vertices() const { - std::vector retval; + std::vector retval; std::for_each(m_vertices.begin(), m_vertices.end(), [&retval](const Vertex& v) { retval.push_back(v.m_data); }); @@ -515,9 +515,9 @@ inline std::vector::pointer> Graph::ver } template -std::vector::pointer> Graph::neighboursOf(const_reference data) const +std::vector::const_pointer> Graph::neighboursOf(const_reference data) const { - typename std::vector retval; + typename std::vector retval; typename std::vector::const_iterator vertex_it = find(data); if (vertex_it == m_vertices.end()) return retval; diff --git a/main.cpp b/main.cpp index 6192a81..a9d2234 100644 --- a/main.cpp +++ b/main.cpp @@ -23,7 +23,7 @@ int main() assert(g.empty() == false); assert(g.numberOfVertices() == 1); { - const std::vector v = g.vertices(); + const std::vector v = g.vertices(); assert(v.size() == 1); assert(*(v[0]) == 2); } @@ -33,7 +33,7 @@ int main() assert(g.addVertex(b) == true); assert(g.numberOfVertices() == 2); { - const std::vector v = g.vertices(); + const std::vector v = g.vertices(); assert(v.size() == 2); assert(*(v[0]) == 2); assert(*(v[1]) == 5); @@ -51,7 +51,7 @@ int main() assert(g.edgesBetween(5, 2).size() == 0); assert(g.neighboursOf(2).size() == 1); { - const std::vector n = g.neighboursOf(2); + const std::vector n = g.neighboursOf(2); assert(n.size() == 1); assert(*(n[0]) == 5); }