From d4e272d77534f79d6c9acfc740ab58c70ca24e4c Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Fri, 9 Dec 2016 10:37:39 +0300 Subject: [PATCH] wifi: Use std::set instead of std::list in QosBlockedDestinations --- src/wifi/model/qos-blocked-destinations.cc | 23 +++------------------- src/wifi/model/qos-blocked-destinations.h | 16 ++------------- 2 files changed, 5 insertions(+), 34 deletions(-) diff --git a/src/wifi/model/qos-blocked-destinations.cc b/src/wifi/model/qos-blocked-destinations.cc index 464fd0bba..d4c63ffe2 100644 --- a/src/wifi/model/qos-blocked-destinations.cc +++ b/src/wifi/model/qos-blocked-destinations.cc @@ -34,36 +34,19 @@ QosBlockedDestinations::~QosBlockedDestinations () bool QosBlockedDestinations::IsBlocked (Mac48Address dest, uint8_t tid) const { - for (BlockedPacketsCI i = m_blockedQosPackets.begin (); i != m_blockedQosPackets.end (); i++) - { - if (i->first == dest && i->second == tid) - { - return true; - } - } - return false; + return m_blockedQosPackets.find ({dest, tid}) != m_blockedQosPackets.end (); } void QosBlockedDestinations::Block (Mac48Address dest, uint8_t tid) { - if (!IsBlocked (dest, tid)) - { - m_blockedQosPackets.push_back (std::make_pair (dest, tid)); - } + m_blockedQosPackets.insert ({dest, tid}); } void QosBlockedDestinations::Unblock (Mac48Address dest, uint8_t tid) { - for (BlockedPacketsI i = m_blockedQosPackets.begin (); i != m_blockedQosPackets.end (); i++) - { - if (i->first == dest && i->second == tid) - { - m_blockedQosPackets.erase (i); - break; - } - } + m_blockedQosPackets.erase ({dest, tid}); } } //namespace ns3 diff --git a/src/wifi/model/qos-blocked-destinations.h b/src/wifi/model/qos-blocked-destinations.h index 840009ef0..05b6c6aee 100644 --- a/src/wifi/model/qos-blocked-destinations.h +++ b/src/wifi/model/qos-blocked-destinations.h @@ -22,7 +22,7 @@ #ifndef QOS_BLOCKED_DESTINATIONS_H #define QOS_BLOCKED_DESTINATIONS_H -#include +#include #include "ns3/mac48-address.h" namespace ns3 { @@ -67,19 +67,7 @@ public: private: - /** - * typedef for a list of pair. - */ - typedef std::list > BlockedPackets; - /** - * typedef for an iterator of BlockedPackets - */ - typedef std::list >::iterator BlockedPacketsI; - /** - * typedef for a constan iterator of BlockedPackets - */ - typedef std::list >::const_iterator BlockedPacketsCI; - BlockedPackets m_blockedQosPackets; + std::set> m_blockedQosPackets; }; } //namespace ns3