UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator > Class Template Reference
+ Inheritance diagram for UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >:

Classes

class  TIterator
 
class  TKeyIterator
 

Public Types

using ElementType = InElementType
 
using KeyFuncsType = KeyFuncs
 
using TConstIterator = TBaseIterator< true >
 
using TConstKeyIterator = TBaseKeyIterator< true >
 
using IntrusiveUnsetOptionalStateType = UE_TCOMPACT_SET
 
using TRangedForIterator = ElementType *
 
using TRangedForConstIterator = const ElementType *
 
- Public Types inherited from TCompactSetBase< Allocator::template ElementAllocator< sizeof(InElementType)> >
using AllocatorType = Allocator
 
using SizeType = typename AllocatorType::SizeType
 

Public Member Functions

UE_FORCEINLINE_HINT constexpr UE_TCOMPACT_SET ()=default
 
consteval UE_TCOMPACT_SET (EConstEval)
 
UE_FORCEINLINE_HINT UE_TCOMPACT_SET (const UE_TCOMPACT_SET &Copy)
 
UE_FORCEINLINE_HINT UE_TCOMPACT_SET (TArrayView< const ElementType > InArrayView)
 
UE_FORCEINLINE_HINT UE_TCOMPACT_SET (TArray< ElementType > &&InArray)
 
 UE_TCOMPACT_SET (std::initializer_list< ElementType > InitList)
 
 UE_TCOMPACT_SET (UE_TCOMPACT_SET &&Other)
 
template<typename OtherAllocator >
 UE_TCOMPACT_SET (UE_TCOMPACT_SET< ElementType, KeyFuncs, OtherAllocator > &&Other)
 
template<typename OtherAllocator >
 UE_TCOMPACT_SET (const UE_TCOMPACT_SET< ElementType, KeyFuncs, OtherAllocator > &Other)
 
UE_FORCEINLINE_HINT ~UE_TCOMPACT_SET ()
 
 UE_TCOMPACT_SET (FIntrusiveUnsetOptionalState Tag)
 
UE_TCOMPACT_SEToperator= (const UE_TCOMPACT_SET &Copy)
 
UE_TCOMPACT_SEToperator= (UE_TCOMPACT_SET &&Other)
 
template<typename OtherAllocator >
UE_TCOMPACT_SEToperator= (UE_TCOMPACT_SET< ElementType, KeyFuncs, OtherAllocator > &&Other)
 
template<typename OtherAllocator >
UE_TCOMPACT_SEToperator= (const UE_TCOMPACT_SET< ElementType, KeyFuncs, OtherAllocator > &Other)
 
UE_TCOMPACT_SEToperator= (std::initializer_list< ElementType > InitList)
 
template<typename OtherKeyFuncs , typename AliasElementType = ElementType>
UE_TCOMPACT_SEToperator= (UE_TCOMPACT_SET< typename TContainerElementTypeCompatibility< ElementType >::CopyFromOtherType, OtherKeyFuncs, Allocator > &&Other)
 
template<typename OtherKeyFuncs , typename OtherAllocator , typename AliasElementType = ElementType>
UE_TCOMPACT_SEToperator= (const UE_TCOMPACT_SET< typename TContainerElementTypeCompatibility< ElementType >::CopyFromOtherType, OtherKeyFuncs, OtherAllocator > &Other)
 
void Empty (int32 ExpectedNumElements=0)
 
void Reset ()
 
void Shrink ()
 
void Reserve (int32 Number)
 
void Compact ()
 
void CompactStable ()
 
void SortFreeList ()
 
void Relax ()
 
UE_FORCEINLINE_HINT SIZE_T GetAllocatedSize () const
 
void CountBytes (FArchive &Ar) const
 
UE_FORCEINLINE_HINT bool IsValidId (FSetElementId Id) const
 
UE_FORCEINLINE_HINT void CheckInvariants () const
 
void RangeCheck (FSetElementId Id) const
 
ElementTypeoperator[] (FSetElementId Id)
 
const ElementTypeoperator[] (FSetElementId Id) const
 
ElementTypeGet (FSetElementId Id)
 
const ElementTypeGet (FSetElementId Id) const
 
UE_FORCEINLINE_HINT FSetElementId Add (const ElementType &InElement, bool *bIsAlreadyInSetPtr=nullptr)
 
