7#include "Containers/Map.h"
54template <
int32 BucketCount,
typename BaseMapType,
typename KeyType,
typename ValueType,
typename SetAllocator,
typename KeyFuncs,
typename LockingPolicy>
57 static_assert(BucketCount > 0,
"The BucketCount needs to be at least 1");
66 typename LockingPolicy::MutexType
Mutex;
92 typename LockingPolicy::ExclusiveLockType
InnerLock;
107#define WITH_STRIPEDMAP_DEBUGGABLE_MUTEX 0
108#if WITH_STRIPEDMAP_DEBUGGABLE_MUTEX
117#undef WITH_STRIPEDMAP_DEBUGGABLE_MUTEX
127 if constexpr (BucketCount == 1)
133 return Hash % BucketCount;
137 template <
typename FunctionType>
143 template <
typename FunctionType>
149 template <
typename LockType,
typename FunctionType>
158 template <
typename LockType,
typename FunctionType>
164 template <
typename LockType,
typename FunctionType>
173 template <
typename LockType,
typename FunctionType>
179 template <
typename FunctionType>
185 template <
typename FunctionType>
191 template <
typename FunctionType>
197 template <
typename FunctionType>
203 template <
typename FunctionType>
209 template <
typename FunctionType>
215 template <
typename FunctionType>
225 template <
typename FunctionType>
269 template <
typename FunctionType>
293 template <
typename UpdateFunctionType>
327 template <
typename InitKeyType = KeyType,
typename InitValueType = ValueType>
388 template <
typename ProduceFunctionType>
396 const ValueType* Result = Bucket.
Map.FindByHash(
Hash,
InKey);
421 template <
typename ProduceFunctionType,
typename ApplyFunctionType>
429 const ValueType* Result = Bucket.
Map.FindByHash(
Hash,
InKey);
457 template <
typename TryProduceFunctionType,
typename ApplyFunctionType>
465 const ValueType* Result = Bucket.
Map.FindByHash(
Hash,
InKey);
474 const ValueType* Result = Bucket.
Map.FindByHash(
Hash,
InKey);
499 template <
typename ProduceFunctionType,
typename ApplyFunctionType>
524 template <
typename TryProduceFunctionType,
typename ApplyFunctionType>
571 template <
typename PredicateType>
580 Map.Remove(ElementId);
594 template <
typename PredicateType>
601 for (
auto It =
Map.CreateIterator(); It; ++It)
642 return Map.FindAndRemoveChecked(
InKey);
710 template <
typename FunctionType>
716 for (
auto& Item :
Map)
729 template <
typename FunctionType>
735 for (
const auto& Item :
Map)
749 template<
typename Allocator>
759 OutKeys.Add(Pair.Key);
760 VisitedKeys.Add(Pair.Key);
779class TStripedMap :
public TStripedMapBase<BucketCount, TMap<KeyType, ValueType, SetAllocator, KeyFuncs>, KeyType, ValueType, SetAllocator, KeyFuncs, LockingPolicy>
796class TStripedMultiMap :
public TStripedMapBase<BucketCount, TMultiMap<KeyType, ValueType, SetAllocator, KeyFuncs>, KeyType, ValueType, SetAllocator, KeyFuncs, LockingPolicy>
808 template<
typename Allocator>
#define check(expr)
Definition AssertionMacros.h:314
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
FTransactionallySafeStripedMapLockingPolicy FDefaultStripedMapLockingPolicy
Definition StripedMap.h:37
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTempIfPossible(T &&Obj) noexcept
Definition UnrealTemplate.h:538
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
Definition ContainerAllocationPolicies.h:1660
Definition SetUtilities.h:95
UE_FORCEINLINE_HINT bool IsValidId() const
Definition SetUtilities.h:101
Definition StripedMap.h:56
LockingPolicy::SharedLockType SharedLockType
Definition StripedMap.h:115
bool RemoveAndCopyValue(KeyConstPointerType InKey, ValueType &OutRemovedValue)
Definition StripedMap.h:622
void Add(KeyType &&InKey, const ValueType &InValue)
Definition StripedMap.h:365
void Shrink()
Definition StripedMap.h:670
int32 Remove(KeyConstPointerType InKey)
Definition StripedMap.h:553
decltype(auto) Read(KeyConstPointerType InKey, FunctionType &&InFunction) const
Definition StripedMap.h:204
decltype(auto) ApplyUnlockedByHash(uint32 InHash, FunctionType &&InFunction)
Definition StripedMap.h:138
int32 RemoveByHash(uint32 InKeyHash, KeyConstPointerType InKey)
Definition StripedMap.h:559
decltype(auto) ReadByHash(uint32 InHash, KeyConstPointerType InKey, FunctionType &&InFunction) const
Definition StripedMap.h:210
void Add(KeyType &&InKey, ValueType &&InValue)
Definition StripedMap.h:376
ValueType FindAndRemoveChecked(KeyConstPointerType InKey)
Definition StripedMap.h:638
BaseMapType::KeyConstPointerType KeyConstPointerType
Definition StripedMap.h:60
ValueType FindRef(KeyConstPointerType InKey) const
Definition StripedMap.h:244
struct TStripedMapBase::FBucket Buckets[BucketCount]
void ForEach(FunctionType &&InFunction)
Definition StripedMap.h:711
ValueType FindOrProduce(const KeyType &InKey, ProduceFunctionType &&InProduceFunction)
Definition StripedMap.h:389
void Emplace(InitKeyType &&InKey, InitValueType &&InValue)
Definition StripedMap.h:328
KeyFuncs KeyFuncsType
Definition StripedMap.h:61
decltype(auto) ReadByHash(uint32 InHash, KeyConstPointerType InKey, FunctionType &&InFunction)
Definition StripedMap.h:198
void ForEach(FunctionType &&InFunction) const
Definition StripedMap.h:730
void FindOrProduceAndApplyForWrite(const KeyType &InKey, ProduceFunctionType &&InProduceFunction, ApplyFunctionType &&InApplyFunction)
Definition StripedMap.h:500
decltype(auto) Apply(KeyConstPointerType InKey, FunctionType &&InFunction) const
Definition StripedMap.h:159
bool FindOrTryProduceAndApplyForWrite(const KeyType &InKey, TryProduceFunctionType &&InTryProduceFunction, ApplyFunctionType &&InApplyFunction)
Definition StripedMap.h:525
decltype(auto) Write(KeyConstPointerType InKey, FunctionType &&InFunction)
Definition StripedMap.h:180
void ForEachMap(FunctionType &&InFunction)
Definition StripedMap.h:216
void ForEachMap(FunctionType &&InFunction) const
Definition StripedMap.h:226
decltype(auto) ApplyUnlocked(KeyConstPointerType InKey, FunctionType &&InFunction)
Definition StripedMap.h:144
decltype(auto) Apply(KeyConstPointerType InKey, FunctionType &&InFunction)
Definition StripedMap.h:174
void Empty()
Definition StripedMap.h:648
int32 GetKeys(TArray< KeyType, Allocator > &OutKeys) const
Definition StripedMap.h:750
void Compact()
Definition StripedMap.h:681
decltype(auto) ApplyByHash(uint32 InHash, FunctionType &&InFunction) const
Definition StripedMap.h:150
LockingPolicy::MutexType MutexType
Definition StripedMap.h:113
BaseMapType MapType
Definition StripedMap.h:59
int32 RemoveIf(PredicateType &&InPredicate)
Definition StripedMap.h:595
bool FindAndApply(KeyConstPointerType InKey, UpdateFunctionType &&InUpdateFunction)
Definition StripedMap.h:294
int32 Num() const
Definition StripedMap.h:692
bool FindAndApply(KeyConstPointerType InKey, FunctionType &&InFunction) const
Definition StripedMap.h:270
void Reset()
Definition StripedMap.h:659
decltype(auto) WriteByHash(uint32 InHash, KeyConstPointerType InKey, FunctionType &&InFunction)
Definition StripedMap.h:186
void Add(const KeyType &InKey, ValueType &&InValue)
Definition StripedMap.h:354
void FindOrProduceAndApply(const KeyType &InKey, ProduceFunctionType &&InProduceFunction, ApplyFunctionType &&InApplyFunction)
Definition StripedMap.h:422
LockingPolicy::ExclusiveLockType ExclusiveLockType
Definition StripedMap.h:114
bool Contains(KeyConstPointerType InKey) const
Definition StripedMap.h:316
decltype(auto) ApplyByHash(uint32 InHash, FunctionType &&InFunction)
Definition StripedMap.h:165
void Add(const KeyType &InKey, const ValueType &InValue)
Definition StripedMap.h:343
uint32 GetBucketIndex(uint32 Hash) const
Definition StripedMap.h:125
decltype(auto) Read(KeyConstPointerType InKey, FunctionType &&InFunction)
Definition StripedMap.h:192
int32 RemoveIf(KeyConstPointerType InKey, PredicateType &&InPredicate)
Definition StripedMap.h:572
bool FindOrTryProduceAndApply(const KeyType &InKey, TryProduceFunctionType &&InTryProduceFunction, ApplyFunctionType &&InApplyFunction)
Definition StripedMap.h:458
Definition StripedMap.h:780
Definition StripedMap.h:797
void MultiFind(typename Super::KeyConstPointerType InKey, TArray< ValueType, Allocator > &OutValues, bool bMaintainOrder=false) const
Definition StripedMap.h:809
Definition SharedMutex.h:22
Definition ScopeRWLock.h:21
Definition SharedLock.h:22
Definition UniqueLock.h:20
Definition ScopeRWLock.h:60
static uint32 GetCurrentThreadId(void)
Definition AndroidPlatformTLS.h:20
Definition StripedMap.h:19
UE::FSharedMutex MutexType
Definition StripedMap.h:20
UE::TUniqueLock< UE::FSharedMutex > ExclusiveLockType
Definition StripedMap.h:21
UE::TSharedLock< UE::FSharedMutex > SharedLockType
Definition StripedMap.h:22
Definition StripedMap.h:29
UE::TReadScopeLock< MutexType > SharedLockType
Definition StripedMap.h:32
FTransactionallySafeRWLock MutexType
Definition StripedMap.h:30
UE::TWriteScopeLock< MutexType > ExclusiveLockType
Definition StripedMap.h:31
Definition StripedMap.h:120
MutexType Lock
Definition StripedMap.h:121
MapType Map
Definition StripedMap.h:122
Definition StripedMap.h:90
FDebuggableMutex & DebuggableMutex
Definition StripedMap.h:91
LockingPolicy::ExclusiveLockType InnerLock
Definition StripedMap.h:92
FDebuggableExclusiveLock(FDebuggableMutex &InDebuggableMutex)
Definition StripedMap.h:93
~FDebuggableExclusiveLock()
Definition StripedMap.h:101
Definition StripedMap.h:65
uint32 ExclusiveLockOwnerThreadId
Definition StripedMap.h:67
std::atomic< uint32 > SharedLockCount
Definition StripedMap.h:68
LockingPolicy::MutexType Mutex
Definition StripedMap.h:66
Definition StripedMap.h:72
FDebuggableMutex & DebuggableMutex
Definition StripedMap.h:73
~FDebuggableSharedLock()
Definition StripedMap.h:83
LockingPolicy::SharedLockType InnerLock
Definition StripedMap.h:74
FDebuggableSharedLock(FDebuggableMutex &InDebuggableMutex)
Definition StripedMap.h:75