UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FScriptMapHelper Class Reference

#include <UnrealType.h>

+ Inheritance diagram for FScriptMapHelper:

Public Types

using FIterator = TScriptContainerIterator< FScriptMapHelper >
 

Public Member Functions

 FScriptMapHelper (const FMapProperty *InProperty, const void *InMap)
 
 FScriptMapHelper (FProperty *InKeyProp, FProperty *InValueProp, const void *InMap, const FScriptMapLayout &InMapLayout, EMapPropertyFlags InMapFlags)
 
FIterator CreateIterator () const
 
FIterator CreateIterator (const int32 InLogicalIndex) const
 
UE_FORCEINLINE_HINT bool IsValidIndex (int32 InternalIndex) const
 
int32 Num () const
 
int32 NumUnchecked () const
 
int32 GetMaxIndex () const
 
uint8GetPairPtr (int32 InternalIndex)
 
UE_FORCEINLINE_HINT const uint8GetPairPtr (const int32 InternalIndex) const
 
uint8GetKeyPtr (int32 InternalIndex)
 
uint8GetValuePtr (int32 InternalIndex)
 
uint8GetPairPtr (const FIterator Iterator)
 
UE_FORCEINLINE_HINT const uint8GetPairPtr (const FIterator Iterator) const
 
uint8GetKeyPtr (const FIterator Iterator)
 
UE_FORCEINLINE_HINT const uint8GetKeyPtr (const FIterator Iterator) const
 
uint8GetValuePtr (const FIterator Iterator)
 
UE_FORCEINLINE_HINT const uint8GetValuePtr (const FIterator Iterator) const
 
uint8FindNthPairPtr (int32 N)
 
uint8FindNthKeyPtr (int32 N)
 
uint8FindNthValuePtr (int32 N)
 
const uint8FindNthPairPtr (int32 N) const
 
void MoveAssign (void *InOtherMap)
 
int32 AddUninitializedValue ()
 
void EmptyValues (int32 Slack=0)
 
int32 AddDefaultValue_Invalid_NeedsRehash ()
 
FPropertyGetKeyProperty () const
 
FPropertyGetValueProperty () const
 
void RemoveAt (int32 InternalIndex, int32 Count=1)
 
COREUOBJECT_API void Rehash ()
 
int32 FindInternalIndex (int32 LogicalIdx) const
 
int32 FindLogicalIndex (int32 InternalIdx) const
 
int32 FindMapIndexWithKey (const void *PairWithKeyToFind, int32 IndexHint=0) const
 
uint8FindMapPairPtrWithKey (const void *PairWithKeyToFind, int32 IndexHint=0)
 
int32 FindMapPairIndexFromHash (const void *KeyPtr)
 
uint8FindMapPairPtrFromHash (const void *KeyPtr)
 
uint8FindValueFromHash (const void *KeyPtr)
 
void AddPair (const void *KeyPtr, const void *ValuePtr)
 
voidFindOrAdd (const void *KeyPtr)
 
bool RemovePair (const void *KeyPtr)
 

Static Public Member Functions

static FScriptMapHelper CreateHelperFormInnerProperties (FProperty *InKeyProperty, FProperty *InValProperty, const void *InMap, EMapPropertyFlags InMapFlags=EMapPropertyFlags::None)
 

Public Attributes

FPropertyKeyProp
 
FPropertyValueProp
 
union { 
 
   FScriptMap *   HeapMap 
 
   FFreezableScriptMap *   FreezableMap 
 
};  
 
FScriptMapLayout MapLayout
 
EMapPropertyFlags MapFlags
 

Friends

class FMapProperty
 

Detailed Description

FScriptMapHelper: Pseudo dynamic map. Used to work with map properties in a sensible way. Note that map can contain invalid entries some number of valid entries (i.e. Num() ) can be smaller that the actual number of elements (i.e. GetMaxIndex() ).

Internal index naming is used to identify the actual index in the container which can point to an invalid entry. It can be used for methods like Get<Item>Ptr, Get<Item>PtrWithoutCheck or IsValidIndex.

Logical index naming is used to identify only valid entries in the container so it can be smaller than the internal index in case we skipped invalid entries to reach the next valid one. This index is used on method like FindNth<Item>Ptr or FindInternalIndex. This is also the type of index we receive from most editor events (e.g. property change events) so it is strongly suggested to rely on FScriptMapHelper::FIterator to iterate or convert to internal index.

