Navigation
Unreal Engine C++ API Reference > Runtime > Core > Containers
Inheritance Hierarchy
- TSet
- FTouchKeySet
References
Module | Core |
Header | /Engine/Source/Runtime/Core/Public/Containers/Set.h |
Include | #include "Containers/Set.h" |
Syntax
template<typename InElementType, typename KeyFuncs, typename Allocator>
class TSet
Remarks
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.
Constructors
Type | Name | Description | |
---|---|---|---|
![]() |
TSet () |
Initialization constructor. | |
![]() |
Copy constructor. | ||
![]() |
TSet
(
const TArray< ElementType >& InArray |
||
![]() |
TSet
(
TArray< ElementType >&& InArray |
||
![]() |
TSet
(
std::initializer_list< ElementType > InitList |
Initializer list constructor. | |
![]() |
Move constructor. | ||
![]() |
TSet
(
TSet< ElementType, KeyFuncs, OtherAllocator >&& Other |
Constructor for moving elements from a TSet with a different SetAllocator | |
![]() |
TSet
(
const TSet< ElementType, KeyFuncs, OtherAllocator >& Other |
Constructor for copying elements from a TSet with a different SetAllocator |
Destructors
Type | Name | Description | |
---|---|---|---|
![]() |
~TSet () |
Destructor. |
Functions
Type | Name | Description | |
---|---|---|---|
![]() |
FSetElementId | Add
(
InElementType&& InElement, |
|
![]() |
FSetElementId | Add
(
const InElementType& InElement, |
Adds an element to the set. |
![]() |
FSetElementId | ||
![]() |
FSetElementId | Adds an element to the set. | |
![]() |
void | Append
(
TArrayView< ElementType, ViewSizeType > InElements |
|
![]() |
void | Append
(
TSet< typename TContainerElementTypeCompatibility< ElementType >::CopyFromOtherType, OtherKeyFuncs, ... |
Add all items from another set to our set (union without creating a new set) Compatible element type version. |
![]() |
void | Append
(
const TSet< typename TContainerElementTypeCompatibility< ElementType >::CopyFromOtherType, OtherKeyF... |
Add all items from another set to our set (union without creating a new set) Compatible element type version. |
![]() |
void | Append
(
std::initializer_list< ElementType > InitList |
|
![]() |
void | Append
(
TSet< ElementType, KeyFuncs, OtherAllocator >&& OtherSet |
|
![]() |
void | Append
(
const TSet< ElementType, KeyFuncs, OtherAllocator >& OtherSet |
Add all items from another set to our set (union without creating a new set) |
![]() |
void | Append
(
TArray< ElementType, ArrayAllocator >&& InElements |
|
![]() |
void | Append
(
const TArray< ElementType, ArrayAllocator >& InElements |
|
![]() |
void | Append
(
TArrayView< const ElementType, ViewSizeType > InElements |
|
![]() ![]() |
void | AppendHash
(
const FPlatformTypeLayoutParameters& LayoutParams, |
|
![]() ![]() |
TArray< ElementType > | Array () |
|
![]() ![]() |
TRangedForConstIterator | begin () |
|
![]() |
TRangedForIterator | begin () |
DO NOT USE DIRECTLY STL-like iterators to enable range-based for loop support. |
![]() ![]() |
void | CheckAddress
(
const ElementType* Addr |
Checks that the specified address is not part of an element within the container. |
![]() |
void | Compact () |
Compacts the allocated elements into a contiguous range. |
![]() |
void | Compacts the allocated elements into a contiguous range. | |
![]() ![]() |
bool | Contains
(
KeyInitType Key |
Checks if the element contains an element with the given key. |
![]() ![]() |
bool | ContainsByHash
(
uint32 KeyHash, |
Checks if the element contains an element with the given key. |
![]() ![]() |
void | CopyUnfrozen
(
const FMemoryUnfreezeContent& Context, |
|
![]() ![]() |
void | CountBytes
(
FArchive& Ar |
Tracks the container's memory use through an archive. |
![]() ![]() |
TConstIterator | Creates a const iterator for the contents of this set | |
![]() |
TIterator | Creates an iterator for the contents of this set | |
![]() ![]() |
TSet | Difference
(
const TSet& OtherSet |
|
![]() |
void | Dump
(
FOutputDevice& Ar |
Describes the set's contents through an output device. |
![]() |
void | DumpHashElements
(
FOutputDevice& Ar |
|
![]() |
FSetElementId | Emplace
(
ArgsType&& Args, |
Adds an element to the set. |
![]() |
FSetElementId | EmplaceByHash
(
uint32 KeyHash, |
Adds an element to the set. |
![]() |
void | Removes all elements from the set, potentially leaving space allocated for an expected number of elements about to be added. | |
![]() |
TRangedForIterator | end () |
|
![]() ![]() |
TRangedForConstIterator | end () |
|
![]() |
ElementType * | Find
(
KeyInitType Key |
Finds an element with the given key in the set. |
![]() ![]() |
const ElementType * | Find
(
KeyInitType Key |
Finds an element with the given key in the set. |
![]() |
ElementType * | FindByHash
(
uint32 KeyHash, |
Finds an element with a pre-calculated hash and a key that can be compared to KeyType. |
![]() ![]() |
const ElementType * | FindByHash
(
uint32 KeyHash, |
|
![]() ![]() |
FSetElementId | FindId
(
KeyInitType Key |
Finds an element with the given key in the set. |
![]() ![]() |
FSetElementId | FindIdByHash
(
uint32 KeyHash, |
Finds an element with a pre-calculated hash and a key that can be compared to KeyType |
![]() |
ElementType & | FindOrAdd
(
InElementType&& InElement, |
|
![]() |
ElementType & | FindOrAdd
(
const InElementType& InElement, |
Adds an element to the set if not already present and returns a reference to the added or existing element. |
![]() |
ElementType & | FindOrAddByHash
(
uint32 KeyHash, |
Adds an element to the set if not already present and returns a reference to the added or existing element. |
![]() ![]() |
const ElementType & | Get
(
FSetElementId Id |
Accesses the identified element's value. Element must be valid (see @IsValidId). |
![]() |
ElementType & | Get
(
FSetElementId Id |
Accesses the identified element's value. Element must be valid (see @IsValidId). |
![]() ![]() |
SIZE_T | 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. | |
![]() ![]() |
int32 | GetMaxIndex () |
|
![]() ![]() |
bool |
Includes
(
const TSet< ElementType, KeyFuncs, Allocator >& OtherSet |
Determine whether the specified set is entirely included within this set |
![]() ![]() |
TSet | ||
![]() ![]() |
bool | IsEmpty () |
Returns true if the sets is empty and contains no elements. |
![]() ![]() |
bool | IsValidId
(
FSetElementId Id |
Checks whether an element id is valid. |
![]() ![]() |
int32 | Num () |
|
![]() |
void | Relax () |
Relaxes the set's hash to a size strictly bounded by the number of elements in the set. |
![]() |
void | Remove
(
FSetElementId ElementId |
Removes an element from the set. |
![]() |
int32 | Remove
(
KeyInitType Key |
Removes all elements from the set matching the specified key. |
![]() |
int32 | RemoveByHash
(
uint32 KeyHash, |
Removes all elements from the set matching the specified key. |
![]() |
void | Preallocates enough memory to contain Number elements | |
![]() |
void | Reset () |
Efficiently empties out the set but preserves all allocations and capacities |
![]() |
void | Shrink () |
Shrinks the set's element storage to avoid slack. |
![]() |
void | Sort
(
const PREDICATE_CLASS& Predicate |
Sorts the set's elements using the provided comparison class. |
![]() |
void | SortFreeList () |
Sort the free element list so that subsequent additions will occur in the lowest available TSparseArray index resulting in tighter packing without moving any existing items. |
![]() |
void | StableSort
(
const PREDICATE_CLASS& Predicate |
Stable sorts the set's elements using the provided comparison class. |
![]() ![]() |
TSet | ||
![]() |
bool | VerifyHashElementsKey
(
KeyInitType Key |
|
![]() ![]() |
void | WriteMemoryImage
(
FMemoryImageWriter& Writer |
Operators
Type | Name | Description | |
---|---|---|---|
![]() ![]() |
const ElementType & | operator[]
(
FSetElementId Id |
Accesses the identified element's value. Element must be valid (see @IsValidId). |
![]() |
ElementType & | operator[]
(
FSetElementId Id |
Accesses the identified element's value. Element must be valid (see @IsValidId). |
![]() |
TSet & | operator=
(
TSet< typename TContainerElementTypeCompatibility< ElementType >::CopyFromOtherType, OtherKeyFuncs, ... |
Move assignment operator. Compatible element type version. |
![]() |
TSet & | operator=
(
const TSet< ElementType, KeyFuncs, OtherAllocator >& Other |
Assignment operator for copying elements from a TSet with a different SetAllocator |
![]() |
TSet & | operator=
(
TSet< ElementType, KeyFuncs, OtherAllocator >&& Other |
Assignment operator for moving elements from a TSet with a different SetAllocator |
![]() |
TSet & | Move assignment operator. | |
![]() |
TSet & | Assignment operator. | |
![]() |
TSet & | operator=
(
const TSet< typename TContainerElementTypeCompatibility< ElementType >::CopyFromOtherType, OtherKeyF... |
Assignment operator. |
![]() |
TSet & | operator=
(
std::initializer_list< ElementType > InitList |
Initializer list assignment operator |
Classes
Type | Name | Description | |
---|---|---|---|
![]() |
TConstIterator | Used to iterate over the elements of a const TSet. | |
![]() |
TConstKeyIterator | Used to iterate over the elements of a const TSet. | |
![]() |
TIterator | Used to iterate over the elements of a TSet. | |
![]() |
TKeyIterator | Used to iterate over the elements of a TSet. |