Navigation
API > API/Runtime > API/Runtime/Core
A Map of keys to value, implemented as a sorted TArray of TPairs.
It has a mostly identical interface to TMap and is designed as a drop in replacement. Keys must be unique, there is no equivalent sorted version of TMultiMap. It uses half as much memory as TMap, but adding and removing elements is O(n), and finding is O(Log n). In practice it is faster than TMap for low element counts, and slower as n increases, This map is always kept sorted by the key type so cannot be sorted manually.
| Name | TSortedMap |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Containers/SortedMap.h |
| Include Path | #include "Containers/SortedMap.h" |
Syntax
template<typename InKeyType, typename InValueType, typename ArrayAllocator, typename SortPredicate>
class TSortedMap
Derived Classes
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TSortedMap () |
Containers/SortedMap.h | ||
TSortedMap
(
TSortedMap&& |
Containers/SortedMap.h | ||
TSortedMap
(
const TSortedMap& |
Containers/SortedMap.h | ||
TSortedMap
(
TSortedMap< KeyType, ValueType, OtherArrayAllocator, SortPredicate >&& Other |
Constructor for moving elements from a TSortedMap with a different ArrayAllocator. | Containers/SortedMap.h | |
TSortedMap
(
const TSortedMap< KeyType, ValueType, OtherArrayAllocator, SortPredicate >& Other |
Constructor for copying elements from a TSortedMap with a different ArrayAllocator. | Containers/SortedMap.h | |
TSortedMap
(
std::initializer_list< TPairInitializer< const KeyType&, const ValueType& > > InitList |
Constructor which gets its elements from a native initializer list | Containers/SortedMap.h | |
| Containers/SortedMap.h |
Classes
| Name | Remarks |
|---|---|
| TBaseIterator | The base of TSortedMap iterators |
| TBaseReverseIterator | The base of TSortedMap reverse iterators. |
| TConstIterator | Const map iterator |
| TConstKeyIterator | Iterates over values associated with a specified key in a const map. |
| TConstReverseIterator | Const map iterator |
| TIterator | Map iterator |
| TKeyIterator | Iterates over values associated with a specified key in a map. |
| TReverseIterator | Reverse Map iterator |
Structs
| Name | Remarks |
|---|---|
| FKeyForward | Forwards sorting into Key of pair |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| ElementArrayType | TArray< ElementType, ArrayAllocator > | Containers/SortedMap.h | |
| ElementType | TPair< KeyType, ValueType > | Containers/SortedMap.h | |
| IntrusiveUnsetOptionalStateType | TSortedMap | Containers/SortedMap.h | |
| KeyConstPointerType | TTypeTraits< KeyType >::ConstPointerType | Containers/SortedMap.h | |
| KeyInitType | TTypeTraits< KeyType >::ConstInitType | Containers/SortedMap.h | |
| KeyType | InKeyType | Containers/SortedMap.h | |
| RangedForConstIteratorType | ElementArrayType::RangedForConstIteratorType | Containers/SortedMap.h | |
| RangedForIteratorType | ElementArrayType::RangedForIteratorType | Ranged For iterators. | Containers/SortedMap.h |
| ValueInitType | TTypeTraits< ValueType >::ConstInitType | Containers/SortedMap.h | |
| ValueType | InValueType | Containers/SortedMap.h |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| bHasIntrusiveUnsetOptionalState | bool | Start - intrusive TOptional |
Containers/SortedMap.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| Pairs | ElementArrayType | An array of the key-value pairs in the map | Containers/SortedMap.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
ValueType & Add
(
KeyType&& InKey, |
Containers/SortedMap.h | ||
ValueType & Add
(
KeyType&& InKey, |
Containers/SortedMap.h | ||
ValueType & Add
(
const KeyType& InKey, |
Containers/SortedMap.h | ||
ValueType & Add
(
const KeyType& InKey, |
Sets the value associated with a key. | Containers/SortedMap.h | |
ValueType & Add
(
KeyType&& InKey |
Containers/SortedMap.h | ||
ValueType & Add
(
const KeyType& InKey |
Sets a default value associated with a key. | Containers/SortedMap.h | |
void Append
(
const TSortedMap< KeyType, ValueType, OtherArrayAllocator, OtherSortPredicate >& OtherMap |
Add all items from another map to our map (if any keys are in both, the value from the other map wins). | Containers/SortedMap.h | |
void Append
(
TSortedMap< KeyType, ValueType, OtherArrayAllocator, OtherSortPredicate >&& OtherMap |
Move all items from another map into our map (if any keys are in both, the value from the other map wins) and empty the other map. | Containers/SortedMap.h | |
RangedForConstIteratorType begin () |
Containers/SortedMap.h | ||
RangedForIteratorType begin () |
DO NOT USE DIRECTLY STL-like iterators to enable range-based for loop support. | Containers/SortedMap.h | |
bool Contains
(
KeyConstPointerType Key |
Checks if map contains the specified key. | Containers/SortedMap.h | |
void CountBytes
(
FArchive& Ar |
Tracks the container's memory use through an archive. | Containers/SortedMap.h | |
TConstIterator CreateConstIterator() |
Creates a const iterator over all the pairs in this map | Containers/SortedMap.h | |
TConstKeyIterator CreateConstKeyIterator
(
KeyInitType InKey |
Creates a const iterator over the values associated with a specified key in a map. | Containers/SortedMap.h | |
TIterator CreateIterator() |
Creates an iterator over all the pairs in this map | Containers/SortedMap.h | |
TKeyIterator CreateKeyIterator
(
KeyInitType InKey |
Creates an iterator over the values associated with a specified key in a map. | Containers/SortedMap.h | |
void Dump
(
FOutputDevice& Ar |
Describes the map's contents through an output device. | Containers/SortedMap.h | |
ValueType & Emplace
(
InitKeyType&& InKey, |
Sets the value associated with a key. | Containers/SortedMap.h | |
ValueType & Emplace
(
InitKeyType&& InKey |
Sets a default value associated with a key. | Containers/SortedMap.h | |
void Empty
(
int32 ExpectedNumElements |
Removes all elements from the map, potentially leaving space allocated for an expected number of elements about to be added. | Containers/SortedMap.h | |
RangedForConstIteratorType end () |
Containers/SortedMap.h | ||
RangedForIteratorType end () |
Containers/SortedMap.h | ||
const ValueType * Find
(
KeyConstPointerType Key |
Containers/SortedMap.h | ||
ValueType * Find
(
KeyConstPointerType Key |
Returns the value associated with a specified key. | Containers/SortedMap.h | |
ValueType FindAndRemoveChecked
(
KeyConstPointerType Key |
Finds a pair with the specified key, removes it from the map, and returns the value part of the pair. | Containers/SortedMap.h | |
const ElementType * FindArbitraryElement () |
Containers/SortedMap.h | ||
ElementType * FindArbitraryElement () |
Finds any pair in the map and returns a pointer to it. | Containers/SortedMap.h | |
const ValueType & FindChecked
(
KeyConstPointerType Key |
Containers/SortedMap.h | ||
ValueType & FindChecked
(
KeyConstPointerType Key |
Returns a reference to the value associated with a specified key. | Containers/SortedMap.h | |
const KeyType * FindKey
(
ValueInitType Value |
Returns the key associated with the specified value. The time taken is O(N) in the number of pairs. | Containers/SortedMap.h | |
ValueType & FindOrAdd
(
KeyType&& Key |
Containers/SortedMap.h | ||
ValueType & FindOrAdd
(
const KeyType& Key |
Returns the value associated with a specified key, or if none exists, adds a value using the default constructor. | Containers/SortedMap.h | |
ValueType FindRef
(
KeyConstPointerType Key, |
Returns the value associated with a specified key. | Containers/SortedMap.h | |
ValueType FindRef
(
KeyConstPointerType Key |
Returns the value associated with a specified key. | Containers/SortedMap.h | |
void GenerateKeyArray
(
TArray< KeyType, Allocator >& OutArray |
Generates an array from the keys in this map. | Containers/SortedMap.h | |
void GenerateValueArray
(
TArray< ValueType, Allocator >& OutArray |
Generates an array from the values in this map. | Containers/SortedMap.h | |
ElementType & Get
(
FSetElementId Id |
Return a mapped pair by internal identifier. Element must be valid (see @IsValidId). | Containers/SortedMap.h | |
const ElementType & Get
(
FSetElementId Id |
Return a mapped pair by internal identifier. Element must be valid (see @IsValidId). | Containers/SortedMap.h | |
SIZE_T GetAllocatedSize () |
Helper function to return the amount of memory allocated by this container. | Containers/SortedMap.h | |
int32 GetKeys
(
TArray< KeyType, Allocator >& OutKeys |
Returns the unique keys contained within this map. | Containers/SortedMap.h | |
int32 GetMaxIndex() |
Containers/SortedMap.h | ||
bool IsEmpty () |
Returns true if the map is empty and contains no elements. | Containers/SortedMap.h | |
bool IsValidId
(
FSetElementId Id |
Checks whether an element id is valid. | Containers/SortedMap.h | |
int32 Max() |
Containers/SortedMap.h | ||
int32 Num() |
Containers/SortedMap.h | ||
int32 Remove
(
KeyConstPointerType InKey |
Removes all value associations for a key. | Containers/SortedMap.h | |
bool RemoveAndCopyValue
(
KeyInitType Key, |
Removes the pair with the specified key and copies the value that was removed to the ref parameter. | Containers/SortedMap.h | |
void Reserve
(
int32 Number |
Preallocates enough memory to contain Number elements. | Containers/SortedMap.h | |
void Reset() |
Efficiently empties out the map but preserves all allocations and capacities. | Containers/SortedMap.h | |
void Shrink() |
Shrinks the pair set to avoid slack. | Containers/SortedMap.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
bool operator!=
(
const TSortedMap& Other |
Inequality operator. This is efficient because pairs are always sorted. | Containers/SortedMap.h | |
const ValueType & operator[]
(
KeyConstPointerType Key |
Containers/SortedMap.h | ||
ValueType & operator[]
(
KeyConstPointerType Key |
Containers/SortedMap.h | ||
TSortedMap & operator=
(
const TSortedMap& |
Containers/SortedMap.h | ||
TSortedMap & operator=
(
TSortedMap&& |
Containers/SortedMap.h | ||
TSortedMap & operator=
(
TSortedMap< KeyType, ValueType, OtherArrayAllocator, SortPredicate >&& Other |
End - intrusive TOptional |
Containers/SortedMap.h | |
TSortedMap & operator=
(
std::initializer_list< TPairInitializer< const KeyType&, const ValueType& > > InitList |
Assignment operator which gets its elements from a native initializer list | Containers/SortedMap.h | |
TSortedMap & operator=
(
const TSortedMap< KeyType, ValueType, OtherArrayAllocator, SortPredicate >& Other |
Assignment operator for copying elements from a TSortedMap with a different ArrayAllocator. | Containers/SortedMap.h | |
bool operator==
(
const TSortedMap& Other |
Equality operator. This is efficient because pairs are always sorted. | Containers/SortedMap.h | |
bool operator==
(
FIntrusiveUnsetOptionalState Tag |
Containers/SortedMap.h |