wifi: Use std::set instead of std::list in QosBlockedDestinations
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#ifndef QOS_BLOCKED_DESTINATIONS_H
|
||||
#define QOS_BLOCKED_DESTINATIONS_H
|
||||
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include "ns3/mac48-address.h"
|
||||
|
||||
namespace ns3 {
|
||||
@@ -67,19 +67,7 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
/**
|
||||
* typedef for a list of <Mac48Address, TID> pair.
|
||||
*/
|
||||
typedef std::list<std::pair<Mac48Address, uint8_t> > BlockedPackets;
|
||||
/**
|
||||
* typedef for an iterator of BlockedPackets
|
||||
*/
|
||||
typedef std::list<std::pair<Mac48Address, uint8_t> >::iterator BlockedPacketsI;
|
||||
/**
|
||||
* typedef for a constan iterator of BlockedPackets
|
||||
*/
|
||||
typedef std::list<std::pair<Mac48Address, uint8_t> >::const_iterator BlockedPacketsCI;
|
||||
BlockedPackets m_blockedQosPackets;
|
||||
std::set<std::pair<Mac48Address, uint8_t>> m_blockedQosPackets;
|
||||
};
|
||||
|
||||
} //namespace ns3
|
||||
|
||||
Reference in New Issue
Block a user