UE_FORCEINLINE_HINT FSetElementId Add (ElementType &&InElement, bool *bIsAlreadyInSetPtr=nullptr)
 
UE_FORCEINLINE_HINT FSetElementId AddByHash (uint32 KeyHash, const ElementType &InElement, bool *bIsAlreadyInSetPtr=nullptr)
 
UE_FORCEINLINE_HINT FSetElementId AddByHash (uint32 KeyHash, ElementType &&InElement, bool *bIsAlreadyInSetPtr=nullptr)
 
template<typename ArgType = ElementType>
UE_FORCEINLINE_HINT FSetElementId Emplace (ArgType &&Arg, bool *bIsAlreadyInSetPtr=nullptr)
 
template<typename... ArgTypes>
TPair< FSetElementId, boolEmplace (EInPlace, ArgTypes &&... InArgs)
 
template<typename ArgType = ElementType>
UE_FORCEINLINE_HINT FSetElementId EmplaceByHash (uint32 KeyHash, ArgType &&Arg, bool *bIsAlreadyInSetPtr=nullptr)
 
template<typename... ArgTypes>
TPair< FSetElementId, boolEmplaceByHash (EInPlace, uint32 KeyHash, ArgTypes &&... InArgs)
 
UE_FORCEINLINE_HINT ElementTypeFindOrAdd (const InElementType &InElement, bool *bIsAlreadyInSetPtr=nullptr)
 
UE_FORCEINLINE_HINT ElementTypeFindOrAdd (InElementType &&InElement, bool *bIsAlreadyInSetPtr=nullptr)
 
template<typename ElementReferenceType >
ElementTypeFindOrAddByHash (uint32 KeyHash, ElementReferenceType &&InElement, bool *bIsAlreadyInSetPtr=nullptr)
 
void Append (TArrayView< const ElementType > InElements)
 
template<typename ArrayAllocator >
void Append (TArray< ElementType, ArrayAllocator > &&InElements)
 
template<typename OtherAllocator >
void Append (const UE_TCOMPACT_SET< ElementType, KeyFuncs, OtherAllocator > &OtherSet)
 
template<typename OtherAllocator >
void Append (UE_TCOMPACT_SET< ElementType, KeyFuncs, OtherAllocator > &&OtherSet)
 
void Append (std::initializer_list< ElementType > InitList)
 
template<typename OtherKeyFuncs , typename OtherAllocator , typename AliasElementType = ElementType>
void Append (const UE_TCOMPACT_SET< typename TContainerElementTypeCompatibility< ElementType >::CopyFromOtherType, OtherKeyFuncs, OtherAllocator > &OtherSet)
 
template<typename OtherKeyFuncs , typename AliasElementType = ElementType>
void Append (UE_TCOMPACT_SET< typename TContainerElementTypeCompatibility< ElementType >::CopyFromOtherType, OtherKeyFuncs, Allocator > &&OtherSet)
 
ElementTypeFindArbitraryElement ()
 
const ElementTypeFindArbitraryElement () const
 
FSetElementId FindId (KeyInitType Key) const
 
template<typename ComparableKey >
FSetElementId FindIdByHash (uint32 KeyHash, const ComparableKey &Key) const
 
ElementTypeFind (KeyInitType Key)
 
UE_FORCEINLINE_HINT const ElementTypeFind (KeyInitType Key) const
 
template<typename ComparableKey >
ElementTypeFindByHash (uint32 KeyHash, const ComparableKey &Key)
 
template<typename ComparableKey >
const ElementTypeFindByHash (uint32 KeyHash, const ComparableKey &Key) const
 
void Remove (FSetElementId ElementId)
 
int32 Remove (KeyInitType Key)
 
void RemoveStable (FSetElementId ElementId)
 
int32 RemoveStable (KeyInitType Key)
 
template<typename ComparableKey >
int32 RemoveByHash (uint32 KeyHash, const ComparableKey &Key)
 
UE_FORCEINLINE_HINT bool Contains (KeyInitType Key) const
 
template<typename ComparableKey >
bool ContainsByHash (uint32 KeyHash, const ComparableKey &Key) const
 
template<typename PredicateType >
void Sort (const PredicateType &Predicate)
 
template<typename PredicateType >
void StableSort (const PredicateType &Predicate)
 
void Dump (FOutputDevice &Ar) const
 
