14template<
typename ContainerType,
typename ElementType,
typename SizeType>
76 return Container[
Index];
81 return &Container[
Index];
87 return Container.IsValidIndex(
Index);
105 Index = Container.Num();
111 Container.RemoveAt(
Index);
120 ContainerType& Container;
133template<
typename T,
typename AllocatorT = FDefaultAllocator>
142 Allocator::NeedsElementType,
144 typename Allocator::ForAnyElementType
147 typedef std::make_signed_t<typename Allocator::SizeType>
IndexType;
149 typedef std::make_unsigned_t<typename Allocator::SizeType>
SizeType;
160 typedef std::make_unsigned_t<typename Allocator::SizeType> StorageModuloType;
201 AllocatorInstance.MoveToEmpty(
Other.AllocatorInstance);
232 return AfterBack == Front;
238 return AfterBack - Front;
244 return static_cast<SizeType>(IndexMask + 1);
338 ConditionalIncrementCapacity();
343 SlackTrackerNumChanged();
390 SlackTrackerNumChanged();
450 ConditionalIncrementCapacity();
455 SlackTrackerNumChanged();
480 return (*
this)[
Num() - 1];
486 return (*
this)[
Num() - 1];
499 DestructRange(Front, Front +
PopCount);
502 SlackTrackerNumChanged();
524 DestructRange(AfterBack -
PopCount, AfterBack);
527 SlackTrackerNumChanged();
548 ShiftLastToFirst(Front, Front +
Index, -1);
561 ShiftLastToFirst(AfterBack - 1, Front +
Index, 1);
611 return GetStorage()[(Front +
Index) & IndexMask];
617 return GetStorage()[(Front +
Index) & IndexMask];
655 const StorageModuloType
MaskedFront = Front & IndexMask;
689 template <
typename PredicateType>
692 if (AfterBack == Front)
713 while (ReadIndex != AfterBack)
715 if (!Predicate(Data[ReadIndex & IndexMask]))
717 if (NeedsDestructElements())
721 ::new ((
void*)&Data[WriteIndex & IndexMask])
ElementType(
MoveTemp(Data[ReadIndex & IndexMask]));
726 AfterBack = WriteIndex;
729 if (NeedsDestructElements())
731 while (WriteIndex != ReadIndex)
737 SlackTrackerNumChanged();
741 template <
typename OtherAllocator>
759 template <
typename OtherAllocator>
762 return !(*
this ==
Other);
795 [[
nodiscard]]
static constexpr bool NeedsDestructElements()
797 return !std::is_trivially_destructible_v<T>;
819 const StorageModuloType
MaskedFront = Front & IndexMask;
825 StorageModuloType WriteIndex = 0;
831 for (StorageModuloType ReadIndex = 0; ReadIndex <
MaskedAfterBack; ++ReadIndex)
839 StorageModuloType WriteIndex = 0;
853 AllocatorResizeAllocation(AllocatorInstance, 0,
NewCapacity);
874 void SlackTrackerNumChanged()
876#if UE_ENABLE_ARRAY_SLACK_TRACKING
879 AllocatorInstance.SlackTrackerLogNum(
Num());
932 void ConditionalIncrementCapacity()
952 if (NeedsDestructElements())
981 return const_cast<TRingBuffer*
>(
this)->GetStorage();
987 return (
ElementType*)AllocatorInstance.GetAllocation();
993 if (Allocator::RequireRangeCheck)
1002 if (Allocator::RequireRangeCheck)
1021 StorageModuloType IndexMask;
1027 StorageModuloType
Front;
1036 StorageModuloType AfterBack;
1039#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_4
#define check(expr)
Definition AssertionMacros.h:314
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
@ INDEX_NONE
Definition CoreMiscDefines.h:150
FORCEINLINE constexpr void DestructItem(ElementType *Element)
Definition MemoryOps.h:56
FORCEINLINE constexpr void DestructItems(ElementType *Element, SizeType Count)
Definition MemoryOps.h:81
FORCEINLINE void MoveConstructItems(void *Dest, const ElementType *Source, SizeType Count)
Definition MemoryOps.h:242
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
const bool
Definition NetworkReplayStreaming.h:178
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTempIfPossible(T &&Obj) noexcept
Definition UnrealTemplate.h:538
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint32 Offset
Definition VulkanMemory.cpp:4033
Definition ArrayView.h:139
Definition RingBuffer.h:16
void SetToEnd()
Definition RingBuffer.h:103
TRingBufferIterator & operator--()
Definition RingBuffer.h:38
SizeType GetIndex() const
Definition RingBuffer.h:91
TRingBufferIterator operator--(int)
Definition RingBuffer.h:43
TRingBufferIterator & operator-=(SizeType Offset)
Definition RingBuffer.h:63
void Reset()
Definition RingBuffer.h:97
UE_FORCEINLINE_HINT bool operator==(const TRingBufferIterator &Rhs) const
Definition RingBuffer.h:115
TRingBufferIterator operator-(SizeType Offset) const
Definition RingBuffer.h:68
TRingBufferIterator operator+(SizeType Offset) const
Definition RingBuffer.h:57
void RemoveCurrent()
Definition RingBuffer.h:109
UE_FORCEINLINE_HINT ElementType * operator->() const
Definition RingBuffer.h:79
TRingBufferIterator & operator++()
Definition RingBuffer.h:25
TRingBufferIterator operator++(int)
Definition RingBuffer.h:30
TRingBufferIterator & operator+=(SizeType Offset)
Definition RingBuffer.h:51
UE_FORCEINLINE_HINT bool operator!=(const TRingBufferIterator &Rhs) const
Definition RingBuffer.h:116
UE_FORCEINLINE_HINT ElementType & operator*() const
Definition RingBuffer.h:74
TRingBufferIterator(ContainerType &InContainer, SizeType StartIndex=0)
Definition RingBuffer.h:18
Definition RingBuffer.h:135
void PopFrontNoCheck(SizeType PopCount=1)
Definition RingBuffer.h:497
TIterator end()
Definition RingBuffer.h:577
TIterator begin()
Definition RingBuffer.h:565
friend class FRingBufferTest
Definition RingBuffer.h:1008
SizeType RemoveAll(PredicateType Predicate)
Definition RingBuffer.h:690
void Trim()
Definition RingBuffer.h:259
ElementType & First()
Definition RingBuffer.h:466
TRingBufferIterator< const TRingBuffer, const ElementType, typename Allocator::SizeType > TConstIterator
Definition RingBuffer.h:152
SIZE_T GetAllocatedSize(void) const
Definition RingBuffer.h:789
ElementType PopFrontValue()
Definition RingBuffer.h:506
void PopFront(SizeType PopCount=1)
Definition RingBuffer.h:490
const ElementType & Last() const
Definition RingBuffer.h:484
TRingBuffer & operator=(const TRingBuffer &Other)
Definition RingBuffer.h:214
void Pop(SizeType PopCount=1)
Definition RingBuffer.h:515
ElementType & Last()
Definition RingBuffer.h:478
T ElementType
Definition RingBuffer.h:138
TConstIterator end() const
Definition RingBuffer.h:583
TArrayView< T > Compact()
Definition RingBuffer.h:769
std::make_unsigned_t< typename Allocator::SizeType > SizeType
Definition RingBuffer.h:149
TRingBufferIterator< TRingBuffer, ElementType, typename Allocator::SizeType > TIterator
Definition RingBuffer.h:151
void Empty()
Definition RingBuffer.h:184
void Reset()
Definition RingBuffer.h:266
IndexType Num() const
Definition RingBuffer.h:236
ElementType & Add_GetRef(const ElementType &Element)
Definition RingBuffer.h:308
IndexType AddUninitialized()
Definition RingBuffer.h:336
TRingBuffer(SizeType InitialCapacity)
Definition RingBuffer.h:172
void MoveAppendRange(ElementType *OtherData, SizeType OtherNum)
Definition RingBuffer.h:357
void ShiftIndexToBack(IndexType Index)
Definition RingBuffer.h:552
IndexType AddFrontUninitialized()
Definition RingBuffer.h:448
IndexType AddFront(const ElementType &Element)
Definition RingBuffer.h:411
bool operator!=(const TRingBuffer< ElementType, OtherAllocator > &Other) const
Definition RingBuffer.h:760
IndexType Max() const
Definition RingBuffer.h:242
TRingBuffer & operator=(TRingBuffer &&Other)
Definition RingBuffer.h:194
ElementType PopValue()
Definition RingBuffer.h:531
IndexType EmplaceFront(ArgsType &&... Args)
Definition RingBuffer.h:430
TRingBuffer()
Definition RingBuffer.h:164
void ShiftIndexToFront(IndexType Index)
Definition RingBuffer.h:540
bool IsEmpty() const
Definition RingBuffer.h:230
AllocatorT Allocator
Definition RingBuffer.h:140
void PopNoCheck(SizeType PopCount=1)
Definition RingBuffer.h:522
ElementType & Add_GetRef(ElementType &&Element)
Definition RingBuffer.h:291
bool IsValidIndex(IndexType Index) const
Definition RingBuffer.h:589
ElementType & Emplace_GetRef(ArgsType &&... Args)
Definition RingBuffer.h:328
const ElementType & operator[](IndexType Index) const
Definition RingBuffer.h:602
ElementType & AddFront_GetRef(const ElementType &Element)
Definition RingBuffer.h:420
~TRingBuffer()
Definition RingBuffer.h:224
bool operator==(const TRingBuffer< ElementType, OtherAllocator > &Other) const
Definition RingBuffer.h:742
TConstIterator begin() const
Definition RingBuffer.h:571
TRingBuffer(std::initializer_list< ElementType > InitList)
Definition RingBuffer.h:179
TRingBuffer(TRingBuffer &&Other)
Definition RingBuffer.h:188
SizeType Remove(const ElementType &Item)
Definition RingBuffer.h:678
ElementType & GetAtIndexNoCheck(IndexType Index)
Definition RingBuffer.h:609
ElementType & AddUninitialized_GetRef()
Definition RingBuffer.h:348
ElementType & EmplaceFront_GetRef(ArgsType &&... Args)
Definition RingBuffer.h:440
void Reserve(SizeType RequiredCapacity)
Definition RingBuffer.h:248
void RemoveAt(IndexType Index)
Definition RingBuffer.h:651
ElementType & operator[](IndexType Index)
Definition RingBuffer.h:595
const ElementType & GetAtIndexNoCheck(IndexType Index) const
Definition RingBuffer.h:615
IndexType ConvertPointerToIndex(const ElementType *Ptr) const
Definition RingBuffer.h:621
std::conditional_t< Allocator::NeedsElementType, typename Allocator::template ForElementType< ElementType >, typename Allocator::ForAnyElementType > ElementAllocatorType
Definition RingBuffer.h:145
ElementType & AddFrontUninitialized_GetRef()
Definition RingBuffer.h:460
void Empty(SizeType Capacity=0)
Definition RingBuffer.h:274
IndexType Emplace(ArgsType &&... Args)
Definition RingBuffer.h:318
TRingBuffer(const TRingBuffer &Other)
Definition RingBuffer.h:208
std::make_signed_t< typename Allocator::SizeType > IndexType
Definition RingBuffer.h:147
IndexType Add(const ElementType &Element)
Definition RingBuffer.h:299
const ElementType & First() const
Definition RingBuffer.h:472
IndexType Add(ElementType &&Element)
Definition RingBuffer.h:282
ElementType & AddFront_GetRef(ElementType &&Element)
Definition RingBuffer.h:403
IndexType AddFront(ElementType &&Element)
Definition RingBuffer.h:394
U16 Index
Definition radfft.cpp:71
Definition ContainerAllocationPolicies.h:256
Definition NumericLimits.h:41