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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8
9#ifndef LIST_SCHEDULER_H
10#define LIST_SCHEDULER_H
11
12#include "scheduler.h"
13
14#include <list>
15#include <stdint.h>
16#include <utility>
17
18/**
19 * \file
20 * \ingroup scheduler
21 * ns3::ListScheduler declaration.
22 */
23
24namespace ns3
25{
26
27class EventImpl;
28
29/**
30 * \ingroup scheduler
31 * \brief a std::list event scheduler
32 *
33 * This class implements an event scheduler using an std::list
34 * data structure, that is, a double linked-list.
35 *
36 * \par Time Complexity
37 *
38 * Operation | Amortized %Time | Reason
39 * :----------- | :-------------- | :-----
40 * Insert() | Linear | Linear search in `std::list`
41 * IsEmpty() | Constant | `std::list::size()`
42 * PeekNext() | Constant | `std::list::front()`
43 * Remove() | Linear | Linear search in `std::list`
44 * RemoveNext() | Constant | `std::list::pop_front()`
45 *
46 * \par Memory Complexity
47 *
48 * Category | Memory | Reason
49 * :-------- | :------------------------------- | :-----
50 * Overhead | 2 x `sizeof (*)` + `size_t`<br/>(24 bytes) | `std::list`
51 * Per Event | 2 x `sizeof (*)` | `std::list`
52 *
53 */
55{
56 public:
57 /**
58 * Register this type.
59 * \return The object TypeId.
60 */
61 static TypeId GetTypeId();
62
63 /** Constructor. */
65 /** Destructor. */
66 ~ListScheduler() override;
67
68 // Inherited
69 void Insert(const Scheduler::Event& ev) override;
70 bool IsEmpty() const override;
71 Scheduler::Event PeekNext() const override;
73 void Remove(const Scheduler::Event& ev) override;
74
75 private:
76 /** Event list type: a simple list of Events. */
77 typedef std::list<Scheduler::Event> Events;
78 /** Events iterator. */
79 typedef std::list<Scheduler::Event>::iterator EventsI;
80
81 /** The event list. */
83};
84
85} // namespace ns3
86
87#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:146
a unique identifier for an interface.
Definition type-id.h:48
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:173