UE_TCOMPACT_SET Intersect (const UE_TCOMPACT_SET &OtherSet) const
 
UE_TCOMPACT_SET Union (const UE_TCOMPACT_SET &OtherSet) const
 
UE_TCOMPACT_SET Difference (const UE_TCOMPACT_SET &OtherSet) const
 
bool Includes (const UE_TCOMPACT_SET< ElementType, KeyFuncs, Allocator > &OtherSet) const
 
TArray< ElementTypeArray () const
 
TArrayView< const ElementTypeArrayView () const
 
UE_FORCEINLINE_HINT TIterator CreateIterator ()
 
UE_FORCEINLINE_HINT TConstIterator CreateConstIterator () const
 
UE_FORCEINLINE_HINT ElementTypebegin ()
 
UE_FORCEINLINE_HINT const ElementTypebegin () const
 
UE_FORCEINLINE_HINT ElementTypeend ()
 
UE_FORCEINLINE_HINT const ElementTypeend () const
 
void WriteMemoryImage (FMemoryImageWriter &Writer) const
 
void CopyUnfrozen (const FMemoryUnfreezeContent &Context, void *Dst) const
 
- Public Member Functions inherited from TCompactSetBase< Allocator::template ElementAllocator< sizeof(InElementType)> >
bool operator== (FIntrusiveUnsetOptionalState Tag) const
 
UE_FORCEINLINE_HINT bool IsEmpty () const
 
UE_FORCEINLINE_HINT int32 Num () const
 
UE_FORCEINLINE_HINT int32 Max () const
 
UE_FORCEINLINE_HINT int32 GetMaxIndex () const
 
UE_FORCEINLINE_HINT SIZE_T GetAllocatedSize (const FCompactSetLayout Layout) const
 

Static Public Member Functions

static UE_FORCEINLINE_HINT constexpr size_t GetTotalMemoryRequiredInBytes (uint32 NumElements)
 
static void AppendHash (const FPlatformTypeLayoutParameters &LayoutParams, FSHA1 &Hasher)
 

Static Public Attributes

static constexpr bool bHasIntrusiveUnsetOptionalState = true
 

Friends

template<typename ScriptAllocator >
class TScriptCompactSet
 
struct TSETPRIVATEFRIEND
 
uint32 GetTypeHash (const UE_TCOMPACT_SET &Set)=delete
 
bool operator== (const UE_TCOMPACT_SET &, const UE_TCOMPACT_SET &)=delete
 
bool operator!= (const UE_TCOMPACT_SET &, const UE_TCOMPACT_SET &)=delete
 

Additional Inherited Members

- Protected Types inherited from TCompactSetBase< Allocator::template ElementAllocator< sizeof(InElementType)> >
using HashCountType = uint32
 
using ElementAllocatorType = typename AllocatorType::template ForElementType< uint8 >
 
- Protected Member Functions inherited from TCompactSetBase< Allocator::template ElementAllocator< sizeof(InElementType)> >
UE_FORCEINLINE_HINT TCompactSetBase ()=default
 
consteval TCompactSetBase (EConstEval)
 
 TCompactSetBase (FIntrusiveUnsetOptionalState Tag)
 
UE_FORCEINLINE_HINT const HashCountTypeGetHashTableMemory (const FCompactSetLayout Layout) const
 
FCompactHashTableView GetHashTableView (const FCompactSetLayout Layout)
 
FConstCompactHashTableView GetConstHashTableView (const FCompactSetLayout Layout) const
 
int32 AllocatorCalculateSlackGrow (int32 NewMaxElements, const FCompactSetLayout &Layout) const
 
void ResizeAllocation (const int32 NewMaxElements, const FCompactSetLayout &Layout)
 
bool ResizeAllocationPreserveData (const int32 NewMaxElements, const FCompactSetLayout &Layout, bool bPreserve=true)
 
- Static Protected Member Functions inherited from TCompactSetBase< Allocator::template ElementAllocator< sizeof(InElementType)> >
static UE_FORCEINLINE_HINT constexpr SizeType GetHashCount (uint32 NumElements)
 
static UE_FORCEINLINE_HINT constexpr size_t GetElementsSizeInBytes (uint32 NumElements, const FCompactSetLayout Layout)
 
static UE_FORCEINLINE_HINT constexpr size_t GetTotalMemoryRequiredInBytes (uint32 NumElements, uint32 HashCount, const FCompactSetLayout Layout)
 
