5 #ifndef __IRR_LIST_H_INCLUDED__ 6 #define __IRR_LIST_H_INCLUDED__ 27 SKListNode(
const T& e) : Next(0), Prev(0), Element(e) {}
43 Iterator& operator ++() { Current = Current->Next;
return *
this; }
44 Iterator& operator --() { Current = Current->Prev;
return *
this; }
52 while (num-- && this->Current != 0) ++(*this);
56 while(num++ && this->Current != 0) --(*this);
63 Iterator operator - (
s32 num)
const {
return (*
this)+ (-num); }
65 bool operator ==(
const Iterator& other)
const {
return Current == other.Current; }
66 bool operator !=(
const Iterator& other)
const {
return Current != other.Current; }
67 bool operator ==(
const ConstIterator& other)
const {
return Current == other.Current; }
68 bool operator !=(
const ConstIterator& other)
const {
return Current != other.Current; }
70 #if defined (_MSC_VER) && (_MSC_VER < 1300) 71 #pragma warning(disable:4284) // infix notation problem when using iterator operator -> 75 T * operator ->() {
return &Current->Element; }
103 while(num-- && this->Current != 0) ++(*this);
107 while(num++ && this->Current != 0) --(*this);
116 bool operator ==(
const ConstIterator& other)
const {
return Current == other.Current; }
117 bool operator !=(
const ConstIterator& other)
const {
return Current != other.Current; }
118 bool operator ==(
const Iterator& other)
const {
return Current == other.Current; }
119 bool operator !=(
const Iterator& other)
const {
return Current != other.Current; }
122 const T * operator ->() {
return &Current->Element; }
137 : First(0), Last(0), Size(0) {}
164 SKListNode* node = other.First;
191 SKListNode * next = First->Next;
192 allocator.destruct(First);
193 allocator.deallocate(First);
215 SKListNode* node = allocator.allocate(1);
216 allocator.construct(node, element);
236 SKListNode* node = allocator.allocate(1);
237 allocator.construct(node, element);
259 return Iterator(First);
267 return ConstIterator(First);
283 return ConstIterator(0);
291 return Iterator(Last);
299 return ConstIterator(Last);
310 SKListNode* node = allocator.allocate(1);
311 allocator.construct(node, element);
313 node->Next = it.Current->Next;
315 if (it.Current->Next)
316 it.Current->Next->Prev = node;
318 node->Prev = it.Current;
319 it.Current->Next = node;
322 if (it.Current == Last)
334 SKListNode* node = allocator.allocate(1);
335 allocator.construct(node, element);
337 node->Prev = it.Current->Prev;
339 if (it.Current->Prev)
340 it.Current->Prev->Next = node;
342 node->Next = it.Current;
343 it.Current->Prev = node;
346 if (it.Current == First)
359 Iterator returnIterator(it);
362 if(it.Current == First)
364 First = it.Current->Next;
368 it.Current->Prev->Next = it.Current->Next;
371 if(it.Current == Last)
373 Last = it.Current->Prev;
377 it.Current->Next->Prev = it.Current->Prev;
380 allocator.destruct(it.Current);
381 allocator.deallocate(it.Current);
385 return returnIterator;
void insert_after(const Iterator &it, const T &element)
Inserts an element after an element.
u32 size() const
Returns amount of elements in list.
ConstIterator(const Iterator &iter)
Iterator getLast()
Gets last element.
Everything in the Irrlicht Engine can be found in this namespace.
ConstIterator end() const
Gets end node.
Doubly linked list template.
List iterator for const access.
list(const list< T > &other)
Copy constructor.
signed int s32
32 bit signed variable.
void push_back(const T &element)
Adds an element at the end of the list.
unsigned int u32
32 bit unsigned variable.
void push_front(const T &element)
Adds an element at the begin of the list.
void operator=(const list< T > &other)
Assignment operator.
void swap(list< T > &other)
Swap the content of this list container with the content of another list.
void swap(T1 &a, T2 &b)
swaps the content of the passed parameters
ConstIterator begin() const
Gets first node.
void clear()
Clears the list, deletes all elements in the list.
Iterator erase(Iterator &it)
Erases an element.
Iterator end()
Gets end node.
CMatrix4< T > operator*(const T scalar, const CMatrix4< T > &mat)
bool empty() const
Checks for empty list.
Iterator begin()
Gets first node.
void insert_before(const Iterator &it, const T &element)
Inserts an element before an element.
ConstIterator getLast() const
Gets last element.
list()
Default constructor for empty list.