Member Typedef Documentation

◆ FIterator

Constructor & Destructor Documentation

◆ FScriptMapHelper() [1/2]

FScriptMapHelper::FScriptMapHelper ( const FMapProperty InProperty,
const void InMap 
)
inline

Constructor, brings together a property and an instance of the property located in memory

Parameters
InPropertyThe property associated with this memory
InMapPointer to raw memory that corresponds to this map. This can be NULL, and sometimes is, but in that case almost all operations will crash.

◆ FScriptMapHelper() [2/2]

FScriptMapHelper::FScriptMapHelper ( FProperty InKeyProp,
FProperty InValueProp,
const void InMap,
const FScriptMapLayout InMapLayout,
EMapPropertyFlags  InMapFlags 
)
inline

Member Function Documentation

◆ AddDefaultValue_Invalid_NeedsRehash()

int32 FScriptMapHelper::AddDefaultValue_Invalid_NeedsRehash ( )
inline

Adds a blank, constructed value to a given size. Note that this will create an invalid map because all the keys will be default constructed, and the map needs rehashing.

Returns
The index of the first element added.

◆ AddPair()

void FScriptMapHelper::AddPair ( const void KeyPtr,
const void ValuePtr 
)
inline

Adds the (key, value) pair to the map, returning true if the element was added, or false if the element was already present and has been overwritten

◆ AddUninitializedValue()

int32 FScriptMapHelper::AddUninitializedValue ( )
inline

Add an uninitialized value to the end of the map.

Returns
The index of the added element.

◆ CreateHelperFormInnerProperties()

static FScriptMapHelper FScriptMapHelper::CreateHelperFormInnerProperties ( FProperty InKeyProperty,
FProperty InValProperty,
const void InMap,
EMapPropertyFlags  InMapFlags = EMapPropertyFlags::None 
)
inlinestatic

◆ CreateIterator() [1/2]

FIterator FScriptMapHelper::CreateIterator ( ) const
inline

◆ CreateIterator() [2/2]

FIterator FScriptMapHelper::CreateIterator ( const int32  InLogicalIndex) const
inline

◆ EmptyValues()

void FScriptMapHelper::EmptyValues ( int32  Slack = 0)
inline

Remove all values from the map, calling destructors, etc as appropriate.

Parameters
Slackused to presize the set for a subsequent add, to avoid reallocation.

◆ FindInternalIndex()

int32 FScriptMapHelper::FindInternalIndex ( int32  LogicalIdx) const
inline

Maps have gaps in their indices, so this function translates a logical index (ie. Nth element) to an internal index that can be used for the other functions in this class. NOTE: This is slow, do not use this for iteration! Use CreateIterator() instead.

◆ FindLogicalIndex()

int32 FScriptMapHelper::FindLogicalIndex ( int32  InternalIdx) const
inline

Maps have gaps in their indices, so this function translates a internal index to an logical index (ie. Nth element). NOTE: This is slow, do not use this for iteration!

◆ FindMapIndexWithKey()

int32 FScriptMapHelper::FindMapIndexWithKey ( const void PairWithKeyToFind,
int32  IndexHint = 0 
) const
inline

Finds the index of an element in a map which matches the key in another pair.

Parameters
PairWithKeyToFindThe address of a map pair which contains the key to search for.
IndexHintThe index to start searching from.
Returns
The index of an element found in MapHelper, or -1 if none was found.

◆ FindMapPairIndexFromHash()

int32 FScriptMapHelper::FindMapPairIndexFromHash ( const void KeyPtr)
inline

Finds the associated pair from hash, rather than linearly searching

◆ FindMapPairPtrFromHash()

uint8 * FScriptMapHelper::FindMapPairPtrFromHash ( const void KeyPtr)
inline

Finds the associated pair from hash, rather than linearly searching

◆ FindMapPairPtrWithKey()

uint8 * FScriptMapHelper::FindMapPairPtrWithKey ( const void PairWithKeyToFind,
int32  IndexHint = 0 
)
inline

Finds the pair in a map which matches the key in another pair.

Parameters
PairWithKeyToFindThe address of a map pair which contains the key to search for.
IndexHintThe index to start searching from.
Returns
A pointer to the found pair, or nullptr if none was found.

