Navigation
API > API/Runtime > API/Runtime/Core
The base class of maps from keys to values. Implemented using a TSet of key-value pairs with a custom KeyFuncs, with the same O(1) addition, removal, and finding.
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.
| Name | TMapBase |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Containers/Map.h |
| Include Path | #include "Containers/Map.h" |
Syntax
template<typename KeyType, typename ValueType, typename SetAllocator, typename KeyFuncs>
class TMapBase
Derived Classes
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Constructor for moving elements from a TMap with a different SetAllocator | Containers/Map.h | ||
| Containers/Map.h | |||
TMapBase
(
FIntrusiveUnsetOptionalState Tag |
Containers/Map.h | ||
TMapBase () |
Containers/Map.h | ||
| Constructor for copying elements from a TMap with a different SetAllocator | Containers/Map.h | ||
| Containers/Map.h |
Classes
| Name | Remarks |
|---|---|
| TBaseIterator | The base of TMapBase iterators. |
| TBaseKeyIterator | The base type of iterators that iterate over the values associated with a specified key. |
| TConstIterator | Const map iterator. |
| TConstKeyIterator | Iterates over values associated with a specified key in a const map. |
| TIterator | Map iterator. |
| TKeyIterator | Iterates over values associated with a specified key in a map. |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| ElementSetType | TSet< ElementType, KeyFuncs, SetAllocator > | Containers/Map.h | |
| ElementType | TPair< KeyType, ValueType > | Containers/Map.h | |
| IntrusiveUnsetOptionalStateType | TMapBase | Containers/Map.h | |
| KeyConstPointerType | TTypeTraits< KeyType >::ConstPointerType | Containers/Map.h | |
| KeyInitType | TTypeTraits< KeyType >::ConstInitType | Containers/Map.h | |
| TRangedForConstIterator | TBaseIterator< true, true > | Containers/Map.h | |
| TRangedForIterator | TBaseIterator< false, true > | Containers/Map.h | |
| ValueInitType | TTypeTraits< ValueType >::ConstInitType | Containers/Map.h |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| bHasIntrusiveUnsetOptionalState | bool | Start - intrusive TOptional |
Containers/Map.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
ValueType & Add
(
const KeyType& InKey |
Set a default value associated with a key. | Containers/Map.h | |
| Set the value associated with a key. | Containers/Map.h | ||
| Containers/Map.h | |||
ValueType & Add
(
const KeyType& InKey, |
Set the value associated with a key. | Containers/Map.h | |
ValueType & Add
(
const KeyType& InKey, |
Containers/Map.h | ||
ValueType & Add
(
KeyType&& InKey, |
Containers/Map.h | ||
ValueType & Add
(
KeyType&& InKey, |
Containers/Map.h | ||
ValueType & Add
(
KeyType&& InKey |
Containers/Map.h | ||
ValueType & AddByHash
(
uint32 KeyHash, |
See Add() and class documentation section on ByHash() functions | Containers/Map.h | |
ValueType & AddByHash
(
uint32 KeyHash, |
See Add() and class documentation section on ByHash() functions | Containers/Map.h | |
ValueType & AddByHash
(
uint32 KeyHash, |
Containers/Map.h | ||
ValueType & AddByHash
(
uint32 KeyHash, |
Containers/Map.h | ||
ValueType & AddByHash
(
uint32 KeyHash, |
Containers/Map.h | ||
ValueType & AddByHash
(
uint32 KeyHash, |
Containers/Map.h | ||
TArray< ElementType > Array() |
Copy the key/value pairs in this map into an array. | Containers/Map.h | |
TRangedForIterator begin () |
DO NOT USE DIRECTLY STL-like iterators to enable range-based for loop support. | Containers/Map.h | |
TRangedForConstIterator begin () |
Containers/Map.h | ||
void Compact() |
Compacts the pair set to remove holes | Containers/Map.h | |
void CompactStable() |
Compacts the pair set to remove holes. Does not change the iteration order of the elements. | Containers/Map.h | |
bool Contains
(
KeyConstPointerType Key |
Check if map contains the specified key. | Containers/Map.h | |
bool ContainsByHash
(
uint32 KeyHash, |
See Contains() and class documentation section on ByHash() functions | Containers/Map.h | |
void CopyUnfrozen
(
const FMemoryUnfreezeContent& Context, |
Containers/Map.h | ||
void CountBytes
(
FArchive& Ar |
Track the container's memory use through an archive. | Containers/Map.h | |
TConstIterator CreateConstIterator() |
Creates a const iterator over all the pairs in this map | Containers/Map.h | |
TConstKeyIterator CreateConstKeyIterator
(
typename TConstKeyIterator::KeyArgumentType InKey |
Creates a const iterator over the values associated with a specified key in a map | Containers/Map.h | |
TIterator CreateIterator() |
Creates an iterator over all the pairs in this map | Containers/Map.h | |
TKeyIterator CreateKeyIterator
(
typename TKeyIterator::KeyArgumentType InKey |
Creates an iterator over the values associated with a specified key in a map | Containers/Map.h | |
void Dump
(
FOutputDevice& Ar |
Describes the map's contents through an output device. | Containers/Map.h | |
ValueType & Emplace
(
InitKeyType&& InKey, |
Sets the value associated with a key. | Containers/Map.h | |
ValueType & Emplace
(
InitKeyType&& InKey |
Set a default value associated with a key. | Containers/Map.h | |
ValueType & EmplaceByHash
(
uint32 KeyHash, |
See Emplace() and class documentation section on ByHash() functions | Containers/Map.h | |
ValueType & EmplaceByHash
(
uint32 KeyHash, |
See Emplace() and class documentation section on ByHash() functions | Containers/Map.h | |
void Empty
(
int32 ExpectedNumElements |
Removes all elements from the map. | Containers/Map.h | |
TRangedForIterator end () |
Containers/Map.h | ||
TRangedForConstIterator end () |
Containers/Map.h | ||
TMap< KeyType, ValueType, SetAllocator, KeyFuncs > FilterByPredicate
(
Predicate Pred |
Filters the elements in the map based on a predicate functor. | Containers/Map.h | |
ValueType * Find
(
KeyConstPointerType Key |
Find the value associated with a specified key. | Containers/Map.h | |
const ValueType * Find
(
KeyConstPointerType Key |
Containers/Map.h | ||
const ElementType * FindArbitraryElement () |
Containers/Map.h | ||
ElementType * FindArbitraryElement () |
Finds any pair in the map and returns a pointer to it. | Containers/Map.h | |
const ValueType * FindByHash
(
uint32 KeyHash, |
Containers/Map.h | ||
ValueType * FindByHash
(
uint32 KeyHash, |
See Find() and class documentation section on ByHash() functions | Containers/Map.h | |
const ValueType & FindByHashChecked
(
uint32 KeyHash, |
Containers/Map.h | ||
ValueType & FindByHashChecked
(
uint32 KeyHash, |
Containers/Map.h | ||
ValueType & FindChecked
(
KeyConstPointerType Key |
Find a reference to the value associated with a specified key. | Containers/Map.h | |
const ValueType & FindChecked
(
KeyConstPointerType Key |
Find a reference to the value associated with a specified key. | Containers/Map.h | |
FSetElementId FindId
(
KeyInitType Key |
Finds the index of the first element that is assigned to the specified key. | Containers/Map.h | |
FSetElementId FindIdByHash
(
uint32 KeyHash, |
See FindId() and class documentation section on ByHash() functions | Containers/Map.h | |
const KeyType * FindKey
(
ValueInitType Value |
Find the key associated with the specified value.The time taken is O(N) in the number of pairs. | Containers/Map.h | |
ValueType & FindOrAdd
(
const KeyType& Key |
Find the value associated with a specified key, or if none exists, adds a value using the default constructor. | Containers/Map.h | |
ValueType & FindOrAdd
(
KeyType&& Key |
Containers/Map.h | ||
ValueType & FindOrAdd
(
KeyType&& Key, |
Containers/Map.h | ||
ValueType & FindOrAdd
(
KeyType&& Key, |
Containers/Map.h | ||
ValueType & FindOrAdd
(
const KeyType& Key, |
Containers/Map.h | ||
ValueType & FindOrAdd
(
const KeyType& Key, |
Find the value associated with a specified key, or if none exists, adds a value using the default constructor. | Containers/Map.h | |
ValueType & FindOrAddByHash
(
uint32 KeyHash, |
Containers/Map.h | ||
ValueType & FindOrAddByHash
(
uint32 KeyHash, |
Containers/Map.h | ||
ValueType & FindOrAddByHash
(
uint32 KeyHash, |
Containers/Map.h | ||
ValueType & FindOrAddByHash
(
uint32 KeyHash, |
See FindOrAdd() and class documentation section on ByHash() functions | Containers/Map.h | |
ValueType & FindOrAddByHash
(
uint32 KeyHash, |
See FindOrAdd() and class documentation section on ByHash() functions | Containers/Map.h | |
ValueType & FindOrAddByHash
(
uint32 KeyHash, |
Containers/Map.h | ||
ValueType FindRef
(
KeyConstPointerType Key |
Find the value associated with a specified key. | Containers/Map.h | |
ValueType FindRef
(
KeyConstPointerType Key, |
Find the value associated with a specified key. | Containers/Map.h | |
void GenerateKeyArray
(
TArray< KeyType, Allocator >& OutArray |
Generate an array from the keys in this map. | Containers/Map.h | |
void GenerateValueArray
(
TArray< ValueType, Allocator >& OutArray |
Generate an array from the values in this map. | Containers/Map.h | |
const ElementType & Get
(
FSetElementId Id |
Return a mapped pair by internal identifier. Element must be valid (see @IsValidId). | Containers/Map.h | |
ElementType & Get
(
FSetElementId Id |
Return a mapped pair by internal identifier. Element must be valid (see @IsValidId). | Containers/Map.h | |
SIZE_T GetAllocatedSize () |
Helper function to return the amount of memory allocated by this container . | Containers/Map.h | |
| Get the unique keys contained within this map. | Containers/Map.h | ||
| Get the unique keys contained within this map. | Containers/Map.h | ||
int32 GetMaxIndex() |
Containers/Map.h | ||
bool IsEmpty () |
Returns true if the map is empty and contains no elements. | Containers/Map.h | |
bool IsValidId
(
FSetElementId Id |
Checks whether an element id is valid. | Containers/Map.h | |
int32 Num() |
Containers/Map.h | ||
bool OrderIndependentCompareEqual
(
const TMapBase& Other |
Compare this map with another for equality. | Containers/Map.h | |
int32 Remove
(
KeyConstPointerType InKey |
Remove all value associations for a key. | Containers/Map.h | |
void Remove
(
FSetElementId Id |
Removes the element at the specified index. The caller has to ensure that the index is valid. | Containers/Map.h | |
int32 RemoveByHash
(
uint32 KeyHash, |
See Remove() and class documentation section on ByHash() functions | Containers/Map.h | |
void Reserve
(
int32 Number |
Preallocates enough memory to contain Number elements | Containers/Map.h | |
void Reset() |
Efficiently empties out the map but preserves all allocations and capacities | Containers/Map.h | |
void Shrink() |
Shrinks the pair set to avoid slack. | Containers/Map.h | |
void WriteMemoryImage
(
FMemoryImageWriter& Writer |
Containers/Map.h |
Protected
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static void AppendHash
(
const FPlatformTypeLayoutParameters& LayoutParams, |
Containers/Map.h | ||
static uint32 HashKey
(
const KeyType& Key |
Containers/Map.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Assignment operator for copying elements from a TMap with a different SetAllocator | Containers/Map.h | ||
| End - intrusive TOptional |
Containers/Map.h | ||
| Containers/Map.h | |||
| Containers/Map.h | |||
bool operator==
(
FIntrusiveUnsetOptionalState Tag |
Containers/Map.h |