use std::tie() to simplify lexicographic comparisons

This commit is contained in:
Dennis Luxen 2015-02-19 19:15:16 +01:00
parent 9b1f108051
commit dc08c516bf
2 changed files with 10 additions and 16 deletions

View File

@ -67,13 +67,9 @@ template <typename EdgeDataT> class DynamicGraph
{ {
} }
bool operator<(const InputEdge &right) const bool operator<(const InputEdge &rhs) const
{ {
if (source != right.source) return std::tie(source, target) < std::tie(rhs.source, rhs.target);
{
return source < right.source;
}
return target < right.target;
} }
}; };

View File

@ -1,6 +1,6 @@
/* /*
Copyright (c) 2014, Project OSRM contributors Copyright (c) 2015, Project OSRM contributors
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, Redistribution and use in source and binary forms, with or without modification,
@ -25,11 +25,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef QUERYEDGE_HPP_ #ifndef QUERYEDGE_HPP
#define QUERYEDGE_HPP_ #define QUERYEDGE_HPP
#include "../typedefs.h" #include "../typedefs.h"
#include <tuple>
struct QueryEdge struct QueryEdge
{ {
NodeID source; NodeID source;
@ -60,13 +62,9 @@ struct QueryEdge
{ {
} }
bool operator<(const QueryEdge &right) const bool operator<(const QueryEdge &rhs) const
{ {
if (source != right.source) return std::tie(source, target) < std::tie(rhs.source, rhs.target);
{
return source < right.source;
}
return target < right.target;
} }
bool operator==(const QueryEdge &right) const bool operator==(const QueryEdge &right) const
@ -78,4 +76,4 @@ struct QueryEdge
} }
}; };
#endif /* QUERYEDGE_HPP_ */ #endif // QUERYEDGE_HPP