Brian Silverman | f7bd1c2 | 2015-12-24 16:07:11 -0800 | [diff] [blame^] | 1 | /*----------------------------------------------------------------------------*/ |
| 2 | /* Copyright (c) FIRST 2015. All Rights Reserved. */ |
| 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */ |
| 4 | /* must be accompanied by the FIRST BSD license file in the root directory of */ |
| 5 | /* the project. */ |
| 6 | /*----------------------------------------------------------------------------*/ |
| 7 | |
| 8 | #include "SequenceNumber.h" |
| 9 | |
| 10 | namespace nt { |
| 11 | |
| 12 | bool operator<(const SequenceNumber& lhs, const SequenceNumber& rhs) { |
| 13 | if (lhs.m_value < rhs.m_value) |
| 14 | return (rhs.m_value - lhs.m_value) < (1u << 15); |
| 15 | else if (lhs.m_value > rhs.m_value) |
| 16 | return (lhs.m_value - rhs.m_value) > (1u << 15); |
| 17 | else |
| 18 | return false; |
| 19 | } |
| 20 | |
| 21 | bool operator>(const SequenceNumber& lhs, const SequenceNumber& rhs) { |
| 22 | if (lhs.m_value < rhs.m_value) |
| 23 | return (rhs.m_value - lhs.m_value) > (1u << 15); |
| 24 | else if (lhs.m_value > rhs.m_value) |
| 25 | return (lhs.m_value - rhs.m_value) < (1u << 15); |
| 26 | else |
| 27 | return false; |
| 28 | } |
| 29 | |
| 30 | } // namespace nt |