diff --git a/graph.h b/graph.h index d62c497..dce3dfa 100644 --- a/graph.h +++ b/graph.h @@ -66,21 +66,21 @@ public: std::vector edges() const; // iterators - class iterator : public std::iterator { public: - typedef iterator self_type; - typedef iterator& reference_self_type; - typedef const iterator& const_reference_self_type; - - iterator() : m_it() {} - iterator(typename std::vector::iterator it) : m_it(it) {} - ~iterator() {} - iterator(const_reference_self_type o) : m_it(o.m_it) {} + typedef vertex_iterator self_type; + typedef vertex_iterator& reference_self_type; + typedef const vertex_iterator& const_reference_self_type; + + vertex_iterator() : m_it() {} + vertex_iterator(typename std::vector::iterator it) : m_it(it) {} + ~vertex_iterator() {} + vertex_iterator(const_reference_self_type o) : m_it(o.m_it) {} reference_self_type operator=(const_reference_self_type o) { if (this != &o) { m_it = o.m_it; } return *this; } @@ -98,8 +98,8 @@ public: typename std::vector::iterator m_it; }; - iterator begin() { return iterator(m_vertices.begin()); } - iterator end() { return iterator(m_vertices.begin()); } + vertex_iterator begin() { return vertex_iterator(m_vertices.begin()); } + vertex_iterator end() { return vertex_iterator(m_vertices.begin()); } private: diff --git a/main.cpp b/main.cpp index 0e74bfe..e459cb7 100644 --- a/main.cpp +++ b/main.cpp @@ -61,7 +61,7 @@ int main() g.addVertex(c); int vertices_array[] = {2, 5, 13, 1}; std::vector v(vertices_array, vertices_array + sizeof(vertices_array) / sizeof(int) ); - Graph::iterator g_it; + Graph::vertex_iterator g_it; std::vector::iterator v_it; for (g_it = g.begin(), v_it = v.begin(); g_it != g.end();