renaming private class Edge to EdgeTo

for/release
Denes Matetelki 12 years ago
parent 1c0001948f
commit 7b06654bc9

@ -24,11 +24,11 @@ public:
private: private:
struct Edge { struct EdgeTo {
Edge(const_reference destination, float weight = 0); EdgeTo(const_reference destination, float weight = 0);
Edge(const Edge& other); EdgeTo(const EdgeTo& other);
Edge& operator=(const Edge& other); EdgeTo& operator=(const EdgeTo& other);
pointer m_destination; pointer m_destination;
float m_weight; float m_weight;
@ -44,7 +44,7 @@ private:
void removeAllEdgesTo(const_reference destination); void removeAllEdgesTo(const_reference destination);
pointer m_data; pointer m_data;
std::list<Edge> m_edges; std::list<EdgeTo> m_edges;
}; };
@ -124,7 +124,7 @@ public:
// Edge // Edge
template <typename T> template <typename T>
Graph<T>::Edge::Edge(const_reference destination, float weight) Graph<T>::EdgeTo::EdgeTo(const_reference destination, float weight)
: m_destination(const_cast<pointer>(&destination)) : m_destination(const_cast<pointer>(&destination))
, m_weight(weight) , m_weight(weight)
{ {
@ -132,7 +132,7 @@ Graph<T>::Edge::Edge(const_reference destination, float weight)
} }
template <typename T> template <typename T>
Graph<T>::Edge::Edge(const Edge& other) Graph<T>::EdgeTo::EdgeTo(const EdgeTo& other)
: m_destination(other.m_destination) : m_destination(other.m_destination)
, m_weight(other.m_weight) , m_weight(other.m_weight)
{ {
@ -140,7 +140,7 @@ Graph<T>::Edge::Edge(const Edge& other)
} }
template <typename T> template <typename T>
typename Graph<T>::Edge& Graph<T>::Edge::operator=(const Edge& other) typename Graph<T>::EdgeTo& Graph<T>::EdgeTo::operator=(const EdgeTo& other)
{ {
if (this != &other) { if (this != &other) {
m_destination = other.m_destination; m_destination = other.m_destination;
@ -184,7 +184,7 @@ typename Graph<T>::Vertex& Graph<T>::Vertex::operator=(const Vertex& other)
template <typename T> template <typename T>
void Graph<T>::Vertex::addEdge(const_reference destination, float weight) void Graph<T>::Vertex::addEdge(const_reference destination, float weight)
{ {
Edge e(destination, weight); EdgeTo e(destination, weight);
m_edges.push_back(e); m_edges.push_back(e);
} }
@ -192,7 +192,7 @@ template <typename T>
void Graph<T>::Vertex::removeEdge(const_reference destination, float weight) void Graph<T>::Vertex::removeEdge(const_reference destination, float weight)
{ {
m_edges.erase(std::find_if(m_edges.begin(), m_edges.end(), m_edges.erase(std::find_if(m_edges.begin(), m_edges.end(),
[&destination, &weight](const Edge& e) [&destination, &weight](const EdgeTo& e)
{ return e.m_destination == destination && { return e.m_destination == destination &&
e.m_weight == weight;})); e.m_weight == weight;}));
} }
@ -201,7 +201,7 @@ template <typename T>
void Graph<T>::Vertex::removeAllEdgesTo(const_reference destination) void Graph<T>::Vertex::removeAllEdgesTo(const_reference destination)
{ {
std::remove_if(m_edges.begin(), m_edges.end(), std::remove_if(m_edges.begin(), m_edges.end(),
[&destination](const Edge& e) [&destination](const EdgeTo& e)
{ return e.m_destination == destination; }); { return e.m_destination == destination; });
} }
@ -319,7 +319,7 @@ std::vector<typename Graph<T>::pointer> Graph<T>::neighboursOf(const_reference d
return retval; return retval;
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](const Edge& e) [&retval](const EdgeTo& e)
{ retval.push_back(e.m_destination); }); { retval.push_back(e.m_destination); });
return retval; return retval;
@ -334,7 +334,7 @@ std::vector<float> Graph<T>::edgesBetween(const_reference source, const_referenc
return retval; return retval;
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 Edge& e) [&retval, &destination](const EdgeTo& e)
{ if (*(e.m_destination) == destination) { if (*(e.m_destination) == destination)
retval.push_back(e.m_weight); }); retval.push_back(e.m_weight); });

Loading…
Cancel
Save