static UE_FORCEINLINE_HINT constexpr size_t GetTotalMemoryRequiredInBytes (uint32 NumElements, const FCompactSetLayout Layout)
 
static constexpr SizeType GetMaxElementsForAvailableSpace (size_t TotalBytes, uint32 HashCount, uint32 MinElementCount, const FCompactSetLayout Layout)
 
- Protected Attributes inherited from TCompactSetBase< Allocator::template ElementAllocator< sizeof(InElementType)> >
ElementAllocatorType Elements
 
SizeType NumElements
 
SizeType MaxElements
 
- Static Protected Attributes inherited from TCompactSetBase< Allocator::template ElementAllocator< sizeof(InElementType)> >
static constexpr size_t HashCountSize
 

Detailed Description

template<typename InElementType, typename KeyFuncs, typename Allocator>
class UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >

A set with an optional KeyFuncs parameters for customizing how the elements are compared and searched.
E.g. You can specify a mapping from elements to keys if you want to find elements by specifying a subset of the element type. It uses a TSparseArray of the elements, and also links the elements into a hash with a number of buckets proportional to the number of elements. Addition, removal, and finding are O(1).

The ByHash() functions are somewhat dangerous but particularly useful in two scenarios: – Heterogeneous lookup to avoid creating expensive keys like FString when looking up by const TCHAR*. You must ensure the hash is calculated in the same way as ElementType is hashed. If possible put both ComparableKey and ElementType hash functions next to each other in the same header to avoid bugs when the ElementType hash function is changed. – Reducing contention around hash tables protected by a lock. It is often important to incur the cache misses of reading key data and doing the hashing before acquiring the lock.

Here's a visual example of the data layout for the compact set


| | | | | | Data Array | Hash Size | Collision List | Hash Table | |____________|___________|________________|____________|

Data Array - Payload of the set. This is a just a regular array of items without any empty spots Hash Size - 4 byte integer to reference how big the hash table is. Storing this is significantly faster than trying to recalculate it Collision List - For each entry in the Data Array there is an entry in this list that may contain a valid index to the next item to consider for hash table collisions Hash Table - Power of 2 table to lookup the first index of a given hash value

Member Typedef Documentation

◆ ElementType

using UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::ElementType = InElementType

◆ IntrusiveUnsetOptionalStateType

using UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::IntrusiveUnsetOptionalStateType = UE_TCOMPACT_SET

◆ KeyFuncsType

using UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::KeyFuncsType = KeyFuncs

◆ TConstIterator

using UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::TConstIterator = TBaseIterator<true>

Used to iterate over the elements of a const UE_TCOMPACT_SET.

◆ TConstKeyIterator

using UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::TConstKeyIterator = TBaseKeyIterator<true>

Used to iterate over the elements of a const UE_TCOMPACT_SET.

◆ TRangedForConstIterator

using UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::TRangedForConstIterator = const ElementType*

◆ TRangedForIterator

using UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::TRangedForIterator = ElementType*

DO NOT USE DIRECTLY STL-like iterators to enable range-based for loop support.

Constructor & Destructor Documentation

◆ UE_TCOMPACT_SET() [1/10]

◆ UE_TCOMPACT_SET() [2/10]

◆ UE_TCOMPACT_SET() [3/10]

◆ UE_TCOMPACT_SET() [4/10]

◆ UE_TCOMPACT_SET() [5/10]

◆ UE_TCOMPACT_SET() [6/10]

UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::UE_TCOMPACT_SET ( std::initializer_list< ElementType InitList)
inline

◆ UE_TCOMPACT_SET() [7/10]

◆ UE_TCOMPACT_SET() [8/10]

Constructor for moving elements from a UE_TCOMPACT_SET with a different SetAllocator

◆ UE_TCOMPACT_SET() [9/10]

Constructor for copying elements from a UE_TCOMPACT_SET with a different SetAllocator

◆ ~UE_TCOMPACT_SET()

◆ UE_TCOMPACT_SET() [10/10]

Member Function Documentation

◆ Add() [1/2]

UE_FORCEINLINE_HINT FSetElementId UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Add ( const ElementType InElement,
bool bIsAlreadyInSetPtr = nullptr 
)
inline

Adds an element to the set.

Parameters
InElementElement to add to set
bIsAlreadyInSetPtr[out] Optional pointer to bool that will be set depending on whether element is already in set
Returns
A pointer to the element stored in the set.

◆ Add() [2/2]

UE_FORCEINLINE_HINT FSetElementId UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Add ( ElementType &&  InElement,
bool bIsAlreadyInSetPtr = nullptr 
)
inline

◆ AddByHash() [1/2]

UE_FORCEINLINE_HINT FSetElementId UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::AddByHash ( uint32  KeyHash,
const ElementType InElement,
bool bIsAlreadyInSetPtr = nullptr 
)
inline

Adds an element to the set.

See also
Class documentation section on ByHash() functions
Parameters
KeyHashA precomputed hash value, calculated in the same way as ElementType is hashed.
InElementElement to add to set
bIsAlreadyInSetPtr[out] Optional pointer to bool that will be set depending on whether element is already in set
Returns
A handle to the element stored in the set

◆ AddByHash() [2/2]

UE_FORCEINLINE_HINT FSetElementId UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::AddByHash ( uint32  KeyHash,
ElementType &&  InElement,
bool bIsAlreadyInSetPtr = nullptr 
)
inline

◆ Append() [1/7]

void UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Append ( const UE_TCOMPACT_SET< ElementType, KeyFuncs, OtherAllocator > &  OtherSet)
inline

Add all items from another set to our set (union without creating a new set)

Parameters
OtherSet- The other set of items to add.

◆ Append() [2/7]

Add all items from another set to our set (union without creating a new set) Compatible element type version.

Parameters
OtherSet- The other set of items to add.

◆ Append() [3/7]

void UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Append ( std::initializer_list< ElementType InitList)
inline

◆ Append() [4/7]

void UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Append ( TArray< ElementType, ArrayAllocator > &&  InElements)
inline

◆ Append() [5/7]

void UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Append ( TArrayView< const ElementType InElements)
inline

◆ Append() [6/7]

void UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Append ( UE_TCOMPACT_SET< ElementType, KeyFuncs, OtherAllocator > &&  OtherSet)
inline

◆ Append() [7/7]

Add all items from another set to our set (union without creating a new set) Compatible element type version.

Parameters
OtherSet- The other set of items to add.

◆ AppendHash()

static void UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::AppendHash ( const FPlatformTypeLayoutParameters LayoutParams,
FSHA1 Hasher 
)
inlinestatic

◆ Array()

TArray< ElementType > UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Array ( ) const
inline
Returns
a TArray that's a copy of all the elements in this set, prefer using ArrayView where possible.

◆ ArrayView()

TArrayView< const ElementType > UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::ArrayView ( ) const
inline
Returns
a readonly TArrayView of the elements

◆ begin() [1/2]

◆ begin() [2/2]

UE_FORCEINLINE_HINT const ElementType * UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::begin ( ) const
inline

◆ CheckInvariants()

UE_FORCEINLINE_HINT void UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::CheckInvariants ( ) const
inline

Checks array invariants: if array size is greater than or equal to zero and less than or equal to the maximum.

◆ Compact()

void UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Compact ( )
inline

Deprecated - default behavior now, keeping this here so UE_TCOMPACT_SET can be swapped with TSet without changing code

◆ CompactStable()

void UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::CompactStable ( )
inline

Deprecated - use sparse array if this behavior is required, keeping this here so UE_TCOMPACT_SET can be swapped with TSet without changing code

◆ Contains()

UE_FORCEINLINE_HINT bool UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Contains ( KeyInitType  Key) const
inline

Checks if the element contains an element with the given key.

Parameters
Key- The key to check for.
Returns
true if the set contains an element with the given key.

◆ ContainsByHash()

template<typename ComparableKey >
bool UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::ContainsByHash ( uint32  KeyHash,
const ComparableKey Key 
) const
inline

Checks if the element contains an element with the given key.

See also
Class documentation section on ByHash() functions

◆ CopyUnfrozen()

void UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::CopyUnfrozen ( const FMemoryUnfreezeContent Context,
void Dst 
) const
inline

◆ CountBytes()

void UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::CountBytes ( FArchive Ar) const
inline

Tracks the container's memory use through an archive.

◆ CreateConstIterator()

UE_FORCEINLINE_HINT TConstIterator UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::CreateConstIterator ( ) const
inline

Creates a const iterator for the contents of this set

