3#include <Foundation/Algorithm/Sorting.h>
4#include <Foundation/Containers/Implementation/ArrayIterator.h>
5#include <Foundation/Memory/Allocator.h>
6#include <Foundation/Memory/AllocatorWrapper.h>
10# define plInvalidIndex 0xFFFFFFFF
25template <
typename T,
bool Construct>
78 template <
typename =
void>
104 void PopBack(plUInt32 uiElements = 1);
116 void PopFront(plUInt32 uiElements = 1);
137 bool Contains(
const T& value)
const;
140 plUInt32
IndexOf(
const T& value, plUInt32 uiStartIndex = 0)
const;
143 plUInt32
LastIndexOf(
const T& value, plUInt32 uiStartIndex = plInvalidIndex)
const;
158 void InsertAt(plUInt32 uiIndex,
const T& value);
161 template <
typename Comparer>
162 void Sort(
const Comparer& comparer);
193 void CompactIndexArray(plUInt32 uiMinChunksToKeep);
196 void MoveIndexChunksLeft(plUInt32 uiChunkDiff);
199 void MoveIndexChunksRight(plUInt32 uiChunkDiff);
202 plUInt32 GetFirstUsedChunk()
const;
206 plUInt32 GetLastUsedChunk(plUInt32 uiAtSize)
const;
209 plUInt32 GetLastUsedChunk()
const;
213 plUInt32 GetRequiredChunks(plUInt32 uiAtSize)
const;
216 void DeallocateUnusedChunks(plUInt32 uiMaxChunks);
219 void ResetReduceSizeCounter();
236 void ReduceSize(plInt32 iReduction);
239 plUInt32 GetCurMaxCount()
const;
246 T& ElementAt(plUInt32 uiIndex);
249 void DeallocateAll();
254 plUInt32 m_uiFirstElement;
256 plUInt32 m_uiAllocatedChunks;
257 plInt32 m_iReduceSizeTimer;
259 plUInt32 m_uiMaxCount;
262#if PL_ENABLED(PL_COMPILE_FOR_DEBUG)
263 plUInt32 m_uiChunkSize;
268template <
typename T,
typename AllocatorWrapper = plDefaultAllocatorWrapper,
bool Construct = true>
288template <
typename T,
bool Construct>
294template <
typename T,
bool Construct>
300template <
typename T,
bool Construct>
306template <
typename T,
bool Construct>
312template <
typename T,
bool Construct>
318template <
typename T,
bool Construct>
324template <
typename T,
bool Construct>
330template <
typename T,
bool Construct>
336template <
typename T,
bool Construct>
342template <
typename T,
bool Construct>
348template <
typename T,
bool Construct>
354template <
typename T,
bool Construct>
360#include <Foundation/Containers/Implementation/Deque_inl.h>
Base class for all memory allocators.
Definition Allocator.h:23
A double ended queue container.
Definition Deque.h:27
void Swap(plDequeBase< T, Construct > &other)
swaps the contents of this deque with another one
Definition Deque_inl.h:264
~plDequeBase()
Destructor.
Definition Deque_inl.h:67
T & operator[](plUInt32 uiIndex)
Accesses the n-th element in the deque.
Definition Deque_inl.h:447
void PopBack(plUInt32 uiElements=1)
Removes the last element from the deque.
Definition Deque_inl.h:525
void Clear()
Destructs all elements and sets the count to zero. Does not deallocate any data.
Definition Deque_inl.h:130
void Sort()
Sort with default comparer.
Definition Deque_inl.h:963
plUInt32 IndexOf(const T &value, plUInt32 uiStartIndex=0) const
Returns the first index at which an element with the given value could be found or plInvalidIndex if ...
Definition Deque_inl.h:643
void Reserve(plUInt32 uiCount)
Rearranges the internal data structures such that the amount of reserved elements can be appended wit...
Definition Deque_inl.h:158
void RemoveAtAndSwap(plUInt32 uiIndex)
Removes the element at the given index and fills the gap with the last element in the deque.
Definition Deque_inl.h:666
plUInt32 LastIndexOf(const T &value, plUInt32 uiStartIndex=plInvalidIndex) const
Returns the last index at which an element with the given value could be found or plInvalidIndex if n...
Definition Deque_inl.h:655
void PushFront()
Adds one default constructed element to the front of the deque.
Definition Deque_inl.h:566
plUInt64 GetHeapMemoryUsage() const
Returns the amount of bytes that are currently allocated on the heap.
Definition Deque_inl.h:970
plUInt32 GetCount() const
Returns the number of active elements in the deque.
Definition Deque_inl.h:607
bool operator==(const plDequeBase< T, Construct > &rhs) const
Comparison operator.
Definition Deque_inl.h:115
void InsertAt(plUInt32 uiIndex, const T &value)
Inserts value at index by shifting all following elements. Valid insert positions are [0; GetCount].
Definition Deque_inl.h:937
plUInt32 GetContiguousRange(plUInt32 uiStartIndex) const
Returns the number of elements after uiStartIndex that are stored in contiguous memory.
Definition Deque_inl.h:432
void Compact()
This function deallocates as much memory as possible to shrink the deque to the bare minimum size tha...
Definition Deque_inl.h:246
T & ExpandAndGetRef()
Grows the deque by one element and returns a reference to the newly created element.
Definition Deque_inl.h:473
void SetCountUninitialized(plUInt32 uiCount)
\Same as SetCount(), but new elements do not get default constructed.
Definition Deque_inl.h:389
void RemoveAtAndCopy(plUInt32 uiIndex)
Removes the element at index and fills the gap by shifting all following elements.
Definition Deque_inl.h:894
plAllocator * GetAllocator() const
Returns the allocator that is used by this instance.
Definition Deque.h:168
void PushBack()
Adds one default constructed element to the back of the deque.
Definition Deque_inl.h:489
void EnsureCount(plUInt32 uiCount)
Ensures the container has at least uiCount elements. Ie. calls SetCount() if the container has fewer ...
Definition Deque_inl.h:423
bool RemoveAndSwap(const T &value)
Removes the first occurrence of value and fills the gap with the last element in the deque.
Definition Deque_inl.h:923
bool Contains(const T &value) const
Checks whether there is any element in the deque with the given value.
Definition Deque_inl.h:637
const T & PeekFront() const
Returns the first element.
Definition Deque_inl.h:613
plDequeBase(plAllocator *pAllocator)
No memory is allocated during construction.
Definition Deque_inl.h:41
void PopFront(plUInt32 uiElements=1)
Removes the first element from the deque.
Definition Deque_inl.h:581
void operator=(const plDequeBase< T, Construct > &rhs)
Assignment operator.
Definition Deque_inl.h:73
const T & PeekBack() const
Returns the last element.
Definition Deque_inl.h:625
bool IsEmpty() const
Checks whether no elements are active in the deque.
Definition Deque_inl.h:601
bool RemoveAndCopy(const T &value)
Removes the first occurrence of value and fills the gap by shifting all following elements.
Definition Deque_inl.h:909
void SetCount(plUInt32 uiCount)
Sets the number of active elements in the deque. All new elements are default constructed....
Definition Deque_inl.h:346
Base class for STL like random access iterators.
Definition ArrayIterator.h:9
Non-const STL like iterators.
Definition ArrayIterator.h:91