use std::tie() to simplify lexicographic comparisons
This commit is contained in:
parent
9b1f108051
commit
dc08c516bf
@ -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;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user