Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | List of all members
dart::bin::CircularLinkedList< T > Class Template Reference

#include <eventhandler.h>

Public Types

typedef void(* ClearFun) (void *value)
 

Public Member Functions

 CircularLinkedList ()
 
bool Add (T t)
 
void RemoveHead (ClearFun clear=nullptr)
 
void Remove (T item)
 
void RemoveAll (ClearFun clear=nullptr)
 
T head () const
 
bool HasHead () const
 
void Rotate ()
 

Detailed Description

template<typename T>
class dart::bin::CircularLinkedList< T >

Definition at line 113 of file eventhandler.h.

Member Typedef Documentation

◆ ClearFun

template<typename T >
typedef void(* dart::bin::CircularLinkedList< T >::ClearFun) (void *value)

Definition at line 117 of file eventhandler.h.

Constructor & Destructor Documentation

◆ CircularLinkedList()

template<typename T >
dart::bin::CircularLinkedList< T >::CircularLinkedList ( )
inline

Definition at line 115 of file eventhandler.h.

115: head_(nullptr) {}

Member Function Documentation

◆ Add()

template<typename T >
bool dart::bin::CircularLinkedList< T >::Add ( T  t)
inline

Definition at line 120 of file eventhandler.h.

120 {
121 Entry* e = new Entry(t);
122 if (head_ == nullptr) {
123 // Empty list, make e head, and point to itself.
124 e->next_ = e;
125 e->prev_ = e;
126 head_ = e;
127 return true;
128 } else {
129 // Insert e as the last element in the list.
130 e->prev_ = head_->prev_;
131 e->next_ = head_;
132 e->prev_->next_ = e;
133 head_->prev_ = e;
134 return false;
135 }
136 }

◆ HasHead()

template<typename T >
bool dart::bin::CircularLinkedList< T >::HasHead ( ) const
inline

Definition at line 193 of file eventhandler.h.

193{ return head_ != nullptr; }

◆ head()

template<typename T >
T dart::bin::CircularLinkedList< T >::head ( ) const
inline

Definition at line 191 of file eventhandler.h.

191{ return head_->t; }

◆ Remove()

template<typename T >
void dart::bin::CircularLinkedList< T >::Remove ( T  item)
inline

Definition at line 155 of file eventhandler.h.

155 {
156 if (head_ == nullptr) {
157 return;
158 } else if (head_ == head_->next_) {
159 if (head_->t == item) {
160 delete head_;
161 head_ = nullptr;
162 return;
163 }
164 } else {
165 Entry* current = head_;
166 do {
167 if (current->t == item) {
168 Entry* next = current->next_;
169 Entry* prev = current->prev_;
170 prev->next_ = next;
171 next->prev_ = prev;
172
173 if (current == head_) {
174 head_ = head_->next_;
175 }
176
177 delete current;
178 return;
179 }
180 current = current->next_;
181 } while (current != head_);
182 }
183 }
static float next(float f)
static float prev(float f)

◆ RemoveAll()

template<typename T >
void dart::bin::CircularLinkedList< T >::RemoveAll ( ClearFun  clear = nullptr)
inline

Definition at line 185 of file eventhandler.h.

185 {
186 while (HasHead()) {
187 RemoveHead(clear);
188 }
189 }
void RemoveHead(ClearFun clear=nullptr)
Definition: eventhandler.h:138

◆ RemoveHead()

template<typename T >
void dart::bin::CircularLinkedList< T >::RemoveHead ( ClearFun  clear = nullptr)
inline

Definition at line 138 of file eventhandler.h.

138 {
139 ASSERT(head_ != nullptr);
140
141 Entry* e = head_;
142 if (e->next_ == e) {
143 head_ = nullptr;
144 } else {
145 e->prev_->next_ = e->next_;
146 e->next_->prev_ = e->prev_;
147 head_ = e->next_;
148 }
149 if (clear != nullptr) {
150 clear(reinterpret_cast<void*>(e->t));
151 }
152 delete e;
153 }
#define ASSERT(E)

◆ Rotate()

template<typename T >
void dart::bin::CircularLinkedList< T >::Rotate ( )
inline

Definition at line 195 of file eventhandler.h.

195 {
196 if (head_ != nullptr) {
197 ASSERT(head_->next_ != nullptr);
198 head_ = head_->next_;
199 }
200 }

The documentation for this class was generated from the following file: