UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TSortedSet< InElementType, ArrayAllocator, SortPredicate > Class Template Reference

#include <SortedSet.h>

Classes

class  TConstIterator
 
class  TIterator
 

Public Types

using ElementType = InElementType
 
using KeyInitType = typename TTypeTraits< ElementType >::ConstPointerType
 
using IntrusiveUnsetOptionalStateType = TSortedSet
 

Public Member Functions

 TSortedSet ()=default
 
 TSortedSet (TSortedSet &&)=default
 
 TSortedSet (const TSortedSet &)=default
 
TSortedSetoperator= (TSortedSet &&)=default
 
TSortedSetoperator= (const TSortedSet &)=default
 
template<typename OtherArrayAllocator >
 TSortedSet (TSortedSet< InElementType, OtherArrayAllocator, SortPredicate > &&Other)
 
template<typename OtherArrayAllocator >
 TSortedSet (const TSortedSet< InElementType, OtherArrayAllocator, SortPredicate > &Other)
 
 TSortedSet (std::initializer_list< ElementType > InitList)
 
 TSortedSet (FIntrusiveUnsetOptionalState Tag)
 
bool operator== (FIntrusiveUnsetOptionalState Tag) const
 
template<typename OtherArrayAllocator >
TSortedSetoperator= (TSortedSet< ElementType, OtherArrayAllocator, SortPredicate > &&Other)
 
template<typename OtherArrayAllocator >
TSortedSetoperator= (const TSortedSet< ElementType, OtherArrayAllocator, SortPredicate > &Other)
 
TSortedSetoperator= (std::initializer_list< ElementType > InitList)
 
UE_FORCEINLINE_HINT bool operator== (const TSortedSet &Other) const
 
UE_FORCEINLINE_HINT bool operator!= (const TSortedSet &Other) const
 
UE_FORCEINLINE_HINT void Empty (int32 ExpectedNumElements=0)
 
UE_FORCEINLINE_HINT void Reset ()
 
UE_FORCEINLINE_HINT void Shrink ()
 
UE_FORCEINLINE_HINT void Reserve (int32 Number)
 
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
 
UE_FORCEINLINE_HINT void CountBytes (FArchive &Ar) const
 
UE_FORCEINLINE_HINT FSetElementId Add (const ElementType &InValue, bool *bIsAlreadyInSetPtr=nullptr)
 
UE_FORCEINLINE_HINT FSetElementId Add (ElementType &&InValue, bool *bIsAlreadyInSetPtr=nullptr)
 
template<typename InitArgType = ElementType>
FSetElementId Emplace (InitArgType &&InInitArg, bool *bIsAlreadyInSetPtr=nullptr)
 
UE_FORCEINLINE_HINT int32 Remove (KeyInitType InKey)
 
UE_FORCEINLINE_HINT ElementTypeFind (KeyInitType Key)
 
UE_FORCEINLINE_HINT const ElementTypeFind (KeyInitType Key) const
 
UE_FORCEINLINE_HINT ElementTypeFindOrAdd (const ElementType &InValue, bool *bIsAlreadyInSetPtr=nullptr)
 
UE_FORCEINLINE_HINT ElementTypeFindOrAdd (ElementType &&InValue, bool *bIsAlreadyInSetPtr=nullptr)
 
ElementTypeFindArbitraryElement ()
 
const ElementTypeFindArbitraryElement () const
 
UE_FORCEINLINE_HINT bool Contains (KeyInitType Key) const
 
TArray< ElementTypeArray () const &
 
TArray< ElementTypeArray () &&
 
void Dump (FOutputDevice &Ar)
 
template<typename OtherArrayAllocator , typename OtherSortPredicate >
void Append (TSortedSet< ElementType, OtherArrayAllocator, OtherSortPredicate > &&Other)
 
template<typename OtherArrayAllocator , typename OtherSortPredicate >
void Append (const TSortedSet< ElementType, OtherArrayAllocator, OtherSortPredicate > &Other)
 
template<typename OtherArrayAllocator >
void Append (TArray< ElementType, OtherArrayAllocator > &&Other)
 
void Append (TArrayView< const ElementType > Other)
 
template<typename OtherArrayAllocator >
void Append (std::initializer_list< ElementType > Other)
 
UE_FORCEINLINE_HINT bool IsValidId (FSetElementId Id) const
 
UE_FORCEINLINE_HINT ElementTypeoperator[] (FSetElementId Id)
 
UE_FORCEINLINE_HINT const ElementTypeoperator[] (FSetElementId Id) const
 
UE_FORCEINLINE_HINT ElementTypeGet (FSetElementId Id)
 
UE_FORCEINLINE_HINT const ElementTypeGet (FSetElementId Id) const
 
UE_FORCEINLINE_HINT TIterator CreateIterator ()
 
UE_FORCEINLINE_HINT TConstIterator CreateConstIterator () const
 
UE_FORCEINLINE_HINT auto begin ()
 
UE_FORCEINLINE_HINT auto begin () const
 
UE_FORCEINLINE_HINT auto end ()
 
UE_FORCEINLINE_HINT auto end () const
 

Static Public Attributes

static constexpr bool bHasIntrusiveUnsetOptionalState = true
 

Friends

template<typename OtherElementType , typename OtherArrayAllocator , typename OtherSortPredicate >
class TSortedSet
 
FArchiveoperator (FArchive &Ar, TSortedSet &Set)
 

Detailed Description

template<typename InElementType, typename ArrayAllocator, typename SortPredicate>
class TSortedSet< InElementType, ArrayAllocator, SortPredicate >

A set of values, implemented as a sorted TArray of elements.

It has a mostly identical interface to TSet and is designed as a drop in replacement. Keys must be unique. It uses half as much memory as TSet and has a smaller static footprint, but adding and removing elements is O(n), and finding is O(Log n). In practice it is faster than TSet for low element counts, and slower as n increases. This set is always kept sorted by key so cannot be sorted manually.

Member Typedef Documentation

◆ ElementType

◆ IntrusiveUnsetOptionalStateType

◆ KeyInitType

Constructor & Destructor Documentation

◆ TSortedSet() [1/7]

◆ TSortedSet() [2/7]

◆ TSortedSet() [3/7]

◆ TSortedSet() [4/7]

Constructor for moving elements from a TSortedSet with a different ArrayAllocator.

◆ TSortedSet() [5/7]

Constructor for copying elements from a TSortedSet with a different ArrayAllocator.

◆ TSortedSet() [6/7]

Constructor which gets its elements from a native initializer list

◆ TSortedSet() [7/7]

Member Function Documentation

◆ Add() [1/2]

Adds an element to the set.

Parameters
InValueThe value to add.
bIsAlreadyInSetPtr[out] Optional pointer to bool that will be set depending on whether element is already in set
Returns
A handle to the value in the set (only valid until the next change to the set).

◆ Add() [2/2]

◆ Append() [1/5]

◆ Append() [2/5]

◆ Append() [3/5]

◆ Append() [4/5]

◆ Append() [5/5]

Adds all items from another set into our set (if any elements are in both, the value from the other set wins). If the source is an rvalue container, the elements will be moved and the container will be left empty.

Parameters
OtherThe range of elements to add.

◆ Array() [1/2]

◆ Array() [2/2]

◆ begin() [1/2]

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

◆ begin() [2/2]

◆ Contains()

Checks if set contains the specified key.

Parameters
KeyThe key to check for.
Returns
true if the set contains the key.

◆ CountBytes()

Tracks the container's memory use through an archive.

◆ CreateConstIterator()

Creates a const iterator over all the elements in this set

◆ CreateIterator()

Creates an iterator over all the elements in this set

◆ Dump()

Describes the set's contents through an output device.

Parameters
ArThe output device to describe the set's contents through.

◆ Emplace()

template<typename InitArgType = ElementType>
FSetElementId TSortedSet< InElementType, ArrayAllocator, SortPredicate >::Emplace ( InitArgType &&  InInitArg,
bool bIsAlreadyInSetPtr = nullptr 
)
inline

Adds an element to the set.

Parameters
InInitArgThe argument 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 value in the set (only valid until the next change to the set).

◆ Empty()

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

Parameters
ExpectedNumElementsThe number of elements about to be added to the set.

◆ end() [1/2]

◆ end() [2/2]

◆ Find() [1/2]

Returns the value associated with a specified key.

Parameters
KeyThe key to search for.
Returns
A pointer to the value associated with the specified key, or nullptr if the key isn't contained in this set. The pointer (only valid until the next change to any key in the set).

◆ Find() [2/2]

◆ FindArbitraryElement() [1/2]

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

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

◆ FindArbitraryElement() [2/2]

◆ FindOrAdd() [1/2]

UE_FORCEINLINE_HINT ElementType & TSortedSet< InElementType, ArrayAllocator, SortPredicate >::FindOrAdd ( const ElementType InValue,
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
InValueThe value to add.
bIsAlreadyInSetPtr[out] Optional pointer to bool that will be set depending on whether element is already in set
Returns
A handle to the value in the set (only valid until the next change to the set).

◆ FindOrAdd() [2/2]

UE_FORCEINLINE_HINT ElementType & TSortedSet< InElementType, ArrayAllocator, SortPredicate >::FindOrAdd ( ElementType &&  InValue,
bool bIsAlreadyInSetPtr = nullptr 
)
inline

◆ Get() [1/2]

◆ Get() [2/2]

◆ GetAllocatedSize()

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.

◆ GetMaxIndex()

Returns
The non-inclusive maximum index of elements in the set.

◆ IsEmpty()

Returns true if the set is empty and contains no elements.

Returns
True if the set is empty.
See also
Num

◆ IsValidId()

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.

◆ Max()

Returns
The number of elements the set can hold before reallocation.

◆ Num()

Returns
The number of elements in the set.

◆ operator!=()

Inequality operator. This is efficient because elements are always sorted.

◆ operator=() [1/5]

◆ operator=() [2/5]

Assignment operator for copying elements from a TSortedSet with a different ArrayAllocator.

◆ operator=() [3/5]

Assignment operator which gets its elements from a native initializer list

◆ operator=() [4/5]

◆ operator=() [5/5]

Assignment operator for moving elements from a TSortedSet with a different ArrayAllocator.

◆ operator==() [1/2]

Equality operator. This is efficient because elements are always sorted.

◆ operator==() [2/2]

◆ operator[]() [1/2]

◆ operator[]() [2/2]

◆ Remove()

Removes all elements from the set matching the specified key.

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

◆ Reserve()

Preallocates enough memory to contain Number elements.

◆ Reset()

Efficiently empties out the set but preserves all allocations and capacities.

◆ Shrink()

Friends And Related Symbol Documentation

◆ operator

◆ TSortedSet

Member Data Documentation

◆ bHasIntrusiveUnsetOptionalState


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