30 |
30 |
31 class EventHolder; |
31 class EventHolder; |
32 |
32 |
33 class SchedulerHeap : public Scheduler { |
33 class SchedulerHeap : public Scheduler { |
34 public: |
34 public: |
35 SchedulerHeap (); |
35 SchedulerHeap (); |
36 virtual ~SchedulerHeap (); |
36 virtual ~SchedulerHeap (); |
37 |
37 |
38 private: |
38 private: |
39 virtual EventId RealInsert (EventImpl *event, Scheduler::EventKey key); |
39 virtual EventId RealInsert (EventImpl *event, Scheduler::EventKey key); |
40 virtual bool RealIsEmpty (void) const; |
40 virtual bool RealIsEmpty (void) const; |
41 virtual EventImpl *RealPeekNext (void) const; |
41 virtual EventImpl *RealPeekNext (void) const; |
42 virtual Scheduler::EventKey RealPeekNextKey (void) const; |
42 virtual Scheduler::EventKey RealPeekNextKey (void) const; |
43 virtual void RealRemoveNext (void); |
43 virtual void RealRemoveNext (void); |
44 virtual EventImpl *RealRemove (EventId ev, Scheduler::EventKey *key); |
44 virtual EventImpl *RealRemove (EventId ev, Scheduler::EventKey *key); |
45 virtual bool RealIsValid (EventId id); |
45 virtual bool RealIsValid (EventId id); |
46 |
46 |
47 typedef std::vector<std::pair<EventImpl *, Scheduler::EventKey> > BinaryHeap; |
47 typedef std::vector<std::pair<EventImpl *, Scheduler::EventKey> > BinaryHeap; |
48 inline void StoreInEvent (EventImpl *ev, uint32_t index) const; |
48 inline void StoreInEvent (EventImpl *ev, uint32_t index) const; |
49 uint32_t GetFromEvent (EventImpl *ev) const; |
49 uint32_t GetFromEvent (EventImpl *ev) const; |
50 |
50 |
51 inline uint32_t Parent (uint32_t id) const; |
51 inline uint32_t Parent (uint32_t id) const; |
52 uint32_t Sibling (uint32_t id) const; |
52 uint32_t Sibling (uint32_t id) const; |
53 inline uint32_t LeftChild (uint32_t id) const; |
53 inline uint32_t LeftChild (uint32_t id) const; |
54 inline uint32_t RightChild (uint32_t id) const; |
54 inline uint32_t RightChild (uint32_t id) const; |
55 inline uint32_t Root (void) const; |
55 inline uint32_t Root (void) const; |
56 uint32_t Last (void) const; |
56 uint32_t Last (void) const; |
57 inline bool IsRoot (uint32_t id) const; |
57 inline bool IsRoot (uint32_t id) const; |
58 inline bool IsBottom (uint32_t id) const; |
58 inline bool IsBottom (uint32_t id) const; |
59 inline bool IsLess (uint32_t a, uint32_t b); |
59 inline bool IsLess (uint32_t a, uint32_t b); |
60 inline uint32_t Smallest (uint32_t a, uint32_t b); |
60 inline uint32_t Smallest (uint32_t a, uint32_t b); |
61 |
61 |
62 inline void Exch (uint32_t a, uint32_t b); |
62 inline void Exch (uint32_t a, uint32_t b); |
63 void BottomUp (void); |
63 void BottomUp (void); |
64 void TopDown (void); |
64 void TopDown (void); |
65 |
65 |
66 BinaryHeap m_heap; |
66 BinaryHeap m_heap; |
67 }; |
67 }; |
68 |
68 |
69 }; // namespace ns3 |
69 }; // namespace ns3 |
70 |
70 |
71 |
71 |