src/simulator/list-scheduler.cc
changeset 6180 cd0d8ba00e6c
parent 4054 d1df606b20f8
equal deleted inserted replaced
6179:96433e14757b 6180:cd0d8ba00e6c
    27 namespace ns3 {
    27 namespace ns3 {
    28 
    28 
    29 
    29 
    30 NS_OBJECT_ENSURE_REGISTERED (ListScheduler);
    30 NS_OBJECT_ENSURE_REGISTERED (ListScheduler);
    31 
    31 
    32 TypeId 
    32 TypeId
    33 ListScheduler::GetTypeId (void)
    33 ListScheduler::GetTypeId (void)
    34 {
    34 {
    35   static TypeId tid = TypeId ("ns3::ListScheduler")
    35   static TypeId tid = TypeId ("ns3::ListScheduler")
    36     .SetParent<Scheduler> ()
    36     .SetParent<Scheduler> ()
    37     .AddConstructor<ListScheduler> ()
    37     .AddConstructor<ListScheduler> ()
    38     ;
    38   ;
    39   return tid;
    39   return tid;
    40 }
    40 }
    41 
    41 
    42 ListScheduler::ListScheduler ()
    42 ListScheduler::ListScheduler ()
    43 {}
    43 {
       
    44 }
    44 ListScheduler::~ListScheduler ()
    45 ListScheduler::~ListScheduler ()
    45 {}
    46 {
       
    47 }
    46 
    48 
    47 void
    49 void
    48 ListScheduler::Insert (const Event &ev)
    50 ListScheduler::Insert (const Event &ev)
    49 {
    51 {
    50   for (EventsI i = m_events.begin (); i != m_events.end (); i++) 
    52   for (EventsI i = m_events.begin (); i != m_events.end (); i++)
    51     {
    53     {
    52       if (ev.key < i->key)
    54       if (ev.key < i->key)
    53         {
    55         {
    54           m_events.insert (i, ev);
    56           m_events.insert (i, ev);
    55           return;
    57           return;
    56         }
    58         }
    57     }
    59     }
    58   m_events.push_back (ev);
    60   m_events.push_back (ev);
    59 }
    61 }
    60 bool 
    62 bool
    61 ListScheduler::IsEmpty (void) const
    63 ListScheduler::IsEmpty (void) const
    62 {
    64 {
    63   return m_events.empty ();
    65   return m_events.empty ();
    64 }
    66 }
    65 Scheduler::Event
    67 Scheduler::Event
    77 }
    79 }
    78 
    80 
    79 void
    81 void
    80 ListScheduler::Remove (const Event &ev)
    82 ListScheduler::Remove (const Event &ev)
    81 {
    83 {
    82   for (EventsI i = m_events.begin (); i != m_events.end (); i++) 
    84   for (EventsI i = m_events.begin (); i != m_events.end (); i++)
    83     {
    85     {
    84       if (i->key.m_uid == ev.key.m_uid)
    86       if (i->key.m_uid == ev.key.m_uid)
    85         {
    87         {
    86           NS_ASSERT (ev.impl == i->impl);
    88           NS_ASSERT (ev.impl == i->impl);
    87           m_events.erase (i);
    89           m_events.erase (i);