1
0
Fork 0

comparison operators that makes sense

This commit is contained in:
Kevin Matz 2021-09-11 10:01:18 -04:00
parent 8e50d9292d
commit 04eb87ed82
1 changed files with 19 additions and 8 deletions

View File

@ -90,30 +90,41 @@ bool operator== (const data_header& a, const data_header& b)
/**
* @brief For matching universe numbers, lower priorities are lesser.
* @brief operator <
* @param a
* @param b
* @return
*/
bool operator< (const data_header& a, const data_header& b)
{
return (a.source_name == b.source_name &&
a.universe == b.universe &&
a.priority < b.priority);
if (a == b)
return false;
if (a.universe != b.universe)
return a.universe < b.universe;
if (a.priority != b.priority)
return a.priority < b.priority;
if (a.source_name != b.source_name)
return a.source_name < b.source_name;
return false;
}
/**
* @brief For matching universe numbers, higher priorities are greater.
* @brief operator >
* @param a
* @param b
* @return
*/
bool operator> (const data_header& a, const data_header& b)
{
return (a.source_name == b.source_name &&
a.universe == b.universe &&
a.priority > b.priority);
if (a == b)
return false;
return !(a < b);
}