Navigation
Unreal Engine C++ API Reference > Runtime > Core > Containers
Inheritance Hierarchy
- TSortedMap
- FAssetDataTagMap
References
Module | Core |
Header | /Engine/Source/Runtime/Core/Public/Containers/SortedMap.h |
Include | #include "Containers/SortedMap.h" |
Syntax
template<typename InKeyType, typename InValueType, typename ArrayAllocator, typename SortPredicate>
class TSortedMap
Remarks
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.
Constructors
Type | Name | Description | |
---|---|---|---|
![]() |
TSortedMap () |
||
![]() |
TSortedMap
(
TSortedMap&& |
||
![]() |
TSortedMap
(
const TSortedMap& |
||
![]() |
TSortedMap
(
TSortedMap< KeyType, ValueType, OtherArrayAllocator, SortPredicate >&& Other |
Constructor for moving elements from a TSortedMap with a different ArrayAllocator. | |
![]() |
TSortedMap
(
const TSortedMap< KeyType, ValueType, OtherArrayAllocator, SortPredicate >& Other |
Constructor for copying elements from a TSortedMap with a different ArrayAllocator. | |
![]() |
TSortedMap
(
std::initializer_list< TPairInitializer< const KeyType&, const ValueType& >> InitList |
Constructor which gets its elements from a native initializer list |
Functions
Type | Name | Description | |
---|---|---|---|
![]() |
ValueType & | ||
![]() |
ValueType & | ||
![]() |
ValueType & | ||
![]() |
ValueType & | Sets the value associated with a key. | |
![]() |
ValueType & | ||
![]() |
ValueType & | Sets a default value associated with a key. | |
![]() |
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). |
![]() |
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. |
![]() ![]() |
RangedForConstIteratorType | begin () |
|
![]() |
RangedForIteratorType | begin () |
DO NOT USE DIRECTLY STL-like iterators to enable range-based for loop support. |
![]() ![]() |
bool | Contains
(
KeyConstPointerType Key |
Checks if map contains the specified key. |
![]() ![]() |
void | CountBytes
(
FArchive& Ar |
Tracks the container's memory use through an archive. |
![]() ![]() |
TConstIterator | Creates a const iterator over all the pairs in this map | |
![]() ![]() |
TConstKeyIterator | CreateConstKeyIterator
(
KeyInitType 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
(
KeyInitType 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 a default value associated with a key. |
![]() |
ValueType & | Emplace
(
InitKeyType&& InKey, |
Sets the value associated with a key. |
![]() |
void | Empty
(
int32 ExpectedNumElements |
Removes all elements from the map, potentially leaving space allocated for an expected number of elements about to be added. |
![]() ![]() |
RangedForConstIteratorType | end () |
|
![]() |
RangedForIteratorType | end () |
|
![]() ![]() |
const ValueType * | Find
(
KeyConstPointerType Key |
|
![]() |
ValueType * | Find
(
KeyConstPointerType Key |
Returns the value associated with a specified key. |
![]() |
ValueType | Finds a pair with the specified key, removes it from the map, and returns the value part of the pair. | |
![]() ![]() |
const ValueType & | FindChecked
(
KeyConstPointerType Key |
|
![]() |
ValueType & | FindChecked
(
KeyConstPointerType Key |
Returns a reference to the value associated with a specified key. |
![]() ![]() |
const KeyType * | FindKey
(
ValueInitType Value |
Returns the key associated with the specified value. The time taken is O(N) in the number of pairs. |
![]() |
ValueType & | Returns the value associated with a specified key, or if none exists, adds a value using the default constructor. | |
![]() |
ValueType & | ||
![]() ![]() |
ValueType | FindRef
(
KeyConstPointerType Key |
Returns the value associated with a specified key. |
![]() ![]() |
void | GenerateKeyArray
(
TArray< KeyType, Allocator >& OutArray |
Generates an array from the keys in this map. |
![]() ![]() |
void | GenerateValueArray
(
TArray< ValueType, Allocator >& OutArray |
Generates 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 | Returns 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 () |
|
![]() |
int32 | Remove
(
KeyConstPointerType InKey |
Removes all value associations for a key. |
![]() |
bool | RemoveAndCopyValue
(
KeyInitType Key, |
Removes the pair with the specified key and copies the value that was removed to the ref parameter. |
![]() |
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. |
Operators
Type | Name | Description | |
---|---|---|---|
![]() ![]() |
bool | operator!=
(
const TSortedMap& Other |
Inequality operator. This is efficient because pairs are always sorted. |
![]() |
ValueType & | operator[]
(
KeyConstPointerType Key |
|
![]() ![]() |
const ValueType & | operator[]
(
KeyConstPointerType Key |
|
![]() |
TSortedMap & | operator=
(
TSortedMap< KeyType, ValueType, OtherArrayAllocator, SortPredicate >&& Other |
Assignment operator for moving elements from a TSortedMap with a different ArrayAllocator. |
![]() |
TSortedMap & | operator=
(
std::initializer_list< TPairInitializer< const KeyType&, const ValueType& >> InitList |
Assignment operator which gets its elements from a native initializer list |
![]() |
TSortedMap & | operator=
(
TSortedMap&& |
|
![]() |
TSortedMap & | operator=
(
const TSortedMap& |
|
![]() |
TSortedMap & | operator=
(
const TSortedMap< KeyType, ValueType, OtherArrayAllocator, SortPredicate >& Other |
Assignment operator for copying elements from a TSortedMap with a different ArrayAllocator. |
![]() ![]() |
bool | operator==
(
const TSortedMap& Other |
Equality operator. This is efficient because pairs are always sorted. |
Classes
Type | Name | Description | |
---|---|---|---|
![]() |
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 |
Typedefs
Name | Description |
---|---|
ElementArrayType | |
ElementType | |
KeyConstPointerType | |
KeyInitType | |
KeyType | |
RangedForConstIteratorType | |
RangedForIteratorType | Ranged For iterators. |
ValueInitType | |
ValueType |