Navigation
API > API/Runtime > API/Runtime/Core > API/Runtime/Core/Containers
Inheritance Hierarchy
- TMapBase
- TSortableMapBase
- TMap
- FConfigFile
- FLocalizationConfigurationScript
- FConfigFileHierarchy
- FContextCache
- FExample
- FOnlineKeyValuePairs
- FOnlineEventParms
- FScopes
- FSecurityRequirement
- TMultiMap
- FClassResourceMap
- FConfigSection
- TFindObjectReferencers
References
| Module | Core |
| Header | /Engine/Source/Runtime/Core/Public/Containers/Map.h |
| Include | #include "Containers/Map.h" |
Syntax
template<typename KeyType, typename ValueType, typename SetAllocator, typename KeyFuncs>
class TMapBase
Remarks
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.
Variables
| Type | Name | Description | |
|---|---|---|---|
| ElementSetType | Pairs | A set of the key-value pairs in the map. |
Constructors
| Type | Name | Description | |
|---|---|---|---|
TMapBase () |
|||
| Constructor for moving elements from a TMap with a different SetAllocator | |||
| Constructor for copying elements from a TMap with a different SetAllocator |
Functions
| Type | Name | Description | |
|---|---|---|---|
| ValueType & | Add
(
KeyType&& InKey, |
||
| ValueType & | Add
(
KeyType&& InKey, |
||
| ValueType & | Add
(
const KeyType& InKey, |
||
| ValueType & | Add
(
const KeyType& InKey, |
Set the value associated with a key. | |
| ValueType & | |||
| ValueType & | Set the value associated with a key. | ||
| ValueType & | Add
(
KeyType&& InKey |
||
| ValueType & | Add
(
const KeyType& InKey |
Set a default value associated with a key. | |
| ValueType & | AddByHash
(
uint32 KeyHash, |
See Add() and class documentation section on ByHash() functions | |
| ValueType & | AddByHash
(
uint32 KeyHash, |
||
| ValueType & | AddByHash
(
uint32 KeyHash, |
||
| ValueType & | AddByHash
(
uint32 KeyHash, |
||
| ValueType & | AddByHash
(
uint32 KeyHash, |
||
| ValueType & | AddByHash
(
uint32 KeyHash, |
See Add() and class documentation section on ByHash() functions | |
| void | AppendHash
(
const FPlatformTypeLayoutParameters& LayoutParams, |
||
| TArray< ElementType > | Array () |
Copy the key/value pairs in this map into an array. | |
| TRangedForConstIterator | begin () |
||
| TRangedForIterator | begin () |
DO NOT USE DIRECTLY STL-like iterators to enable range-based for loop support. | |
| void | Compact () |
Compacts the pair set to remove holes | |
| void | Compacts the pair set to remove holes. Does not change the iteration order of the elements. | ||
| bool | Contains
(
KeyConstPointerType Key |
Check if map contains the specified key. | |
| bool | ContainsByHash
(
uint32 KeyHash, |
See Contains() and class documentation section on ByHash() functions | |
| void | CopyUnfrozen
(
const FMemoryUnfreezeContent& Context, |
||
| void | CountBytes
(
FArchive& Ar |
Track the container's memory use through an archive. | |
| TConstIterator | Creates a const iterator over all the pairs in this map | ||
| TConstKeyIterator | CreateConstKeyIterator
(
typename TConstKeyIterator::KeyArgumentType InKey |
Creates a const iterator over the values associated with a specified key in a map | |
| TIterator | Creates an iterator over all the pairs in this map | ||
| TKeyIterator | CreateKeyIterator
(
typename TKeyIterator::KeyArgumentType InKey |
Creates an iterator over the values associated with a specified key in a map | |
| void | Dump
(
FOutputDevice& Ar |
Describes the map's contents through an output device. | |
| ValueType & | Emplace
(
InitKeyType&& InKey, |
Sets the value associated with a key. | |
| ValueType & | Emplace
(
InitKeyType&& InKey |
Set a default value associated with a key. | |
| ValueType & | EmplaceByHash
(
uint32 KeyHash, |
See Emplace() and class documentation section on ByHash() functions | |
| ValueType & | EmplaceByHash
(
uint32 KeyHash, |
See Emplace() and class documentation section on ByHash() functions | |
| void | Empty
(
int32 ExpectedNumElements |
Removes all elements from the map. | |
| TRangedForIterator | end () |
||
| TRangedForConstIterator | end () |
||
| TMap< KeyType, ValueType, SetAllocator, KeyFuncs > | FilterByPredicate
(
Predicate Pred |
Filters the elements in the map based on a predicate functor. | |
| ValueType * | Find
(
KeyConstPointerType Key |
Find the value associated with a specified key. | |
| const ValueType * | Find
(
KeyConstPointerType Key |
||
| const ValueType * | FindByHash
(
uint32 KeyHash, |
||
| ValueType * | FindByHash
(
uint32 KeyHash, |
See Find() and class documentation section on ByHash() functions | |
| ValueType & | FindChecked
(
KeyConstPointerType Key |
Find a reference to the value associated with a specified key. | |
| const ValueType & | FindChecked
(
KeyConstPointerType Key |
Find a reference to the value associated with a specified key. | |
| const KeyType * | FindKey
(
ValueInitType Value |
Find the key associated with the specified value.The time taken is O(N) in the number of pairs. | |
| ValueType & | FindOrAdd
(
KeyType&& Key, |
||
| ValueType & | FindOrAdd
(
KeyType&& Key, |
||
| ValueType & | FindOrAdd
(
const KeyType& Key, |
||
| ValueType & | FindOrAdd
(
KeyType&& Key |
||
| ValueType & | FindOrAdd
(
const KeyType& Key |
Find the value associated with a specified key, or if none exists, adds a value using the default constructor. | |
| ValueType & | FindOrAdd
(
const KeyType& Key, |
Find the value associated with a specified key, or if none exists, adds a value using the default constructor. | |
| ValueType & | FindOrAddByHash
(
uint32 KeyHash, |
||
| ValueType & | FindOrAddByHash
(
uint32 KeyHash, |
||
| ValueType & | FindOrAddByHash
(
uint32 KeyHash, |
See FindOrAdd() and class documentation section on ByHash() functions | |
| ValueType & | FindOrAddByHash
(
uint32 KeyHash, |
||
| ValueType & | FindOrAddByHash
(
uint32 KeyHash, |
||
| ValueType & | FindOrAddByHash
(
uint32 KeyHash, |
See FindOrAdd() and class documentation section on ByHash() functions | |
| ValueType | FindRef
(
KeyConstPointerType Key |
Find the value associated with a specified key. | |
| void | GenerateKeyArray
(
TArray< KeyType, Allocator >& OutArray |
Generate an array from the keys in this map. | |
| void | GenerateValueArray
(
TArray< ValueType, Allocator >& OutArray |
Generate an array from the values in this map. | |
| ElementType & | Get
(
FSetElementId Id |
Return a mapped pair by internal identifier. Element must be valid (see ). | |
| const ElementType & | Get
(
FSetElementId Id |
Return a mapped pair by internal identifier. Element must be valid (see ). | |
| SIZE_T | Helper function to return the amount of memory allocated by this container . | ||
| int32 | Get the unique keys contained within this map. | ||
| int32 | Get the unique keys contained within this map. | ||
| int32 | GetMaxIndex () |
||
| bool | IsEmpty () |
Returns true if the map is empty and contains no elements. | |
| bool | IsValidId
(
FSetElementId Id |
Checks whether an element id is valid. | |
| int32 | Num () |
||
| bool | OrderIndependentCompareEqual
(
const TMapBase& Other |
Compare this map with another for equality. | |
| int32 | Remove
(
KeyConstPointerType InKey |
Remove all value associations for a key. | |
| int32 | RemoveByHash
(
uint32 KeyHash, |
See Remove() and class documentation section on ByHash() functions | |
| void | Reserve
(
int32 Number |
Preallocates enough memory to contain Number elements | |
| void | Reset () |
Efficiently empties out the map but preserves all allocations and capacities | |
| void | Shrink () |
Shrinks the pair set to avoid slack. | |
| void | WriteMemoryImage
(
FMemoryImageWriter& Writer |
Operators
| Type | Name | Description | |
|---|---|---|---|
| TMapBase & | Assignment operator for moving elements from a TMap with a different SetAllocator | ||
| TMapBase & | |||
| TMapBase & | |||
| TMapBase & | Assignment operator for copying elements from a TMap with a different SetAllocator |
Classes
| Type | Name | Description | |
|---|---|---|---|
| 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. |