Move comparators to struct

This commit is contained in:
Patrick Niklaus 2015-07-15 21:37:55 +02:00
parent 35542e5823
commit d4356b0453

View File

@ -141,6 +141,16 @@ void Prepare::FindComponents(unsigned max_edge_id, const DeallocatingVector<Edge
unsigned source;
unsigned target;
UncontractedEdgeData data;
bool operator<(const InputEdge& rhs) const
{
return source < rhs.source || (source == rhs.source && target < rhs.target);
}
bool operator==(const InputEdge& rhs) const
{
return source == rhs.source && target == rhs.target;
}
};
using UncontractedGraph = StaticGraph<UncontractedEdgeData>;
std::vector<InputEdge> edges;
@ -171,16 +181,8 @@ void Prepare::FindComponents(unsigned max_edge_id, const DeallocatingVector<Edge
}
}
tbb::parallel_sort(edges.begin(), edges.end(),
[](const InputEdge& lhs, const InputEdge& rhs)
{
return lhs.source < rhs.source || (lhs.source == rhs.source && lhs.target < rhs.target);
});
auto new_end = std::unique(edges.begin(), edges.end(),
[](const InputEdge& lhs, const InputEdge& rhs)
{
return lhs.source == rhs.source && lhs.target == rhs.target;
});
tbb::parallel_sort(edges.begin(), edges.end());
auto new_end = std::unique(edges.begin(), edges.end());
edges.resize(new_end - edges.begin());
auto uncontractor_graph = std::make_shared<UncontractedGraph>(max_edge_id+1, edges);