A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
map-scheduler.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2006 INRIA
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7
*/
8
9
#ifndef MAP_SCHEDULER_H
10
#define MAP_SCHEDULER_H
11
12
#include "
scheduler.h
"
13
14
#include <map>
15
#include <stdint.h>
16
#include <utility>
17
18
/**
19
* \file
20
* \ingroup scheduler
21
* ns3::MapScheduler declaration.
22
*/
23
24
namespace
ns3
25
{
26
27
/**
28
* \ingroup scheduler
29
* \brief a std::map event scheduler
30
*
31
* This class implements the an event scheduler using an std::map
32
* data structure.
33
*
34
* \par Time Complexity
35
*
36
* Operation | Amortized %Time | Reason
37
* :----------- | :-------------- | :-----
38
* Insert() | Logarithmic | `std::map::insert()`
39
* IsEmpty() | Constant | `std::map::empty()`
40
* PeekNext() | Constant | `std::map::begin()`
41
* Remove() | Logarithmic | `std::map::find()`
42
* RemoveNext() | Constant | `std::map::begin()`
43
*
44
* \par Memory Complexity
45
*
46
* Category | Memory | Reason
47
* :-------- | :------------------------------- | :-----
48
* Overhead | 3 x `sizeof (*)` + 2 x `size_t`<br/>(40 bytes) | red-black tree
49
* Per Event | 3 x `sizeof (*)` + `int`<br/>(32 bytes) | red-black tree
50
*
51
*/
52
class
MapScheduler
:
public
Scheduler
53
{
54
public
:
55
/**
56
* Register this type.
57
* \return The object TypeId.
58
*/
59
static
TypeId
GetTypeId
();
60
61
/** Constructor. */
62
MapScheduler
();
63
/** Destructor. */
64
~MapScheduler
()
override
;
65
66
// Inherited
67
void
Insert
(
const
Scheduler::Event
& ev)
override
;
68
bool
IsEmpty
()
const override
;
69
Scheduler::Event
PeekNext
()
const override
;
70
Scheduler::Event
RemoveNext
()
override
;
71
void
Remove
(
const
Scheduler::Event
& ev)
override
;
72
73
private
:
74
/** Event list type: a Map from EventKey to EventImpl. */
75
typedef
std::map<Scheduler::EventKey, EventImpl*>
EventMap
;
76
/** EventMap iterator. */
77
typedef
std::map<Scheduler::EventKey, EventImpl*>::iterator
EventMapI
;
78
/** EventMap const iterator. */
79
typedef
std::map<Scheduler::EventKey, EventImpl*>::const_iterator
EventMapCI
;
80
81
/** The event list. */
82
EventMap
m_list
;
83
};
84
85
}
// namespace ns3
86
87
#endif
/* MAP_SCHEDULER_H */
ns3::MapScheduler
a std::map event scheduler
Definition
map-scheduler.h:53
ns3::MapScheduler::Remove
void Remove(const Scheduler::Event &ev) override
Remove a specific event from the event list.
Definition
map-scheduler.cc:96
ns3::MapScheduler::MapScheduler
MapScheduler()
Constructor.
Definition
map-scheduler.cc:41
ns3::MapScheduler::EventMap
std::map< Scheduler::EventKey, EventImpl * > EventMap
Event list type: a Map from EventKey to EventImpl.
Definition
map-scheduler.h:75
ns3::MapScheduler::EventMapCI
std::map< Scheduler::EventKey, EventImpl * >::const_iterator EventMapCI
EventMap const iterator.
Definition
map-scheduler.h:79
ns3::MapScheduler::Insert
void Insert(const Scheduler::Event &ev) override
Insert a new Event in the schedule.
Definition
map-scheduler.cc:52
ns3::MapScheduler::RemoveNext
Scheduler::Event RemoveNext() override
Remove the earliest event from the event list.
Definition
map-scheduler.cc:82
ns3::MapScheduler::PeekNext
Scheduler::Event PeekNext() const override
Get a pointer to the next event.
Definition
map-scheduler.cc:68
ns3::MapScheduler::IsEmpty
bool IsEmpty() const override
Test if the schedule is empty.
Definition
map-scheduler.cc:61
ns3::MapScheduler::EventMapI
std::map< Scheduler::EventKey, EventImpl * >::iterator EventMapI
EventMap iterator.
Definition
map-scheduler.h:77
ns3::MapScheduler::m_list
EventMap m_list
The event list.
Definition
map-scheduler.h:82
ns3::MapScheduler::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition
map-scheduler.cc:32
ns3::MapScheduler::~MapScheduler
~MapScheduler() override
Destructor.
Definition
map-scheduler.cc:46
ns3::Scheduler
Maintain the event list.
Definition
scheduler.h:146
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
scheduler.h
ns3::Scheduler abstract base class, ns3::Scheduler::Event and ns3::Scheduler::EventKey declarations.
ns3::Scheduler::Event
Scheduler event.
Definition
scheduler.h:173
src
core
model
map-scheduler.h
Generated on Wed Oct 9 2024 01:03:22 for ns-3 by
1.11.0