◆ CreateIterator()

UE_FORCEINLINE_HINT TIterator UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::CreateIterator ( )
inline

Creates an iterator for the contents of this set

◆ Difference()

UE_TCOMPACT_SET UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Difference ( const UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator > &  OtherSet) const
inline
Returns
the complement of two sets. (A not in B where A is this and B is Other)

◆ Dump()

void UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Dump ( FOutputDevice Ar) const
inline

Describes the set's contents through an output device.

Parameters
Ar- The output device to describe the set's contents through.

◆ Emplace() [1/2]

template<typename ArgType = ElementType>
UE_FORCEINLINE_HINT FSetElementId UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Emplace ( ArgType &&  Arg,
bool bIsAlreadyInSetPtr = nullptr 
)
inline

Adds an element to the set.

Parameters
ArgThe argument(s) to be forwarded to the set element's constructor.
bIsAlreadyInSetPtr[out] Optional pointer to bool that will be set depending on whether element is already in set
Returns
A handle to the element stored in the set.

◆ Emplace() [2/2]

template<typename... ArgTypes>
TPair< FSetElementId, bool > UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Emplace ( EInPlace  ,
ArgTypes &&...  InArgs 
)
inline

Adds an element to the set by constructing the ElementType in-place with multiple args.

Parameters
EInPlaceTag to disambiguate in-place construction.
InArgsArguments forwarded to ElementType's constructor.
Returns
Pair of (element id, whether an equivalent element already existed).

◆ EmplaceByHash() [1/2]

template<typename... ArgTypes>
TPair< FSetElementId, bool > UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::EmplaceByHash ( EInPlace  ,
uint32  KeyHash,
ArgTypes &&...  InArgs 
)
inline

Adds an element to the set by constructing in-place with multiple args, using a precomputed hash.

See also
Class documentation section on ByHash() functions.
Parameters
KeyHashA precomputed hash value, calculated in the same way as ElementType is hashed.
EInPlaceTag to disambiguate in-place construction.
InArgsArguments forwarded to ElementType's constructor.
Returns
Pair of (element id, whether an equivalent element already existed).

◆ EmplaceByHash() [2/2]

template<typename ArgType = ElementType>
UE_FORCEINLINE_HINT FSetElementId UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::EmplaceByHash ( uint32  KeyHash,
ArgType &&  Arg,
bool bIsAlreadyInSetPtr = nullptr 
)
inline

Adds an element to the set.

See also
Class documentation section on ByHash() functions
Parameters
KeyHashA precomputed hash value, calculated in the same way as ElementType is hashed.
ArgThe argument(s) to be forwarded to the set element's constructor.
bIsAlreadyInSetPtr[out] Optional pointer to bool that will be set depending on whether element is already in set
Returns
A handle to the element stored in the set.

◆ Empty()

void UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Empty ( int32  ExpectedNumElements = 0)
inline

Removes all elements from the set, potentially leaving space allocated for an expected number of elements about to be added.

Parameters
ExpectedNumElements- The number of elements about to be added to the set.

◆ end() [1/2]

◆ end() [2/2]

UE_FORCEINLINE_HINT const ElementType * UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::end ( ) const
inline

◆ Find() [1/2]

ElementType * UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Find ( KeyInitType  Key)
inline

Finds an element with the given key in the set.

Parameters
Key- The key to search for.
Returns
A pointer to an element with the given key. If no element in the set has the given key, this will return NULL.

◆ Find() [2/2]

UE_FORCEINLINE_HINT const ElementType * UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Find ( KeyInitType  Key) const
inline

Finds an element with the given key in the set.

Parameters
Key- The key to search for.
Returns
A const pointer to an element with the given key. If no element in the set has the given key, this will return NULL.

◆ FindArbitraryElement() [1/2]

ElementType * UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::FindArbitraryElement ( )
inline

Finds any element in the set and returns a pointer to it. Callers should not depend on particular patterns in the behaviour of this function.

Returns
A pointer to an arbitrary element, or nullptr if the container is empty.

◆ FindArbitraryElement() [2/2]

const ElementType * UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::FindArbitraryElement ( ) const
inline

◆ FindByHash() [1/2]

template<typename ComparableKey >
ElementType * UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::FindByHash ( uint32  KeyHash,
const ComparableKey Key 
)
inline