◆ FindNthKeyPtr()

uint8 * FScriptMapHelper::FindNthKeyPtr ( int32  N)
inline

Returns a uint8 pointer to the the Nth valid key in the map (skipping invalid entries). NOTE: This is slow, do not use this for iteration! Use CreateIterator() instead.

Returns
Pointer to the element, or nullptr if the index is invalid.

◆ FindNthPairPtr() [1/2]

uint8 * FScriptMapHelper::FindNthPairPtr ( int32  N)
inline

Returns a uint8 pointer to the the Nth valid pair in the map (skipping invalid entries). NOTE: This is slow, do not use this for iteration! Use CreateIterator() instead.

Returns
Pointer to the element, or nullptr if the index is invalid.

◆ FindNthPairPtr() [2/2]

const uint8 * FScriptMapHelper::FindNthPairPtr ( int32  N) const
inline

Returns a uint8 pointer to the the Nth valid pair in the map (skipping invalid entries). NOTE: This is slow, do not use this for iteration! Use CreateIterator() instead.

Returns
Pointer to the element, or nullptr if the index is invalid.

◆ FindNthValuePtr()

uint8 * FScriptMapHelper::FindNthValuePtr ( int32  N)
inline

Returns a uint8 pointer to the the Nth valid value in the map (skipping invalid entries). NOTE: This is slow, do not use this for iteration! Use CreateIterator() instead.

Returns
Pointer to the element, or nullptr if the index is invalid.

◆ FindOrAdd()

void * FScriptMapHelper::FindOrAdd ( const void KeyPtr)
inline

Finds or adds a new default-constructed value

No need to rehash after calling. The hash table must be properly hashed before calling.

Returns
The address to the value, not the pair

◆ FindValueFromHash()

uint8 * FScriptMapHelper::FindValueFromHash ( const void KeyPtr)
inline

Finds the associated value from hash, rather than linearly searching

◆ GetKeyProperty()

FProperty * FScriptMapHelper::GetKeyProperty ( ) const
inline

Returns the property representing the key of the map pair.

Returns
The property representing the key of the map pair.

◆ GetKeyPtr() [1/3]

uint8 * FScriptMapHelper::GetKeyPtr ( const FIterator  Iterator)
inline

Returns a uint8 pointer to the Key (first element) in the map. Currently identical to GetPairPtr, but provides clarity of purpose and avoids exposing implementation details of TMap.

Parameters
IteratorA valid iterator of the item to return a pointer to.
Returns
Pointer to the key, or will fail a check if an invalid iterator is provided.

◆ GetKeyPtr() [2/3]

UE_FORCEINLINE_HINT const uint8 * FScriptMapHelper::GetKeyPtr ( const FIterator  Iterator) const
inline

Returns a const uint8 pointer to the Key (first element) in the map. Currently identical to GetPairPtr, but provides clarity of purpose and avoids exposing implementation details of TMap.

Parameters
IteratorA valid iterator of the item to return a pointer to.
Returns
Pointer to the key, or will fail a check if an invalid iterator is provided.

◆ GetKeyPtr() [3/3]

uint8 * FScriptMapHelper::GetKeyPtr ( int32  InternalIndex)
inline

Returns a uint8 pointer to the Key (first element) in the map. Currently identical to GetPairPtr, but provides clarity of purpose and avoids exposing implementation details of TMap.

Parameters
InternalIndexindex of the item to return a pointer to.
Returns
Pointer to the key, or nullptr if the map is empty.

◆ GetMaxIndex()

int32 FScriptMapHelper::GetMaxIndex ( ) const
inline

Returns the (non-inclusive) maximum index of elements in the map.

Returns
The (non-inclusive) maximum index of elements in the map.

◆ GetPairPtr() [1/4]

uint8 * FScriptMapHelper::GetPairPtr ( const FIterator  Iterator)
inline

Returns a uint8 pointer to the pair in the map

Parameters
IteratorA valid iterator of the item to return a pointer to.
Returns
Pointer to the pair, or will fail a check if an invalid iterator is provided.

◆ GetPairPtr() [2/4]

UE_FORCEINLINE_HINT const uint8 * FScriptMapHelper::GetPairPtr ( const FIterator  Iterator) const
inline

