11template<
typename KeyType,
typename ValueType>
22 return GetTypeHash(Key);
26namespace TSherwoodHashTable_Private
37template <
typename KeyType,
typename ValueType,
typename KeyFuncs = TSherwoodHashKeyFuncs<KeyType, ValueType>>
44 static constexpr bool bIsMap = !std::is_same_v<ValueType, FNoopStruct>;
73 return (T*)FMemory::Malloc(
sizeof(T) *
Count);
162 Result.AllocatedCount =
Count;
234 else if (Data.IsEmpty(Cursor))
238 return bIsMap ? &Data.Values[Cursor] :
nullptr;
242 Swap(Key, Data.Keys[Cursor]);
253 if (Data.IsEmpty(Cursor))
259 else if (Data.Distances[Cursor] <
Distance)
262 Swap(Key, Data.Keys[Cursor]);
351template <
typename KeyType,
typename ValueType,
typename KeyFuncs = TSherwoodHashKeyFuncs<KeyType, ValueType>>
356 return *Table.FindOrAdd(Key,
Value);
361 return Table.Find(Key).Value;
364 const ValueType*
Find(KeyType Key)
const
366 return Table.Find(Key).Value;
371 return Table.NumElements;
393template <
typename KeyType,
typename KeyFuncs = TSherwoodHashKeyFuncs<KeyType, FNoopStruct>>
401 const KeyType*
Find(KeyType Key)
const
403 return Table.Find(Key).Key;
408 return Table.NumElements;
#define FORCEINLINE_DEBUGGABLE
Definition CoreMiscDefines.h:74
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition RobinHoodHashTable.h:18
U16 Index
Definition radfft.cpp:71
Definition SherwoodHashTable.h:13
TTypeTraits< KeyType >::ConstPointerType KeyInitType
Definition SherwoodHashTable.h:14
static FORCEINLINE uint32 GetKeyHash(KeyInitType Key)
Definition SherwoodHashTable.h:20
static FORCEINLINE bool Matches(KeyInitType A, KeyInitType B)
Definition SherwoodHashTable.h:16
Definition SherwoodHashTable.h:82
KeyType * Keys
Definition SherwoodHashTable.h:107
ValueType * Values
Definition SherwoodHashTable.h:108
bool IsValid() const
Definition SherwoodHashTable.h:103
bool IsEmpty(uint32 i) const
Definition SherwoodHashTable.h:88
bool HasValue(uint32 i) const
Definition SherwoodHashTable.h:83
int8 * Distances
Definition SherwoodHashTable.h:106
uint32 AllocatedCount
Definition SherwoodHashTable.h:105
void AddAt(uint32 i, int8 InDistance, KeyType InKey, ValueType InValue)
Definition SherwoodHashTable.h:93
Definition SherwoodHashTable.h:39
TSherwoodHashTable(const TSherwoodHashTable &)=delete
static T * AllocateUninitialized(uint32 Count)
Definition SherwoodHashTable.h:71
void Grow()
Definition SherwoodHashTable.h:333
void Reserve(uint32 DesiredNumElements)
Definition SherwoodHashTable.h:339
void Empty()
Definition SherwoodHashTable.h:137
static uint8 ComputeMaxLookups(uint32 InNumSlots)
Definition SherwoodHashTable.h:152
FORCEINLINE_DEBUGGABLE ValueType * FindOrAddByHash(KeyType Key, HashType Hash, ValueType Value, bool *bIsAlreadyInContainerPtr=nullptr)
Definition SherwoodHashTable.h:199
static void Deallocate(void *Ptr)
Definition SherwoodHashTable.h:76
static constexpr float MaxLoadFactor
Definition SherwoodHashTable.h:53
int32 NumElements
Definition SherwoodHashTable.h:114
~TSherwoodHashTable()
Definition SherwoodHashTable.h:65
TSherwoodHashTable(TSherwoodHashTable &&)=delete
static FData AllocateData(uint32 Count)
Definition SherwoodHashTable.h:158
static constexpr uint32 MinNumLookups
Definition SherwoodHashTable.h:47
FORCEINLINE_DEBUGGABLE ValueType * FindOrAdd(KeyType Key, ValueType Value, bool *bIsAlreadyInContainerPtr=nullptr)
Definition SherwoodHashTable.h:194
FData CurrentData
Definition SherwoodHashTable.h:111
void Reset()
Definition SherwoodHashTable.h:128
void Rehash(uint32 DesiredNumSlots)
Definition SherwoodHashTable.h:287
uint32 NumSlots() const
Definition SherwoodHashTable.h:147
uint32 HashType
Definition SherwoodHashTable.h:40
TSherwoodHashTable & operator=(const TSherwoodHashTable &)=delete
FORCEINLINE_DEBUGGABLE TTuple< const KeyType *, ValueType * > Find(KeyType Key) const
Definition SherwoodHashTable.h:175
uint32 NumSlotsMinusOne
Definition SherwoodHashTable.h:112
static void DeallocateData(FData &Data)
Definition SherwoodHashTable.h:116
FORCENOINLINE ValueType * Add(int8 Distance, FData &Data, uint32 Cursor, KeyType Key, HashType Hash, ValueType Value)
Definition SherwoodHashTable.h:227
static constexpr uint32 MinNumSlots
Definition SherwoodHashTable.h:50
static constexpr bool bIsMap
Definition SherwoodHashTable.h:44
int8 MaxLookups
Definition SherwoodHashTable.h:113
TSherwoodHashTable()=default
Definition SherwoodHashTable.h:353
ValueType * Find(KeyType Key)
Definition SherwoodHashTable.h:359
int32 Num() const
Definition SherwoodHashTable.h:369
void Reset()
Definition SherwoodHashTable.h:379
ValueType & FindOrAdd(KeyType Key, ValueType Value)
Definition SherwoodHashTable.h:354
const ValueType * Find(KeyType Key) const
Definition SherwoodHashTable.h:364
void Reserve(uint32 DesiredNumElements)
Definition SherwoodHashTable.h:384
void Empty()
Definition SherwoodHashTable.h:374
Definition SherwoodHashTable.h:395
const KeyType * Find(KeyType Key) const
Definition SherwoodHashTable.h:401
void Empty()
Definition SherwoodHashTable.h:411
void Reset()
Definition SherwoodHashTable.h:416
void Reserve(uint32 DesiredNumElements)
Definition SherwoodHashTable.h:421
int32 Num() const
Definition SherwoodHashTable.h:406
void Add(KeyType Key, bool *bIsAlreadyInSetPtr=nullptr)
Definition SherwoodHashTable.h:396
static FORCENOINLINE CORE_API void Free(void *Original)
Definition UnrealMemory.cpp:685
static UE_FORCEINLINE_HINT void * Memset(void *Dest, uint8 Char, SIZE_T Count)
Definition UnrealMemory.h:119
Definition UnrealTemplate.h:717
Definition IsTrivial.h:15
TCallTraits< T >::ConstPointerType ConstPointerType
Definition UnrealTypeTraits.h:337