A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
list-scheduler.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005 INRIA
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 */
19
20#ifndef LIST_SCHEDULER_H
21#define LIST_SCHEDULER_H
22
23#include "scheduler.h"
24
25#include <list>
26#include <stdint.h>
27#include <utility>
28
29/**
30 * \file
31 * \ingroup scheduler
32 * ns3::ListScheduler declaration.
33 */
34
35namespace ns3
36{
37
38class EventImpl;
39
40/**
41 * \ingroup scheduler
42 * \brief a std::list event scheduler
43 *
44 * This class implements an event scheduler using an std::list
45 * data structure, that is, a double linked-list.
46 *
47 * \par Time Complexity
48 *
49 * Operation | Amortized %Time | Reason
50 * :----------- | :-------------- | :-----
51 * Insert() | Linear | Linear search in `std::list`
52 * IsEmpty() | Constant | `std::list::size()`
53 * PeekNext() | Constant | `std::list::front()`
54 * Remove() | Linear | Linear search in `std::list`
55 * RemoveNext() | Constant | `std::list::pop_front()`
56 *
57 * \par Memory Complexity
58 *
59 * Category | Memory | Reason
60 * :-------- | :------------------------------- | :-----
61 * Overhead | 2 x `sizeof (*)` + `size_t`<br/>(24 bytes) | `std::list`
62 * Per Event | 2 x `sizeof (*)` | `std::list`
63 *
64 */
66{
67 public:
68 /**
69 * Register this type.
70 * \return The object TypeId.
71 */
72 static TypeId GetTypeId();
73
74 /** Constructor. */
76 /** Destructor. */
77 ~ListScheduler() override;
78
79 // Inherited
80 void Insert(const Scheduler::Event& ev) override;
81 bool IsEmpty() const override;
82 Scheduler::Event PeekNext() const override;
84 void Remove(const Scheduler::Event& ev) override;
85
86 private:
87 /** Event list type: a simple list of Events. */
88 typedef std::list<Scheduler::Event> Events;
89 /** Events iterator. */
90 typedef std::list<Scheduler::Event>::iterator EventsI;
91
92 /** The event list. */
94};
95
96} // namespace ns3
97
98#endif /* LIST_SCHEDULER_H */
a std::list event scheduler
std::list< Scheduler::Event >::iterator EventsI
Events iterator.
~ListScheduler() override
Destructor.
std::list< Scheduler::Event > Events
Event list type: a simple list of Events.
ListScheduler()
Constructor.
Events m_events
The event list.
Scheduler::Event RemoveNext() override
Remove the earliest event from the event list.
void Remove(const Scheduler::Event &ev) override
Remove a specific event from the event list.
bool IsEmpty() const override
Test if the schedule is empty.
Scheduler::Event PeekNext() const override
Get a pointer to the next event.
void Insert(const Scheduler::Event &ev) override
Insert a new Event in the schedule.
static TypeId GetTypeId()
Register this type.
Maintain the event list.
Definition: scheduler.h:157
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Scheduler abstract base class, ns3::Scheduler::Event and ns3::Scheduler::EventKey declarations.
Scheduler event.
Definition: scheduler.h:184