Finds an element with a pre-calculated hash and a key that can be compared to KeyType.

See also
Class documentation section on ByHash() functions
Returns
A pointer to the contained element or nullptr.

◆ FindByHash() [2/2]

template<typename ComparableKey >
const ElementType * UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::FindByHash ( uint32  KeyHash,
const ComparableKey Key 
) const
inline

◆ FindId()

FSetElementId UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::FindId ( KeyInitType  Key) const
inline

Finds an element with the given key in the set.

Parameters
Key- The key to search for.
Returns
The id of the set element matching the given key, or the NULL id if none matches.

◆ FindIdByHash()

template<typename ComparableKey >
FSetElementId UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::FindIdByHash ( uint32  KeyHash,
const ComparableKey Key 
) const
inline

Finds an element with a pre-calculated hash and a key that can be compared to KeyType

See also
Class documentation section on ByHash() functions
Returns
The element id that matches the key and hash or an invalid element id

◆ FindOrAdd() [1/2]

UE_FORCEINLINE_HINT ElementType & UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::FindOrAdd ( const InElementType InElement,
bool bIsAlreadyInSetPtr = nullptr 
)
inline

Adds an element to the set if not already present and returns a reference to the added or existing element.

Parameters
InElementElement to add to set
bIsAlreadyInSetPtr[out] Optional pointer to bool that will be set depending on whether element is already in set
Returns
A reference to the element stored in the set.

◆ FindOrAdd() [2/2]

UE_FORCEINLINE_HINT ElementType & UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::FindOrAdd ( InElementType &&  InElement,
bool bIsAlreadyInSetPtr = nullptr 
)
inline

◆ FindOrAddByHash()

ElementType & UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::FindOrAddByHash ( uint32  KeyHash,
ElementReferenceType &&  InElement,
bool bIsAlreadyInSetPtr = nullptr 
)
inline

Adds an element to the set if not already present and returns a reference to the added or existing element.

See also
Class documentation section on ByHash() functions
Parameters
KeyHashA precomputed hash value, calculated in the same way as ElementType is hashed.
InElementElement to add to set
bIsAlreadyInSetPtr[out] Optional pointer to bool that will be set depending on whether element is already in set
Returns
A reference to the element stored in the set

◆ Get() [1/2]

Accesses the identified element's value. Element must be valid (see @IsValidId).

◆ Get() [2/2]

const ElementType & UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Get ( FSetElementId  Id) const
inline

Accesses the identified element's value. Element must be valid (see @IsValidId).

◆ GetAllocatedSize()

UE_FORCEINLINE_HINT SIZE_T UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::GetAllocatedSize ( ) const
inline

Helper function to return the amount of memory allocated by this container Only returns the size of allocations made directly by the container, not the elements themselves.

Returns
number of bytes allocated by this container

◆ GetTotalMemoryRequiredInBytes()

static UE_FORCEINLINE_HINT constexpr size_t UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::GetTotalMemoryRequiredInBytes ( uint32  NumElements)
inlinestaticconstexpr

◆ Includes()

bool UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Includes ( const UE_TCOMPACT_SET< ElementType, KeyFuncs, Allocator > &  OtherSet) const
inline

Determine whether the specified set is entirely included within this set

Parameters
OtherSetSet to check
Returns
True if the other set is entirely included in this set, false if it is not

◆ Intersect()

UE_TCOMPACT_SET UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Intersect ( const UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator > &  OtherSet) const
inline
Returns
the intersection of two sets. (A AND B)

◆ IsValidId()

UE_FORCEINLINE_HINT bool UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::IsValidId ( FSetElementId  Id) const
inline

Checks whether an element id is valid.

Parameters
Id- The element id to check.
Returns
true if the element identifier refers to a valid element in this set.

◆ operator=() [1/7]

UE_TCOMPACT_SET & UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::operator= ( const UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator > &  Copy)
inline

◆ operator=() [2/7]

UE_TCOMPACT_SET & UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::operator= ( const UE_TCOMPACT_SET< ElementType, KeyFuncs, OtherAllocator > &  Other)
inline

Assignment operator for copying elements from a UE_TCOMPACT_SET with a different SetAllocator

◆ operator=() [3/7]

Assignment operator. First deletes all currently contained elements and then copies from other set. Compatible element type version.

Parameters
OtherThe source set to assign from.

◆ operator=() [4/7]

