3#include <Foundation/Containers/Deque.h>
16 struct ListElementBase
25 struct ListElement :
public ListElementBase
31 explicit ListElement(
const T& data);
39 PL_DECLARE_POD_TYPE();
48 bool operator==(
typename plListBase<T>::ConstIterator it2)
const {
return (m_pElement == it2.m_pElement); }
49 PL_ADD_DEFAULT_OPERATOR_NOTEQUAL(
typename plListBase<T>::ConstIterator);
52 const T& operator*()
const {
return (m_pElement->m_Data); }
55 const T* operator->()
const {
return (&m_pElement->m_Data); }
58 void Next() { m_pElement = m_pElement->m_pNext; }
61 void Prev() { m_pElement = m_pElement->m_pPrev; }
64 bool IsValid()
const {
return ((m_pElement !=
nullptr) && (m_pElement->m_pPrev !=
nullptr) && (m_pElement->m_pNext !=
nullptr)); }
67 void operator++() { Next(); }
70 void operator--() { Prev(); }
75 ConstIterator(ListElement* pInit)
80 ListElement* m_pElement;
88 using ConstIterator::operator*;
89 using ConstIterator::operator->;
91 PL_DECLARE_POD_TYPE();
108 explicit Iterator(ListElement* pInit)
109 : ConstIterator(pInit)
174 Iterator
Insert(
const Iterator& pos,
const T& data);
177 void Insert(
const Iterator& pos, ConstIterator first,
const ConstIterator& last);
180 Iterator
Insert(
const Iterator& pos);
183 Iterator
Remove(
const Iterator& pos);
186 Iterator
Remove(Iterator first,
const Iterator& last);
212 ListElementBase m_First;
215 ListElementBase m_Last;
224 ListElement* AcquireNode();
227 void ReleaseNode(ListElement* pNode);
233 ListElement* m_pFreeElementStack;
237template <
typename T,
typename AllocatorWrapper = plDefaultAllocatorWrapper>
251#include <Foundation/Containers/Implementation/List_inl.h>
Base class for all memory allocators.
Definition Allocator.h:23
plUInt64 GetHeapMemoryUsage() const
Returns the amount of bytes that are currently allocated on the heap.
Definition Deque_inl.h:970
plAllocator * GetAllocator() const
Returns the allocator that is used by this instance.
Definition Deque.h:168
A List-class, similar to STL::list.
Definition List.h:12
plUInt32 GetCount() const
Returns the number of elements in the list. O(1) operation.
Definition List_inl.h:127
~plListBase()
Destroys the list and all its content.
Definition List_inl.h:47
void SetCount(plUInt32 uiNewSize)
Sets the number of elements that are in the list.
Definition List_inl.h:307
plAllocator * GetAllocator() const
Returns the allocator that is used by this instance.
Definition List.h:201
plUInt64 GetHeapMemoryUsage() const
Returns the amount of bytes that are currently allocated on the heap.
Definition List.h:208
Iterator Remove(const Iterator &pos)
Erases the element pointed to by the iterator.
Definition List_inl.h:275
plListBase(plAllocator *pAllocator)
Initializes the list to be empty.
Definition List_inl.h:23
void PopFront()
Removes the very first element from the list.
Definition List_inl.h:220
T & PushFront()
Appends a default-constructed element to the front of the list and returns a reference to it.
Definition List_inl.h:200
void PopBack()
Removes the very last element from the list.
Definition List_inl.h:212
const T & PeekBack() const
Returns the very last element in the list.
Definition List_inl.h:179
void Compact()
See plDeque::Compact()
Definition List_inl.h:149
T & PushBack()
Appends a default-constructed element to the list and returns a reference to it.
Definition List_inl.h:188
void operator=(const plListBase< T > &cc)
Copies the list cc into this list.
Definition List_inl.h:53
const T & PeekFront() const
Returns the very first element in the list.
Definition List_inl.h:171
void Clear()
Clears the list, afterwards it is empty.
Definition List_inl.h:139
Iterator Insert(const Iterator &pos, const T &data)
Inserts one element before the position defined by the iterator.
Definition List_inl.h:245
bool IsEmpty() const
Returns whether size == 0. O(1) operation.
Definition List_inl.h:133
Iterator GetEndIterator()
Returns an iterator pointing behind the last element. Necessary if one wants to insert elements at th...
Definition List_inl.h:109
Iterator GetIterator()
Returns an iterator to the first list-element.
Definition List_inl.h:103
bool operator==(const plListBase< T > &rhs) const
Comparison operator.
Definition List_inl.h:317
A forward-iterator. Allows sequential access from front-to-back.
Definition List.h:86
T * operator->()
Accesses the element stored in the node.
Definition List.h:103
Iterator()
Constructor.
Definition List.h:94
T & operator*()
Accesses the element stored in the node.
Definition List.h:100