Using unordered_set where it suffices

This commit is contained in:
DennisOSRM 2013-02-03 13:19:23 +01:00
parent 78c92be14b
commit 59ca59d431
2 changed files with 7 additions and 12 deletions

View File

@ -44,18 +44,12 @@ EdgeBasedGraphFactory::EdgeBasedGraphFactory(int nodes, std::vector<NodeBasedEdg
_restrictionBucketVector.at(index).push_back(std::make_pair(restriction.toNode, restriction.flags.isOnly)); _restrictionBucketVector.at(index).push_back(std::make_pair(restriction.toNode, restriction.flags.isOnly));
} }
BOOST_FOREACH(NodeID id, bn) { _barrierNodes.insert(bn.begin(), bn.end());
_barrierNodes[id] = true; _trafficLights.insert(tl.begin(), tl.end());
}
BOOST_FOREACH(NodeID id, tl) {
_trafficLights[id] = true;
}
DeallocatingVector< _NodeBasedEdge > edges; DeallocatingVector< _NodeBasedEdge > edges;
// edges.reserve( 2 * inputEdges.size() ); _NodeBasedEdge edge;
for ( std::vector< NodeBasedEdge >::const_iterator i = inputEdges.begin(); i != inputEdges.end(); ++i ) { for ( std::vector< NodeBasedEdge >::const_iterator i = inputEdges.begin(); i != inputEdges.end(); ++i ) {
_NodeBasedEdge edge;
if(!i->isForward()) { if(!i->isForward()) {
edge.source = i->target(); edge.source = i->target();
edge.target = i->source(); edge.target = i->source();

View File

@ -35,7 +35,8 @@
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/unordered_map.hpp>
#include <boost/unordered_set.hpp>
#include "../typedefs.h" #include "../typedefs.h"
#include "../DataStructures/DeallocatingVector.h" #include "../DataStructures/DeallocatingVector.h"
@ -103,8 +104,8 @@ public:
} speedProfile; } speedProfile;
private: private:
boost::shared_ptr<_NodeBasedDynamicGraph> _nodeBasedGraph; boost::shared_ptr<_NodeBasedDynamicGraph> _nodeBasedGraph;
boost::unordered_map<NodeID, bool> _barrierNodes; boost::unordered_set<NodeID> _barrierNodes;
boost::unordered_map<NodeID, bool> _trafficLights; boost::unordered_set<NodeID> _trafficLights;
typedef std::pair<NodeID, NodeID> RestrictionSource; typedef std::pair<NodeID, NodeID> RestrictionSource;
typedef std::pair<NodeID, bool> RestrictionTarget; typedef std::pair<NodeID, bool> RestrictionTarget;