UE_TCOMPACT_SET & UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::operator= ( std::initializer_list< ElementType InitList)
inline

◆ operator=() [5/7]

UE_TCOMPACT_SET & UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::operator= ( UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator > &&  Other)
inline

◆ operator=() [6/7]

UE_TCOMPACT_SET & UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::operator= ( UE_TCOMPACT_SET< ElementType, KeyFuncs, OtherAllocator > &&  Other)
inline

Assignment operator for moving elements from a UE_TCOMPACT_SET with a different SetAllocator

◆ operator=() [7/7]

Move assignment operator. Compatible element type version.

Parameters
OtherSet to assign and move from.

◆ operator[]() [1/2]

ElementType & UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::operator[] ( FSetElementId  Id)
inline

Accesses the identified element's value. Element must be valid (see @IsValidId).

◆ operator[]() [2/2]

const ElementType & UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::operator[] ( FSetElementId  Id) const
inline

Accesses the identified element's value. Element must be valid (see @IsValidId).

◆ RangeCheck()

void UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::RangeCheck ( FSetElementId  Id) const
inline

Checks if index is in array range.

Parameters
IndexIndex to check.

◆ Relax()

void UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Relax ( )
inline

Deprecated - default behavior now, keeping this here so UE_TCOMPACT_SET can be swapped with TSet without changing code

◆ Remove() [1/2]

void UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Remove ( FSetElementId  ElementId)
inline

Removes an element from the set.

Parameters
Element- A pointer to the element in the set, as returned by Add or Find.

◆ Remove() [2/2]

int32 UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Remove ( KeyInitType  Key)
inline

Removes all elements from the set matching the specified key.

Parameters
Key- The key to match elements against.
Returns
The number of elements removed.

◆ RemoveByHash()

template<typename ComparableKey >
int32 UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::RemoveByHash ( uint32  KeyHash,
const ComparableKey Key 
)
inline

Removes all elements from the set matching the specified key.

See also
Class documentation section on ByHash() functions
Parameters
Key- The key to match elements against.
Returns
The number of elements removed.

◆ RemoveStable() [1/2]

void UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::RemoveStable ( FSetElementId  ElementId)
inline

Removes an element from the set while maintaining set order.

Parameters
Element- A pointer to the element in the set, as returned by Add or Find.

◆ RemoveStable() [2/2]

int32 UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::RemoveStable ( KeyInitType  Key)
inline

Removes all elements from the set matching the specified key.

Parameters
Key- The key to match elements against.
Returns
The number of elements removed.

◆ Reserve()

void UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Reserve ( int32  Number)
inline

Preallocates enough memory to contain Number elements

◆ Reset()

void UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Reset ( )
inline

Efficiently empties out the set but preserves all allocations and capacities

◆ Shrink()

void UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Shrink ( )
inline

Shrinks the set's element storage to avoid slack.

◆ Sort()

template<typename PredicateType >
void UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Sort ( const PredicateType Predicate)
inline

Sorts the set's elements using the provided comparison class.

◆ SortFreeList()

void UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::SortFreeList ( )
inline

Deprecated - unnecessary, keeping this here so UE_TCOMPACT_SET can be swapped with TSet without changing code

◆ StableSort()

template<typename PredicateType >
void UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::StableSort ( const PredicateType Predicate)
inline

Stable sorts the set's elements using the provided comparison class.

◆ Union()

UE_TCOMPACT_SET UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::Union ( const UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator > &  OtherSet) const
inline
Returns
the union of two sets. (A OR B)

◆ WriteMemoryImage()

void UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::WriteMemoryImage ( FMemoryImageWriter Writer) const
inline

Friends And Related Symbol Documentation

◆ GetTypeHash

uint32 GetTypeHash ( const UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator > &  Set)
friend

◆ operator!=

bool operator!= ( const UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator > &  ,
const UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator > &   
)
friend

◆ operator==

bool operator== ( const UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator > &  ,
const UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator > &   
)
friend

◆ TScriptCompactSet

◆ TSETPRIVATEFRIEND

Member Data Documentation

◆ bHasIntrusiveUnsetOptionalState

constexpr bool UE_TCOMPACT_SET< InElementType, KeyFuncs, Allocator >::bHasIntrusiveUnsetOptionalState = true
staticconstexpr

The documentation for this class was generated from the following file: