From 4434c65c7a471eeb210db5dd81acd10adace9caa Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Tue, 25 Feb 2020 13:45:41 -0800 Subject: [PATCH] core: Event and EventKey comparison operators --- src/core/model/scheduler.h | 81 +++++++++++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 14 deletions(-) diff --git a/src/core/model/scheduler.h b/src/core/model/scheduler.h index fcf65c7ee..254d5e774 100644 --- a/src/core/model/scheduler.h +++ b/src/core/model/scheduler.h @@ -137,6 +137,34 @@ public: virtual void Remove (const Event &ev) = 0; }; +/** + * \ingroup Events + * Compare (equal) two events by EventKey. + * + * \param [in] a The first event. + * \param [in] b The second event. + * \returns \c true if \c a != \c b + */ +inline bool operator == (const Scheduler::EventKey &a, + const Scheduler::EventKey &b) +{ + return a.m_uid == b.m_uid; +} + +/** + * \ingroup Events + * Compare (not equal) two events by EventKey. + * + * \param [in] a The first event. + * \param [in] b The second event. + * \returns \c true if \c a != \c b + */ +inline bool operator != (const Scheduler::EventKey &a, + const Scheduler::EventKey &b) +{ + return a.m_uid != b.m_uid; +} + /** * \ingroup Events * Compare (less than) two events by EventKey. @@ -168,20 +196,6 @@ inline bool operator < (const Scheduler::EventKey &a, } } -/** - * \ingroup Events - * Compare (not equal) two events by EventKey. - * - * \param [in] a The first event. - * \param [in] b The second event. - * \returns \c true if \c a != \c b - */ -inline bool operator != (const Scheduler::EventKey &a, - const Scheduler::EventKey &b) -{ - return a.m_uid != b.m_uid; -} - /** * Compare (greater than) two events by EventKey. * @@ -207,6 +221,32 @@ inline bool operator > (const Scheduler::EventKey &a, } } +/** + * Compare (equal) two events by Event. + * + * \param [in] a The first event. + * \param [in] b The second event. + * \returns \c true if \c a == \c b + */ +inline bool operator == (const Scheduler::Event &a, + const Scheduler::Event &b) +{ + return a.key == b.key; +} + +/** + * Compare (not equal) two events by Event. + * + * \param [in] a The first event. + * \param [in] b The second event. + * \returns \c true if \c a != \c b + */ +inline bool operator != (const Scheduler::Event &a, + const Scheduler::Event &b) +{ + return a.key != b.key; +} + /** * Compare (less than) two events by Event. * @@ -220,6 +260,19 @@ inline bool operator < (const Scheduler::Event &a, return a.key < b.key; } +/** + * Compare (greater than) two events by Event. + * + * \param [in] a The first event. + * \param [in] b The second event. + * \returns \c true if \c a > \c b + */ +inline bool operator > (const Scheduler::Event &a, + const Scheduler::Event &b) +{ + return a.key > b.key; +} + } // namespace ns3