From 687c9cc1a70bdc6d86c32a22ff368d2d620c7716 Mon Sep 17 00:00:00 2001 From: dmatetelki Date: Thu, 15 May 2014 16:19:05 +0200 Subject: [PATCH] refactoring (*it).member to it->member --- lib/graph/graph.hpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/graph/graph.hpp b/lib/graph/graph.hpp index 6427c51..9258d58 100644 --- a/lib/graph/graph.hpp +++ b/lib/graph/graph.hpp @@ -143,8 +143,8 @@ public: reference_self_type operator=(self_type o) { swap(o); return *this; } void swap(reference_self_type o) { std::swap(m_it, o.m_it); } - const_reference operator*() { return (*m_it).m_data; } - const_pointer operator->() { return &(*m_it).m_data; } + const_reference operator*() { return m_it->m_data; } + const_pointer operator->() { return &m_it->m_data; } self_type &operator++() { ++m_it; return *this; } self_type operator++(int) { self_type tmp(*this); ++(*this); return tmp; } self_type operator+(difference_type n) { self_type tmp(*this); tmp.pos_ += n; return tmp; } @@ -284,7 +284,7 @@ inline Graph::edge_iterator::edge_iterator(v_container vertices, bool begi ++m_vertex_it; if (m_vertex_it != m_vertices.end()) - m_edge_it = (*m_vertex_it).m_edges.begin(); + m_edge_it = m_vertex_it->m_edges.begin(); } else { m_vertex_it = m_vertices.end(); } @@ -296,7 +296,7 @@ inline void Graph::edge_iterator::resetEdge() if (m_vertex_it == m_vertices.end() || (*m_vertex_it).m_edges.empty()) { m_edge = Edge(); } else { - m_edge = Edge( m_vertex_it->m_data, (m_edge_it->m_destination)->m_data, (*m_edge_it).m_weight); + m_edge = Edge( m_vertex_it->m_data, (m_edge_it->m_destination)->m_data, m_edge_it->m_weight); } } @@ -304,7 +304,7 @@ template void Graph::edge_iterator::advance(int n) { while (n > 0 && m_vertex_it != m_vertices.end()) { - const int edgesAhead = std::distance(m_edge_it, (*m_vertex_it).m_edges.end()) - 1; + const int edgesAhead = std::distance(m_edge_it, m_vertex_it->m_edges.end()) - 1; if (n <= edgesAhead) { std::advance(m_edge_it, n); return; @@ -314,8 +314,8 @@ void Graph::edge_iterator::advance(int n) ++m_vertex_it; if (m_vertex_it != m_vertices.end()) { - m_edge_it = (*m_vertex_it).m_edges.begin(); - if (m_edge_it != (*m_vertex_it).m_edges.end()) + m_edge_it = m_vertex_it->m_edges.begin(); + if (m_edge_it != m_vertex_it->m_edges.end()) --n; } } @@ -438,9 +438,9 @@ bool Graph::addEdge(const_reference source, const_reference destination, c if (destination_it == m_vertices.end()) return false; - (*source_it).addEdge( v_iterator(destination_it), weight); + source_it->addEdge( v_iterator(destination_it), weight); if (!m_directed) - (*destination_it).addEdge( v_iterator(source_it), weight); + destination_it->addEdge( v_iterator(source_it), weight); return true; } @@ -456,9 +456,9 @@ inline bool Graph::removeEdge(const_reference source, const_reference dest if (destination_it == m_vertices.end()) return false; - (*source_it).removeEdge(destination, weight); + source_it->removeEdge(destination, weight); if (!m_directed) - (*destination_it).removeEdge(source, weight); + destination_it->removeEdge(source, weight); return true; } @@ -474,9 +474,9 @@ inline bool Graph::removeAllEdges(const_reference source, const_reference if (destination_it == m_vertices.end()) return false; - (*source_it).removeAllEdgesTo(destination_it); + source_it->removeAllEdgesTo(destination_it); if (!m_directed) - (*destination_it).removeAllEdgesTo(source_it); + destination_it->removeAllEdgesTo(source_it); return true; } @@ -502,7 +502,7 @@ std::vector::value_type> Graph::neighboursOf(const_re std::set tmp; /// @todo rewrite for_each to parallel aware - std::for_each((*vertex_it).m_edges.begin(), (*vertex_it).m_edges.end(), + std::for_each(vertex_it->m_edges.begin(), vertex_it->m_edges.end(), [&tmp, &retval](const EdgeTo& e) { if (tmp.insert(e.m_destination).second) retval.push_back((e.m_destination)->m_data); }); @@ -519,9 +519,9 @@ std::vector Graph::weightsBetween(const_reference source, const_referen return retval; /// @todo rewrite for_each to parallel aware - std::for_each((*vertex_it).m_edges.begin(), (*vertex_it).m_edges.end(), + std::for_each(vertex_it->m_edges.begin(), vertex_it->m_edges.end(), [&retval, &destination](const EdgeTo& e) - { if ((*(e.m_destination)).m_data == destination) + { if (e.m_destination->m_data == destination) retval.push_back(e.m_weight); }); return retval;