Returns a uint8 pointer to the pair in the map.

Parameters
IteratorA valid iterator of the item to return a pointer to.
Returns
Pointer to the pair, or will fail a check if an invalid iterator is provided.

◆ GetPairPtr() [3/4]

UE_FORCEINLINE_HINT const uint8 * FScriptMapHelper::GetPairPtr ( const int32  InternalIndex) const
inline

Returns a uint8 pointer to the pair in the map.

Parameters
InternalIndexindex of the item to return a pointer to.
Returns
Pointer to the pair, or nullptr if the map is empty.

◆ GetPairPtr() [4/4]

uint8 * FScriptMapHelper::GetPairPtr ( int32  InternalIndex)
inline

Returns a uint8 pointer to the pair in the map

Parameters
InternalIndexindex of the item to return a pointer to.
Returns
Pointer to the pair, or nullptr if the map is empty.

◆ GetValueProperty()

FProperty * FScriptMapHelper::GetValueProperty ( ) const
inline

Returns the property representing the value of the map pair.

Returns
The property representing the value of the map pair.

◆ GetValuePtr() [1/3]

uint8 * FScriptMapHelper::GetValuePtr ( const FIterator  Iterator)
inline

Returns a uint8 pointer to the Value (second element) in the map.

Parameters
IteratorA valid iterator of the item to return a pointer to.
Returns
Pointer to the value, or will fail a check if an invalid iterator is provided.

◆ GetValuePtr() [2/3]

UE_FORCEINLINE_HINT const uint8 * FScriptMapHelper::GetValuePtr ( const FIterator  Iterator) const
inline

Returns a const uint8 pointer to the Value (second element) in the map.

Parameters
IteratorA valid iterator of the item to return a pointer to.
Returns
Pointer to the value, or will fail a check if an invalid iterator is provided.

◆ GetValuePtr() [3/3]

uint8 * FScriptMapHelper::GetValuePtr ( int32  InternalIndex)
inline

Returns a uint8 pointer to the Value (second element) in the map.

Parameters
InternalIndexindex of the item to return a pointer to.
Returns
Pointer to the value, or nullptr if the map is empty.

◆ IsValidIndex()

UE_FORCEINLINE_HINT bool FScriptMapHelper::IsValidIndex ( int32  InternalIndex) const
inline

Index range check

Parameters
InternalIndexIndex to check
Returns
true if accessing this element is legal.

◆ MoveAssign()

void FScriptMapHelper::MoveAssign ( void InOtherMap)
inline

Move the allocation from another map and make it our own.

Note
The maps MUST be of the same type, and this function will NOT validate that!
Parameters
InOtherMapThe map to move the allocation from.

◆ Num()

int32 FScriptMapHelper::Num ( ) const
inline

Returns the number of elements in the map.

Returns
The number of elements in the map.

◆ NumUnchecked()

int32 FScriptMapHelper::NumUnchecked ( ) const
inline

Returns the number of elements in the map. Needed to allow reading of the num when the map is 'invalid' during its intrusive unset state.

Returns
The number of elements in the map.

◆ Rehash()

void FScriptMapHelper::Rehash ( )

Rehashes the keys in the map. This function must be called to create a valid map.

◆ RemoveAt()

void FScriptMapHelper::RemoveAt ( int32  InternalIndex,
int32  Count = 1 
)
inline

Removes an element at the specified index, destroying it.

Parameters
InternalIndexThe index of the element to remove.

◆ RemovePair()

bool FScriptMapHelper::RemovePair ( const void KeyPtr)
inline

Removes the key and its associated value from the map

Friends And Related Symbol Documentation

◆ FMapProperty

friend class FMapProperty
friend

Member Data Documentation

◆ [union]

union { ... } FScriptMapHelper

◆ FreezableMap

FFreezableScriptMap* FScriptMapHelper::FreezableMap

◆ HeapMap

FScriptMap* FScriptMapHelper::HeapMap

◆ KeyProp

FProperty* FScriptMapHelper::KeyProp

◆ MapFlags

EMapPropertyFlags FScriptMapHelper::MapFlags

◆ MapLayout

FScriptMapLayout FScriptMapHelper::MapLayout

◆ ValueProp

FProperty* FScriptMapHelper::ValueProp

The documentation for this class was generated from the following files: