Replaced std::pair with classes.
Looks like fixed wrong restriction type in CheckForEmanatingIsOnlyTurn (now RestrictionTarget instead if RestrictionSource).
This commit is contained in:
parent
2d9645b9b0
commit
07e13e2499
@ -46,7 +46,7 @@ RestrictionMap::RestrictionMap(const std::shared_ptr<NodeBasedDynamicGraph> &gra
|
||||
m_restriction_start_nodes.insert(restriction.fromNode);
|
||||
m_no_turn_via_node_set.insert(restriction.viaNode);
|
||||
|
||||
std::pair<NodeID, NodeID> restriction_source = {restriction.fromNode, restriction.viaNode};
|
||||
RestrictionSource restriction_source(restriction.fromNode, restriction.viaNode);
|
||||
|
||||
unsigned index;
|
||||
auto restriction_iter = m_restriction_map.find(restriction_source);
|
||||
@ -60,7 +60,7 @@ RestrictionMap::RestrictionMap(const std::shared_ptr<NodeBasedDynamicGraph> &gra
|
||||
{
|
||||
index = restriction_iter->second;
|
||||
// Map already contains an is_only_*-restriction
|
||||
if (m_restriction_bucket_list.at(index).begin()->second)
|
||||
if (m_restriction_bucket_list.at(index).begin()->IsOnly())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -116,9 +116,9 @@ void RestrictionMap::FixupArrivingTurnRestriction(const NodeID node_u,
|
||||
auto &bucket = m_restriction_bucket_list.at(index);
|
||||
for (RestrictionTarget &restriction_target : bucket)
|
||||
{
|
||||
if (node_v == restriction_target.first)
|
||||
if (node_v == restriction_target.TargetNode())
|
||||
{
|
||||
restriction_target.first = node_w;
|
||||
restriction_target.SetTarget(node_w);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -169,11 +169,11 @@ NodeID RestrictionMap::CheckForEmanatingIsOnlyTurn(const NodeID node_u,
|
||||
{
|
||||
const unsigned index = restriction_iter->second;
|
||||
auto &bucket = m_restriction_bucket_list.at(index);
|
||||
for (const RestrictionSource &restriction_target : bucket)
|
||||
for (const RestrictionTarget &restriction_target : bucket)
|
||||
{
|
||||
if (restriction_target.second)
|
||||
if (restriction_target.IsOnly())
|
||||
{
|
||||
return restriction_target.first;
|
||||
return restriction_target.TargetNode();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -203,8 +203,9 @@ bool RestrictionMap::CheckIfTurnIsRestricted(const NodeID node_u,
|
||||
const auto &bucket = m_restriction_bucket_list.at(index);
|
||||
for (const RestrictionTarget &restriction_target : bucket)
|
||||
{
|
||||
if ((node_w == restriction_target.first) && // target found
|
||||
(!restriction_target.second)) // and not an only_-restr.
|
||||
if ((node_w == restriction_target.TargetNode()) && // target found
|
||||
(!restriction_target.IsOnly()) // and not an only_-restr.
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -40,36 +40,36 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <unordered_set>
|
||||
|
||||
|
||||
struct RestrictionSource//: public std::pair<NodeID, NodeID>
|
||||
struct RestrictionSource
|
||||
{
|
||||
NodeID start;
|
||||
NodeID via;
|
||||
NodeID start_node;
|
||||
NodeID via_node;
|
||||
|
||||
RestrictionSource(NodeID _start, NodeID _via)//:std::pair<NodeID, NodeID>(from, via) {}
|
||||
: start(_start), via(_via) {}
|
||||
inline NodeID StartNode() const { return start; }
|
||||
inline NodeID ViaNode() const { return via; }
|
||||
RestrictionSource(NodeID start, NodeID via)
|
||||
: start_node(start), via_node(via) {}
|
||||
inline NodeID StartNode() const { return start_node; }
|
||||
inline NodeID ViaNode() const { return via_node; }
|
||||
|
||||
friend inline bool operator==(const RestrictionSource& lhs, const RestrictionSource& rhs)
|
||||
{
|
||||
return (lhs.start == rhs.start && lhs.via == rhs.via);
|
||||
return (lhs.start_node == rhs.start_node && lhs.via_node == rhs.via_node);
|
||||
}
|
||||
};
|
||||
|
||||
struct RestrictionTarget//: public std::pair<NodeID, bool>
|
||||
struct RestrictionTarget
|
||||
{
|
||||
NodeID target;
|
||||
NodeID target_node;
|
||||
bool is_only;
|
||||
|
||||
RestrictionTarget(NodeID _target, bool _only)//:std::pair<NodeID, bool>(to, _only) {}
|
||||
: target(_target), is_only(_only) {}
|
||||
inline NodeID TargetNode() const { return target; }
|
||||
RestrictionTarget(NodeID target, bool only)
|
||||
: target_node(target), is_only(only) {}
|
||||
inline NodeID TargetNode() const { return target_node; }
|
||||
inline NodeID IsOnly() const { return is_only; } //!< an only_-restriction
|
||||
inline void SetTarget(NodeID _target) { target = _target; } //!< an only_-restriction
|
||||
inline void SetTarget(NodeID target) { target_node = target; } //!< an only_-restriction
|
||||
|
||||
friend inline bool operator==(const RestrictionTarget& lhs, const RestrictionTarget& rhs)
|
||||
{
|
||||
return (lhs.target == rhs.target && lhs.is_only == rhs.is_only);
|
||||
return (lhs.target_node == rhs.target_node && lhs.is_only == rhs.is_only);
|
||||
}
|
||||
};
|
||||
|
||||
@ -111,8 +111,6 @@ class RestrictionMap
|
||||
|
||||
private:
|
||||
bool IsSourceNode(const NodeID node) const;
|
||||
typedef std::pair<NodeID, NodeID> RestrictionSource;
|
||||
typedef std::pair<NodeID, bool> RestrictionTarget;
|
||||
typedef std::vector<RestrictionTarget> EmanatingRestrictionsVector;
|
||||
typedef NodeBasedDynamicGraph::EdgeData EdgeData;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user