3#include <Foundation/Math/Math.h>
5#define REDUCE_SIZE(iReduction) \
6 m_iReduceSizeTimer -= iReduction; \
7 if (m_iReduceSizeTimer <= 0) \
10#define RESERVE(uiCount) \
11 if (uiCount > m_uiCount) \
13 m_uiMaxCount = plMath::Max(m_uiMaxCount, uiCount); \
14 if ((m_uiFirstElement <= 0) || (GetCurMaxCount() < uiCount)) \
18#define CHUNK_SIZE(Type) (4096 / sizeof(Type) < 32 ? 32 : 4096 / sizeof(Type))
22template <
typename T,
bool Construct>
25 m_pAllocator = pAllocator;
30 m_uiAllocatedChunks = 0;
33 ResetReduceSizeCounter();
35#if PL_ENABLED(PL_COMPILE_FOR_DEBUG)
36 m_uiChunkSize = CHUNK_SIZE(T);
40template <
typename T,
bool Construct>
43 Constructor(pAllocator);
46template <
typename T,
bool Construct>
49 static_assert(Construct,
"This function is not supported on Deques that do not construct their data.");
51 Constructor(pAllocator);
56template <
typename T,
bool Construct>
59 static_assert(Construct,
"This function is not supported on Deques that do not construct their data.");
61 Constructor(pAllocator);
63 *
this = std::move(rhs);
66template <
typename T,
bool Construct>
72template <
typename T,
bool Construct>
75 static_assert(Construct,
"This function is not supported on Deques that do not construct their data.");
78 RESERVE(rhs.m_uiCount);
79 m_uiCount = rhs.m_uiCount;
82 for (plUInt32 i = 0; i < rhs.m_uiCount; ++i)
86template <
typename T,
bool Construct>
89 static_assert(Construct,
"This function is not supported on Deques that do not construct their data.");
91 if (m_pAllocator != rhs.m_pAllocator)
97 m_uiCount = rhs.m_uiCount;
98 m_iReduceSizeTimer = rhs.m_iReduceSizeTimer;
99 m_pChunks = rhs.m_pChunks;
100 m_uiAllocatedChunks = rhs.m_uiAllocatedChunks;
101 m_uiChunks = rhs.m_uiChunks;
102 m_uiFirstElement = rhs.m_uiFirstElement;
103 m_uiMaxCount = rhs.m_uiMaxCount;
106 rhs.m_pChunks =
nullptr;
107 rhs.m_uiAllocatedChunks = 0;
109 rhs.m_uiFirstElement = 0;
110 rhs.m_uiMaxCount = 0;
114template <
typename T,
bool Construct>
120 for (plUInt32 i = 0; i < GetCount(); ++i)
122 if ((*
this)[i] != rhs[i])
129template <
typename T,
bool Construct>
134 for (plUInt32 i = 0; i < m_uiCount; ++i)
146 m_uiFirstElement = CHUNK_SIZE(T) * 16;
147 else if (m_uiChunks > 8)
148 m_uiFirstElement = CHUNK_SIZE(T) * 4;
149 else if (m_uiChunks > 1)
150 m_uiFirstElement = CHUNK_SIZE(T) * 1;
151 else if (m_uiChunks > 0)
152 m_uiFirstElement = 1;
154 m_uiFirstElement = 0;
157template <
typename T,
bool Construct>
171 if (uiCount <= m_uiCount)
179 if ((m_uiFirstElement > 0) && (GetCurMaxCount() >= uiCount))
182 const plUInt32 uiCurFirstChunk = GetFirstUsedChunk();
183 const plUInt32 uiRequiredChunks = GetRequiredChunks(uiCount);
186 if (m_uiChunks > uiRequiredChunks + 1)
188 const plUInt32 uiSpareChunks = m_uiChunks - uiRequiredChunks;
189 const plUInt32 uiSpareChunksStart = uiSpareChunks / 2;
191 PL_ASSERT_DEBUG(uiSpareChunksStart > 0,
"Implementation error.");
195 PL_ASSERT_DEBUG(uiSpareChunksStart != uiCurFirstChunk,
"No rearrangement possible.");
198 if (uiSpareChunksStart < uiCurFirstChunk)
199 MoveIndexChunksLeft(uiCurFirstChunk - uiSpareChunksStart);
201 MoveIndexChunksRight(uiSpareChunksStart - uiCurFirstChunk);
203 PL_ASSERT_DEBUG(m_uiFirstElement > 0,
"Did not achieve the desired effect.");
204 PL_ASSERT_DEBUG(GetCurMaxCount() >= uiCount,
"Did not achieve the desired effect ({0} >= {1}).", GetCurMaxCount(), uiCount);
208 const plUInt32 uiReallocSize = 16 + uiRequiredChunks + 16;
210 T** pNewChunksArray = PL_NEW_RAW_BUFFER(m_pAllocator, T*, uiReallocSize);
213 const plUInt32 uiFirstUsedChunk = m_uiFirstElement / CHUNK_SIZE(T);
219 for (plUInt32 i = 0; i < m_uiChunks - uiFirstUsedChunk; ++i)
221 pNewChunksArray[pos] = m_pChunks[uiFirstUsedChunk + i];
225 m_uiFirstElement -= uiFirstUsedChunk * CHUNK_SIZE(T);
228 for (plUInt32 i = 0; i < uiFirstUsedChunk; ++i)
230 pNewChunksArray[pos] = m_pChunks[i];
234 m_uiFirstElement += 16 * CHUNK_SIZE(T);
236 PL_ASSERT_DEBUG(m_uiFirstElement == (16 * CHUNK_SIZE(T)) + (m_uiFirstElement % CHUNK_SIZE(T)),
"");
239 PL_DELETE_RAW_BUFFER(m_pAllocator, m_pChunks);
240 m_pChunks = pNewChunksArray;
241 m_uiChunks = uiReallocSize;
245template <
typename T,
bool Construct>
248 ResetReduceSizeCounter();
257 DeallocateUnusedChunks(GetRequiredChunks(m_uiCount));
260 CompactIndexArray(0);
263template <
typename T,
bool Construct>
269 plMath::Swap(this->m_uiFirstElement, other.m_uiFirstElement);
271 plMath::Swap(this->m_uiAllocatedChunks, other.m_uiAllocatedChunks);
272 plMath::Swap(this->m_iReduceSizeTimer, other.m_iReduceSizeTimer);
276template <
typename T,
bool Construct>
280 uiMinChunksToKeep =
plMath::Max(uiRequiredChunks, uiMinChunksToKeep);
283 const plUInt32 uiChunksToKeep = 16 + uiMinChunksToKeep + 16;
286 if (uiChunksToKeep + 4 >= m_uiChunks / 2)
289 T** pNewChunkArray = PL_NEW_RAW_BUFFER(m_pAllocator, T*, uiChunksToKeep);
292 const plUInt32 uiFirstChunk = GetFirstUsedChunk();
295 DeallocateUnusedChunks(uiChunksToKeep);
298 for (plUInt32 i = 0; i < uiRequiredChunks; ++i)
300 pNewChunkArray[16 + i] = m_pChunks[uiFirstChunk + i];
301 m_pChunks[uiFirstChunk + i] =
nullptr;
308 for (plUInt32 i = 0; i < uiFirstChunk; ++i)
312 PL_ASSERT_DEBUG(iPos < 16 || ((iPos >= 16 + uiRequiredChunks) && (iPos < uiChunksToKeep)),
"Implementation error.");
314 pNewChunkArray[iPos] = m_pChunks[i];
315 m_pChunks[i] =
nullptr;
319 iPos += uiRequiredChunks;
323 for (plUInt32 i = GetLastUsedChunk() + 1; i < m_uiChunks; ++i)
327 PL_ASSERT_DEBUG(iPos < 16 || ((iPos >= 16 + uiRequiredChunks) && (iPos < uiChunksToKeep)),
"Implementation error.");
329 pNewChunkArray[iPos] = m_pChunks[i];
330 m_pChunks[i] =
nullptr;
334 iPos += uiRequiredChunks;
339 PL_DELETE_RAW_BUFFER(m_pAllocator, m_pChunks);
340 m_pChunks = pNewChunkArray;
341 m_uiChunks = uiChunksToKeep;
342 m_uiFirstElement = (16 * CHUNK_SIZE(T)) + (m_uiFirstElement % CHUNK_SIZE(T));
345template <
typename T,
bool Construct>
348 const plUInt32 uiOldCount = m_uiCount;
349 const plUInt32 uiNewCount = uiCount;
351 if (uiNewCount > uiOldCount)
356 m_uiCount = uiNewCount;
361 for (plUInt32 i = uiOldCount; i < uiNewCount; ++i)
366 for (plUInt32 i = uiOldCount; i < uiNewCount; ++i)
375 for (plUInt32 i = uiNewCount; i < uiOldCount; ++i)
379 m_uiCount = uiNewCount;
382 ReduceSize(uiOldCount - uiNewCount);
386template <
typename T,
bool Construct>
391 static_assert(
plIsPodType<T>::value == plTypeIsPod::value,
"SetCountUninitialized is only supported for POD types.");
393 const plUInt32 uiOldCount = m_uiCount;
394 const plUInt32 uiNewCount = uiCount;
396 if (uiNewCount > uiOldCount)
401 m_uiCount = uiNewCount;
403 for (plUInt32 i = uiOldCount; i < uiNewCount; ++i)
411 for (plUInt32 i = uiNewCount; i < uiOldCount; ++i)
415 m_uiCount = uiNewCount;
418 ReduceSize(uiOldCount - uiNewCount);
422template <
typename T,
bool Construct>
425 if (uiCount > m_uiCount)
431template <
typename T,
bool Construct>
434 PL_ASSERT_DEV(uiIndex < m_uiCount,
"The deque has {0} elements. Cannot access element {1}.", m_uiCount, uiIndex);
436 const plUInt32 uiChunkSize = CHUNK_SIZE(T);
438 const plUInt32 uiRealIndex = m_uiFirstElement + uiIndex;
439 const plUInt32 uiChunkOffset = uiRealIndex % uiChunkSize;
441 const plUInt32 uiRange = uiChunkSize - uiChunkOffset;
446template <
typename T,
bool Construct>
449 PL_ASSERT_DEBUG(uiIndex < m_uiCount,
"The deque has {0} elements. Cannot access element {1}.", m_uiCount, uiIndex);
451 const plUInt32 uiRealIndex = m_uiFirstElement + uiIndex;
453 const plUInt32 uiChunkIndex = uiRealIndex / CHUNK_SIZE(T);
454 const plUInt32 uiChunkOffset = uiRealIndex % CHUNK_SIZE(T);
456 return m_pChunks[uiChunkIndex][uiChunkOffset];
459template <
typename T,
bool Construct>
462 PL_ASSERT_DEBUG(uiIndex < m_uiCount,
"The deque has {0} elements. Cannot access element {1}.", m_uiCount, uiIndex);
464 const plUInt32 uiRealIndex = m_uiFirstElement + uiIndex;
466 const plUInt32 uiChunkIndex = uiRealIndex / CHUNK_SIZE(T);
467 const plUInt32 uiChunkOffset = uiRealIndex % CHUNK_SIZE(T);
469 return m_pChunks[uiChunkIndex][uiChunkOffset];
472template <
typename T,
bool Construct>
475 RESERVE(m_uiCount + 1);
478 T* pElement = &ElementAt(m_uiCount - 1);
488template <
typename T,
bool Construct>
491 RESERVE(m_uiCount + 1);
494 T* pElement = &ElementAt(m_uiCount - 1);
502template <
typename T,
bool Construct>
505 static_assert(Construct,
"This function is not supported on Deques that do not construct their data.");
507 RESERVE(m_uiCount + 1);
513template <
typename T,
bool Construct>
516 static_assert(Construct,
"This function is not supported on Deques that do not construct their data.");
518 RESERVE(m_uiCount + 1);
524template <
typename T,
bool Construct>
527 PL_ASSERT_DEV(uiElements <= GetCount(),
"Cannot remove {0} elements, the deque only contains {1} elements.", uiElements, GetCount());
529 for (plUInt32 i = 0; i < uiElements; ++i)
538 REDUCE_SIZE(uiElements);
541template <
typename T,
bool Construct>
544 static_assert(Construct,
"This function is not supported on Deques that do not construct their data.");
546 RESERVE(m_uiCount + 1);
553template <
typename T,
bool Construct>
556 static_assert(Construct,
"This function is not supported on Deques that do not construct their data.");
558 RESERVE(m_uiCount + 1);
565template <
typename T,
bool Construct>
568 RESERVE(m_uiCount + 1);
572 T* pElement = &ElementAt(0);
580template <
typename T,
bool Construct>
583 PL_ASSERT_DEV(uiElements <= GetCount(),
"Cannot remove {0} elements, the deque only contains {1} elements.", uiElements, GetCount());
585 for (plUInt32 i = 0; i < uiElements; ++i)
597 REDUCE_SIZE(uiElements);
600template <
typename T,
bool Construct>
603 return m_uiCount == 0;
606template <
typename T,
bool Construct>
612template <
typename T,
bool Construct>
615 return operator[](0);
618template <
typename T,
bool Construct>
621 return operator[](0);
624template <
typename T,
bool Construct>
627 return operator[](m_uiCount - 1);
630template <
typename T,
bool Construct>
633 return operator[](m_uiCount - 1);
636template <
typename T,
bool Construct>
639 return IndexOf(value) != plInvalidIndex;
642template <
typename T,
bool Construct>
645 for (plUInt32 i = uiStartIndex; i < m_uiCount; ++i)
651 return plInvalidIndex;
654template <
typename T,
bool Construct>
657 for (plUInt32 i =
plMath::Min(uiStartIndex, m_uiCount); i-- > 0;)
662 return plInvalidIndex;
665template <
typename T,
bool Construct>
668 static_assert(Construct,
"This function is not supported on Deques that do not construct their data.");
670 PL_ASSERT_DEV(uiIndex < m_uiCount,
"Cannot remove element {0}, the deque only contains {1} elements.", uiIndex, m_uiCount);
672 if (uiIndex + 1 < m_uiCount)
673 operator[](uiIndex) = PeekBack();
678template <
typename T,
bool Construct>
681 const plUInt32 uiCurFirstChunk = GetFirstUsedChunk();
682 const plUInt32 uiRemainingChunks = m_uiChunks - uiCurFirstChunk;
683 const plUInt32 uiNewFirstChunk = uiCurFirstChunk - uiChunkDiff;
686 for (plUInt32 front = 0; front < uiRemainingChunks; ++front)
687 plMath::Swap(m_pChunks[uiNewFirstChunk + front], m_pChunks[front + uiCurFirstChunk]);
690 PL_ASSERT_DEBUG(m_uiFirstElement > uiChunkDiff * CHUNK_SIZE(T),
"");
693 m_uiFirstElement -= uiChunkDiff * CHUNK_SIZE(T);
696template <
typename T,
bool Construct>
699 const plUInt32 uiCurFirstChunk = GetFirstUsedChunk();
700 const plUInt32 uiLastChunk = (m_uiCount == 0) ? (m_uiFirstElement / CHUNK_SIZE(T)) : ((m_uiFirstElement + m_uiCount - 1) / CHUNK_SIZE(T));
701 const plUInt32 uiCopyChunks = (uiLastChunk - uiCurFirstChunk) + 1;
704 for (plUInt32 i = 0; i < uiCopyChunks; ++i)
705 plMath::Swap(m_pChunks[uiLastChunk - i], m_pChunks[uiLastChunk + uiChunkDiff - i]);
708 m_uiFirstElement += uiChunkDiff * CHUNK_SIZE(T);
711template <
typename T,
bool Construct>
714 return m_uiFirstElement / CHUNK_SIZE(T);
717template <
typename T,
bool Construct>
721 return GetFirstUsedChunk();
723 return (m_uiFirstElement + uiAtSize - 1) / CHUNK_SIZE(T);
726template <
typename T,
bool Construct>
729 return GetLastUsedChunk(m_uiCount);
732template <
typename T,
bool Construct>
738 return GetLastUsedChunk(uiAtSize) - GetFirstUsedChunk() + 1;
741template <
typename T,
bool Construct>
744 if (m_uiAllocatedChunks <= uiMaxChunks)
748 for (plUInt32 i = GetLastUsedChunk() + 1; i < m_uiChunks; ++i)
752 --m_uiAllocatedChunks;
753 PL_DELETE_RAW_BUFFER(m_pAllocator, m_pChunks[i]);
755 if (m_uiAllocatedChunks <= uiMaxChunks)
761 const plUInt32 uiFirstChunk = GetFirstUsedChunk();
763 for (plUInt32 i = 0; i < uiFirstChunk; ++i)
767 --m_uiAllocatedChunks;
768 PL_DELETE_RAW_BUFFER(m_pAllocator, m_pChunks[i]);
770 if (m_uiAllocatedChunks <= uiMaxChunks)
776template <
typename T,
bool Construct>
779 m_iReduceSizeTimer = CHUNK_SIZE(T) * 8;
782template <
typename T,
bool Construct>
785 m_iReduceSizeTimer -= iReduction;
788 if (m_iReduceSizeTimer > 0)
791 ResetReduceSizeCounter();
796 const plUInt32 uiMaxChunks = (m_uiMaxCount / CHUNK_SIZE(T)) + 3;
798 PL_ASSERT_DEBUG(uiMaxChunks >= GetRequiredChunks(m_uiCount),
"Implementation Error.");
800 DeallocateUnusedChunks(uiMaxChunks);
805 m_uiMaxCount =
plMath::Max(m_uiCount, (m_uiMaxCount / 2) + (m_uiCount / 2));
808 CompactIndexArray(uiMaxChunks);
811template <
typename T,
bool Construct>
814 return m_uiChunks * CHUNK_SIZE(T) - m_uiFirstElement;
817template <
typename T,
bool Construct>
821 const plUInt32 uiCurFirstChunk = GetFirstUsedChunk();
824 for (plUInt32 i = 0; i < uiCurFirstChunk; ++i)
828 T* pChunk = m_pChunks[i];
829 m_pChunks[i] =
nullptr;
834 const plUInt32 uiCurLastChunk = GetLastUsedChunk();
837 for (plUInt32 i = m_uiChunks - 1; i > uiCurLastChunk; --i)
841 T* pChunk = m_pChunks[i];
842 m_pChunks[i] =
nullptr;
848 ResetReduceSizeCounter();
849 ++m_uiAllocatedChunks;
850 return PL_NEW_RAW_BUFFER(m_pAllocator, T, CHUNK_SIZE(T));
853template <
typename T,
bool Construct>
856 PL_ASSERT_DEBUG(uiIndex < m_uiCount,
"");
858 const plUInt32 uiRealIndex = m_uiFirstElement + uiIndex;
860 const plUInt32 uiChunkIndex = uiRealIndex / CHUNK_SIZE(T);
861 const plUInt32 uiChunkOffset = uiRealIndex % CHUNK_SIZE(T);
863 PL_ASSERT_DEBUG(uiChunkIndex < m_uiChunks,
"");
865 if (m_pChunks[uiChunkIndex] ==
nullptr)
866 m_pChunks[uiChunkIndex] = GetUnusedChunk();
868 return m_pChunks[uiChunkIndex][uiChunkOffset];
871template <
typename T,
bool Construct>
877 while (m_uiAllocatedChunks > 0)
881 --m_uiAllocatedChunks;
882 PL_DELETE_RAW_BUFFER(m_pAllocator, m_pChunks[i]);
888 PL_DELETE_RAW_BUFFER(m_pAllocator, m_pChunks);
890 Constructor(m_pAllocator);
893template <
typename T,
bool Construct>
896 static_assert(Construct,
"This function is not supported on Deques that do not construct their data.");
898 PL_ASSERT_DEV(uiIndex < m_uiCount,
"Out of bounds access. Array has {0} elements, trying to remove element at index {1}.", m_uiCount, uiIndex);
900 for (plUInt32 i = uiIndex + 1; i < m_uiCount; ++i)
908template <
typename T,
bool Construct>
911 static_assert(Construct,
"This function is not supported on Deques that do not construct their data.");
913 plUInt32 uiIndex = IndexOf(value);
915 if (uiIndex == plInvalidIndex)
918 RemoveAtAndCopy(uiIndex);
922template <
typename T,
bool Construct>
925 static_assert(Construct,
"This function is not supported on Deques that do not construct their data.");
927 plUInt32 uiIndex = IndexOf(value);
929 if (uiIndex == plInvalidIndex)
932 RemoveAtAndSwap(uiIndex);
936template <
typename T,
bool Construct>
939 static_assert(Construct,
"This function is not supported on Deques that do not construct their data.");
942 PL_ASSERT_DEV(uiIndex <= m_uiCount,
"The deque has {0} elements. Cannot insert an element at index {1}.", m_uiCount, uiIndex);
946 for (plUInt32 i = m_uiCount - 1; i > uiIndex; --i)
954template <
typename T,
bool Construct>
955template <
typename Comparer>
962template <
typename T,
bool Construct>
969template <
typename T,
bool Construct>
972 if (m_pChunks ==
nullptr)
975 plUInt64 res = m_uiChunks *
sizeof(T*);
977 for (plUInt32 i = 0; i < m_uiChunks; ++i)
979 if (m_pChunks[i] !=
nullptr)
981 res += (plUInt64)(CHUNK_SIZE(T)) * (plUInt64)
sizeof(T);
992template <
typename T,
typename A,
bool Construct>
998template <
typename T,
typename A,
bool Construct>
1004template <
typename T,
typename A,
bool Construct>
1006 :
plDequeBase<T, Construct>(other, A::GetAllocator())
1010template <
typename T,
typename A,
bool Construct>
1012 :
plDequeBase<T, Construct>(std::move(other), other.GetAllocator())
1016template <
typename T,
typename A,
bool Construct>
1018 :
plDequeBase<T, Construct>(other, A::GetAllocator())
1022template <
typename T,
typename A,
bool Construct>
1024 :
plDequeBase<T, Construct>(std::move(other), other.GetAllocator())
1028template <
typename T,
typename A,
bool Construct>
1034template <
typename T,
typename A,
bool Construct>
1040template <
typename T,
typename A,
bool Construct>
1046template <
typename T,
typename A,
bool Construct>
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
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
static void CopyConstruct(Destination *pDestination, const Source ©, size_t uiCount=1)
Constructs uiCount objects of type T in a raw buffer at pDestination, by creating uiCount copies of c...
static bool IsEqual(const T *a, const T *b, size_t uiCount=1)
Tests if objects of type T from pSource and pDestination are equal.
static void Construct(T *pDestination, size_t uiCount=1)
Constructs uiCount objects of type T in a raw buffer at pDestination.
static void Copy(T *pDestination, const T *pSource, size_t uiCount=1)
Copies objects of type T from pSource to pDestination.
static void MoveConstruct(T *pDestination, T &&source)
Constructs an object of type T in a raw buffer at pDestination, by using move construction from sourc...
static void CopyOverlapped(T *pDestination, const T *pSource, size_t uiCount=1)
Copies objects of type T from pSource to pDestination.
static void ZeroFill(T *pDestination, size_t uiCount=1)
Zeros every byte in the provided memory buffer.
static void Destruct(T *pDestination, size_t uiCount=1)
Destructs uiCount objects of type T at pDestination.
static void QuickSort(Container &inout_container, const Comparer &comparer=Comparer())
Sorts the elements in container using a in-place quick sort implementation (not stable).
Definition Sorting_inl.h:3
constexpr PL_ALWAYS_INLINE T Min(T f1, T f2)
Returns the smaller value, f1 or f2.
Definition Math_inl.h:27
PL_ALWAYS_INLINE void Swap(T &ref_f1, T &ref_f2)
Swaps the values in the two variables f1 and f2.
Definition Math_inl.h:224
constexpr PL_ALWAYS_INLINE T Max(T f1, T f2)
Returns the greater value, f1 or f2.
Definition Math_inl.h:39
A comparer object is used in sorting algorithms to compare to objects of the same type.
Definition Comparer.h:7
If there is an % operator which takes a TypeIsPod and returns a CompileTimeTrueType T is Pod....
Definition TypeTraits.h:43