/usr/include/ns3/heap-scheduler.h is in libns3-dev 3.13+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2005 INRIA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
#ifndef HEAP_SCHEDULER_H
#define HEAP_SCHEDULER_H
#include "scheduler.h"
#include <stdint.h>
#include <vector>
namespace ns3 {
/**
* \ingroup scheduler
* \brief a binary heap event scheduler
*
* This code started as a c++ translation of a java-based code written in 2005
* to implement a heap sort. So, this binary heap is really a pretty
* straightforward implementation of the classic data structure. Not much to say
* about it.
*
* What is smart about this code ?
* - it does not use the index 0 in the array to avoid having to convert
* C-style array indexes (which start at zero) and heap-style indexes
* (which start at 1). This is why _all_ indexes start at 1, and that
* the index of the root is 1.
* - It uses a slightly non-standard while loop for top-down heapify
* to move one if statement out of the loop.
*/
class HeapScheduler : public Scheduler
{
public:
static TypeId GetTypeId (void);
HeapScheduler ();
virtual ~HeapScheduler ();
virtual void Insert (const Event &ev);
virtual bool IsEmpty (void) const;
virtual Event PeekNext (void) const;
virtual Event RemoveNext (void);
virtual void Remove (const Event &ev);
private:
typedef std::vector<Event> BinaryHeap;
inline uint32_t Parent (uint32_t id) const;
uint32_t Sibling (uint32_t id) const;
inline uint32_t LeftChild (uint32_t id) const;
inline uint32_t RightChild (uint32_t id) const;
inline uint32_t Root (void) const;
/* Return the position in the array of the last element included in it. */
uint32_t Last (void) const;
inline bool IsRoot (uint32_t id) const;
inline bool IsBottom (uint32_t id) const;
inline bool IsLessStrictly (uint32_t a, uint32_t b) const;
inline uint32_t Smallest (uint32_t a, uint32_t b) const;
inline void Exch (uint32_t a, uint32_t b);
void BottomUp (void);
void TopDown (uint32_t start);
BinaryHeap m_heap;
};
} // namespace ns3
#endif /* HEAP_SCHEDULER_H */
|