A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
list-scheduler.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2005 INRIA
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
*/
20
21
#include "
list-scheduler.h
"
22
#include "
event-impl.h
"
23
#include <utility>
24
#include <string>
25
#include "
assert.h
"
26
27
namespace
ns3 {
28
29
30
NS_OBJECT_ENSURE_REGISTERED
(ListScheduler);
31
32
TypeId
33
ListScheduler::GetTypeId
(
void
)
34
{
35
static
TypeId
tid =
TypeId
(
"ns3::ListScheduler"
)
36
.
SetParent
<
Scheduler
> ()
37
.AddConstructor<ListScheduler> ()
38
;
39
return
tid;
40
}
41
42
ListScheduler::ListScheduler
()
43
{
44
}
45
ListScheduler::~ListScheduler
()
46
{
47
}
48
49
void
50
ListScheduler::Insert
(
const
Event
&ev)
51
{
52
for
(
EventsI
i =
m_events
.begin (); i !=
m_events
.end (); i++)
53
{
54
if
(ev.
key
< i->key)
55
{
56
m_events
.insert (i, ev);
57
return
;
58
}
59
}
60
m_events
.push_back (ev);
61
}
62
bool
63
ListScheduler::IsEmpty
(
void
)
const
64
{
65
return
m_events
.empty ();
66
}
67
Scheduler::Event
68
ListScheduler::PeekNext
(
void
)
const
69
{
70
return
m_events
.front ();
71
}
72
73
Scheduler::Event
74
ListScheduler::RemoveNext
(
void
)
75
{
76
Event
next =
m_events
.front ();
77
m_events
.pop_front ();
78
return
next;
79
}
80
81
void
82
ListScheduler::Remove
(
const
Event
&ev)
83
{
84
for
(
EventsI
i =
m_events
.begin (); i !=
m_events
.end (); i++)
85
{
86
if
(i->key.m_uid == ev.
key
.
m_uid
)
87
{
88
NS_ASSERT
(ev.
impl
== i->impl);
89
m_events
.erase (i);
90
return
;
91
}
92
}
93
NS_ASSERT
(
false
);
94
}
95
96
}
// namespace ns3
src
core
model
list-scheduler.cc
Generated on Tue Oct 9 2012 16:45:34 for ns-3 by
1.8.1.2