Navigation
API > API/Runtime > API/Runtime/Core
The base class of striped maps which is a wrapper that adds thread-safety and contention reduction over regular maps.
The interface is slightly modified compared to regular maps to avoid some thread-safety issues that would arise if we returned pointers or reference to memory inside the map after the lock on a bucket had been released.
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. This class manage this automatically so you don't have to work with ByHash function in this case.
| Name | TStripedMapBase |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Containers/StripedMap.h |
| Include Path | #include "Containers/StripedMap.h" |
Syntax
template<int32 BucketCount, typename BaseMapType, typename KeyType, typename ValueType, typename SetAllocator, typename KeyFuncs, typename LockingPolicy>
class TStripedMapBase
Derived Classes
Structs
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| ExclusiveLockType | LockingPolicy::ExclusiveLockType | Containers/StripedMap.h | |
| KeyConstPointerType | BaseMapType::KeyConstPointerType | Containers/StripedMap.h | |
| KeyFuncsType | KeyFuncs | Containers/StripedMap.h | |
| KeyInitType | BaseMapType::KeyInitType | Containers/StripedMap.h | |
| MapType | BaseMapType | Containers/StripedMap.h | |
| MutexType | LockingPolicy::MutexType | Containers/StripedMap.h | |
| SharedLockType | LockingPolicy::SharedLockType | Containers/StripedMap.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void Add
(
KeyType&& InKey, |
Set the value associated with a key. | Containers/StripedMap.h | |
void Add
(
KeyType&& InKey, |
Set the value associated with a key. | Containers/StripedMap.h | |
void Add
(
const KeyType& InKey, |
Set the value associated with a key. | Containers/StripedMap.h | |
void Add
(
const KeyType& InKey, |
Set the value associated with a key. | Containers/StripedMap.h | |
void Compact() |
Compacts the pair set to remove holes | Containers/StripedMap.h | |
bool Contains
(
KeyInitType InKey |
Check if map contains the specified key. | Containers/StripedMap.h | |
void Emplace
(
InitKeyType&& InKey, |
Sets the value associated with a key. | Containers/StripedMap.h | |
void Empty() |
Removes all elements from the map. | Containers/StripedMap.h | |
bool FindAndApply
(
KeyInitType InKey, |
Calls a function when the value is found while holding a lock on the map. | Containers/StripedMap.h | |
bool FindAndApply
(
KeyInitType InKey, |
Calls a function to update a value if it has been found. | Containers/StripedMap.h | |
ValueType FindAndRemoveChecked
(
KeyInitType InKey |
Find a pair with the specified key, removes it from the map, and returns the value part of the pair. | Containers/StripedMap.h | |
ValueType FindOrProduce
(
const KeyType& InKey, |
Finds or produce a value associated with the key. | Containers/StripedMap.h | |
void FindOrProduceAndApply
(
const KeyType& InKey, |
Calls ProduceFunction to produce a value if the key is missing, then calls ApplyFunction on the value. | Containers/StripedMap.h | |
void FindOrProduceAndApplyForWrite
(
const KeyType& InKey, |
Calls ProduceFunction to produce a value if the key is missing, then calls ApplyFunction on the value. | Containers/StripedMap.h | |
bool FindOrTryProduceAndApply
(
const KeyType& InKey, |
Calls TryProduceFunction to produce a value if the key is missing, then calls ApplyFunction on the value if one exists. | Containers/StripedMap.h | |
bool FindOrTryProduceAndApplyForWrite
(
const KeyType& InKey, |
Calls TryProduceFunction to produce a value if the key is missing, then calls ApplyFunction on the value if one exists. | Containers/StripedMap.h | |
ValueType FindRef
(
KeyInitType InKey |
Gets you a copy of the value. | Containers/StripedMap.h | |
void ForEach
(
FunctionType&& InFunction |
Calls a function on all elements of the map with shared access (elements can only be read). | Containers/StripedMap.h | |
void ForEach
(
FunctionType&& InFunction |
Calls a function on all elements of the map with exclusive access (elements can be modified). | Containers/StripedMap.h | |
SIZE_T GetAllocatedSize () |
Helper function to return the amount of memory allocated by this container. | Containers/StripedMap.h | |
int32 GetKeys
(
TArray< KeyType, Allocator >& OutKeys |
Get the unique keys contained within this map. | Containers/StripedMap.h | |
int32 Num() |
Containers/StripedMap.h | ||
void ParallelForEach
(
FunctionType&& InFunction |
Calls a function on all elements of the map with shared access (elements can only be read). | Containers/StripedMap.h | |
void ParallelForEach
(
FunctionType&& InFunction |
Calls a function on all elements of the map with exclusive access (elements can be modified). | Containers/StripedMap.h | |
int32 ParallelRemoveIf
(
PredicateType&& InPredicate |
Removes all elements where the predicate returns true. | Containers/StripedMap.h | |
int32 Remove
(
KeyInitType InKey |
Remove all value associations for a key. | Containers/StripedMap.h | |
bool RemoveAndCopyValue
(
KeyInitType InKey, |
Remove the pair with the specified key and copies the value that was removed to the ref parameter | Containers/StripedMap.h | |
int32 RemoveByHash
(
uint32 InKeyHash, |
See Remove() and class documentation section on ByHash() functions | Containers/StripedMap.h | |
int32 RemoveIf
(
KeyInitType InKey, |
Removes only the element associated by the key if the predicate returns true. | Containers/StripedMap.h | |
int32 RemoveIf
(
PredicateType&& InPredicate |
Removes all elements where the predicate returns true. | Containers/StripedMap.h | |
void Reserve
(
int32 Number |
Reserves memory such that the map can contain at least Number elements. | Containers/StripedMap.h | |
void Reset() |
Efficiently empties out the map but preserves all allocations and capacities | Containers/StripedMap.h | |
void Shrink() |
Shrinks the pair set to avoid slack. | Containers/StripedMap.h |
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
decltype(auto) Apply
(
KeyInitType InKey, |
Containers/StripedMap.h | ||
decltype(auto) Apply
(
KeyInitType InKey, |
Containers/StripedMap.h | ||
decltype(auto) ApplyByHash
(
uint32 InHash, |
Containers/StripedMap.h | ||
decltype(auto) ApplyByHash
(
uint32 InHash, |
Containers/StripedMap.h | ||
decltype(auto) ApplyUnlocked
(
KeyInitType InKey, |
Containers/StripedMap.h | ||
decltype(auto) ApplyUnlockedByHash
(
uint32 InHash, |
Containers/StripedMap.h | ||
void ForEachMap
(
FunctionType&& InFunction |
Containers/StripedMap.h | ||
void ForEachMap
(
FunctionType&& InFunction |
Containers/StripedMap.h | ||
uint32 GetBucketIndex
(
uint32 Hash |
Containers/StripedMap.h | ||
void ParallelForEachMap
(
FunctionType&& InFunction |
Containers/StripedMap.h | ||
void ParallelForEachMap
(
FunctionType&& InFunction |
Containers/StripedMap.h | ||
decltype(auto) Read
(
KeyInitType InKey, |
Containers/StripedMap.h | ||
decltype(auto) Read
(
KeyInitType InKey, |
Containers/StripedMap.h | ||
decltype(auto) ReadByHash
(
uint32 InHash, |
Containers/StripedMap.h | ||
decltype(auto) ReadByHash
(
uint32 InHash, |
Containers/StripedMap.h | ||
decltype(auto) Write
(
KeyInitType InKey, |
Containers/StripedMap.h | ||
decltype(auto) WriteByHash
(
uint32 InHash, |
Containers/StripedMap.h |