37template<
typename ElementType>
45 ChunkList[0]->Initialize(BlocksPerChunk * BlockSize);
57 ChunkList[0]->Initialize(BlocksPerChunk * BlockSize);
66 return (ListIndex >= 0 && ListIndex < (
int32)Lists.
Num() && Lists[ListIndex].CurBlock !=
nullptr );
82 NewList.Blocks.Add( AllocateNewBlockMemory() );
95 Insert_Internal(Lists[ListIndex],
Value);
104 Insert_Internal(List,
Value);
114 SetValues_Internal(Lists[ListIndex], Values);
124 SetValues_Internal(List, Values);
141 FList& List = Lists[ListIndex];
142 Clear_Internal(List);
152 const FList& List = Lists[ListIndex];
153 return FMath::Max(0, List.Blocks.Num()-1)*BlockSize + List.CurIndex;
167 template<
typename FuncType>
171 const FList& List = Lists[ListIndex];
172 if ( List.CurBlock !=
nullptr )
174 int32 N = List.Blocks.Num();
177 const ElementType* Elements = List.Blocks[
BlockIndex];
178 const ElementType*
EndElement = (
BlockIndex == N-1) ? (Elements + List.CurIndex) : (Elements + BlockSize);
191 template<
typename FuncType>
195 const FList& List = Lists[ListIndex];
196 if (List.CurBlock !=
nullptr)
198 int32 N = List.Blocks.Num();
201 const ElementType* Elements = List.Blocks[
BlockIndex];
202 const ElementType*
EndElement = (
BlockIndex == N - 1) ? (Elements + List.CurIndex) : (Elements + BlockSize);
222 int BlocksPerChunk = 256;
227 int BlocksAllocated = 0;
240 ElementType* CurBlock =
nullptr;
244 TDynamicVector<FList> Lists;
247 void Insert_Internal(FList& List, ElementType
Value)
249 if (
List.CurIndex == BlockSize)
251 List.Blocks.Add( AllocateNewBlockMemory() );
261 if (
List.CurIndex != 0)
263 Clear_Internal(List);
265 for (
int32 k = 0; k < N; ++k)
268 if (
List.CurIndex == BlockSize)
270 List.Blocks.Add( AllocateNewBlockMemory() );
274 List.CurBlock[
List.CurIndex++] = Values[k];
279 void Clear_Internal(FList& List)
281 for (
int32 k = 1; k <
List.Blocks.Num(); ++k)
283 FreeBlockMemory(
List.Blocks[k]);
285 List.Blocks.SetNum(1);
291 ElementType* AllocateNewBlockMemory()
295 if (FreeList.
Num() > 0)
297 return FreeList.
Pop();
300 FChunk* LastChunk = ChunkList.
Last().Get();
301 if (LastChunk->BlocksAllocated == BlocksPerChunk)
304 LastChunk = ChunkList.
Last().Get();
305 LastChunk->Initialize( BlocksPerChunk * BlockSize );
308 ElementType*
BlockBuffer = LastChunk->GetBlockBufferPtr(LastChunk->BlocksAllocated * BlockSize);
309 LastChunk->BlocksAllocated++;
314 void FreeBlockMemory(ElementType*
Block)
324template<
typename ElementType>
328 FList& List = Lists[ListIndex];
329 if ( List.CurBlock !=
nullptr )
331 int32 N = List.Blocks.Num();
334 ElementType* Elements = List.Blocks[
BlockIndex];
338 if (Elements[k] ==
Value)
343 if (k == List.CurIndex-1)
351 Swap(Elements[k], Elements[List.CurIndex-1]);
357 if (List.CurIndex == 0)
361 Swap(Elements[k], List.CurBlock[List.CurIndex-1]);
366 if (List.CurIndex == 0 && List.Blocks.Num() > 1)
368 FreeBlockMemory(List.CurBlock);
370 List.CurBlock = List.Blocks.Last();
371 List.CurIndex = BlockSize;
385template<
typename ElementType>
389 const FList& List = Lists[ListIndex];
390 int32 N = List.Blocks.Num();
393 const ElementType* Elements = List.Blocks[
BlockIndex];
394 const ElementType*
EndElement = (
BlockIndex == N-1) ? (Elements + List.CurIndex) : (Elements + BlockSize);
397 if ((*Elements++) ==
Value)
#define checkSlow(expr)
Definition AssertionMacros.h:332
#define check(expr)
Definition AssertionMacros.h:314
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE::FPlatformRecursiveMutex FCriticalSection
Definition CriticalSection.h:53
@ Stop
Definition PrecomputedVolumetricLightmapStreaming.cpp:26
FRWLock Lock
Definition UnversionedPropertySerialization.cpp:921
uint32 Offset
Definition VulkanMemory.cpp:4033
uint32 Size
Definition VulkanMemory.cpp:4034
int BlockIndex
Definition binka_ue_decode_test.cpp:38
Definition Archive.h:1208
Definition ScopeLock.h:141
UE_REWRITE SizeType Num() const
Definition Array.h:1144
UE_NODEBUG UE_FORCEINLINE_HINT ElementType & Last(SizeType IndexFromTheEnd=0) UE_LIFETIMEBOUND
Definition Array.h:1263
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
ElementType Pop(EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
Definition Array.h:1196
void InsertAt(const Type &Data, unsigned int Index)
Definition DynamicVector.h:747
size_t Num() const
Definition DynamicVector.h:147
@ List
Definition ITypedTableView.h:38
Definition AdvancedWidgetsModule.cpp:13
static constexpr UE_FORCEINLINE_HINT T Clamp(const T X, const T MinValue, const T MaxValue)
Definition UnrealMathUtility.h:592
Definition SparseListSet.h:71
void * ListRef
Definition SparseListSet.h:72
Definition SparseListSet.h:39
TSparseListSet()
Definition SparseListSet.h:42
bool Remove(int32 ListIndex, ElementType Value)
Definition SparseListSet.h:325
void SetValues(int32 ListIndex, const TArray< ElementType > &Values)
Definition SparseListSet.h:111
TSparseListSet(int BlockSizeIn, int BlocksPerChunkIn)
Definition SparseListSet.h:52
bool EnumerateEarlyOut(int32 ListIndex, FuncType ApplyFunc) const
Definition SparseListSet.h:192
void Insert(FListHandle ListHandle, ElementType Value)
Definition SparseListSet.h:101
void Clear(int32 ListIndex)
Definition SparseListSet.h:138
FListHandle AllocateAt(int32 ListIndex)
Definition SparseListSet.h:79
void Insert(int32 ListIndex, ElementType Value)
Definition SparseListSet.h:92
bool IsAllocated(int32 ListIndex) const
Definition SparseListSet.h:64
int32 GetCount(int32 ListIndex) const
Definition SparseListSet.h:149
bool Contains(int32 ListIndex, ElementType Value) const
Definition SparseListSet.h:386
void SetValues(FListHandle ListHandle, const TArray< ElementType > &Values)
Definition SparseListSet.h:121
void Enumerate(int32 ListIndex, FuncType Func) const
Definition SparseListSet.h:168