engine
 
载入中...
搜索中...
未找到
类 | Public 成员函数 | Protected 成员函数 | Protected 属性 | 友元 | 所有成员列表
TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs > 模板类 参考

The base class of maps from keys to values. 更多...

#include <Map.h>

+ 类 TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs > 继承关系图:

类

class  TBaseIterator
 The base of TMapBase iterators. 更多...
 
class  TBaseKeyIterator
 The base type of iterators that iterate over the values associated with a specified key. 更多...
 
class  TConstIterator
 Const map iterator. 更多...
 
class  TConstKeyIterator
 Iterates over values associated with a specified key in a const map. 更多...
 
class  TIterator
 Map iterator. 更多...
 
class  TKeyIterator
 Iterates over values associated with a specified key in a map. 更多...
 

Public 成员函数

FORCEINLINE ValueType & Add (const KeyType &InKey)
 Set a default value associated with a key. 更多...
 
FORCEINLINE ValueType & Add (const KeyType &InKey, const ValueType &InValue)
 Set the value associated with a key. 更多...
 
FORCEINLINE ValueType & Add (const TTuple< KeyType, ValueType > &InKeyValue)
 Set the value associated with a key. 更多...
 
FORCEINLINE ValueType & AddByHash (uint32 KeyHash, const KeyType &InKey)
 See Add() and class documentation section on ByHash() functions
 
FORCEINLINE ValueType & AddByHash (uint32 KeyHash, const KeyType &InKey, const ValueType &InValue)
 See Add() and class documentation section on ByHash() functions
 
FORCEINLINE TRangedForIterator begin ()
 DO NOT USE DIRECTLY STL-like iterators to enable range-based for loop support.
 
FORCEINLINE void Compact ()
 Compacts the pair set to remove holes
 
FORCEINLINE void CompactStable ()
 Compacts the pair set to remove holes. 更多...
 
FORCEINLINE bool Contains (KeyConstPointerType Key) const
 Check if map contains the specified key. 更多...
 
template<typename ComparableKey >
FORCEINLINE bool ContainsByHash (uint32 KeyHash, const ComparableKey &Key) const
 See Contains() and class documentation section on ByHash() functions
 
FORCEINLINE void CountBytes (FArchive &Ar) const
 Track the container's memory use through an archive. 更多...
 
FORCEINLINE TConstIterator CreateConstIterator () const
 Creates a const iterator over all the pairs in this map
 
FORCEINLINE TConstKeyIterator CreateConstKeyIterator (KeyInitType InKey) const
 Creates a const iterator over the values associated with a specified key in a map
 
FORCEINLINE TIterator CreateIterator ()
 Creates an iterator over all the pairs in this map
 
FORCEINLINE 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. 更多...
 
template<typename InitKeyType >
ValueType & Emplace (InitKeyType &&InKey)
 Set a default value associated with a key. 更多...
 
template<typename InitKeyType , typename InitValueType >
ValueType & Emplace (InitKeyType &&InKey, InitValueType &&InValue)
 Sets the value associated with a key. 更多...
 
template<typename InitKeyType >
ValueType & EmplaceByHash (uint32 KeyHash, InitKeyType &&InKey)
 See Emplace() and class documentation section on ByHash() functions
 
template<typename InitKeyType , typename InitValueType >
ValueType & EmplaceByHash (uint32 KeyHash, InitKeyType &&InKey, InitValueType &&InValue)
 See Emplace() and class documentation section on ByHash() functions
 
FORCEINLINE void Empty (int32 ExpectedNumElements=0)
 Removes all elements from the map. 更多...
 
FORCEINLINE ValueType * Find (KeyConstPointerType Key)
 Find the value associated with a specified key. 更多...
 
template<typename ComparableKey >
FORCEINLINE ValueType * FindByHash (uint32 KeyHash, const ComparableKey &Key)
 See Find() and class documentation section on ByHash() functions
 
FORCEINLINE ValueType & FindChecked (KeyConstPointerType Key)
 Find a reference to the value associated with a specified key. 更多...
 
FORCEINLINE const ValueType & FindChecked (KeyConstPointerType Key) const
 Find a reference to the value associated with a specified key. 更多...
 
const KeyType * FindKey (ValueInitType Value) const
 Find the key associated with the specified value. 更多...
 
FORCEINLINE ValueType & FindOrAdd (const KeyType &Key)
 Find the value associated with a specified key, or if none exists, adds a value using the default constructor. 更多...
 
FORCEINLINE ValueType & FindOrAdd (const KeyType &Key, const ValueType &Value)
 Find the value associated with a specified key, or if none exists, adds a value using the default constructor. 更多...
 
FORCEINLINE ValueType & FindOrAddByHash (uint32 KeyHash, const KeyType &Key)
 See FindOrAdd() and class documentation section on ByHash() functions
 
FORCEINLINE ValueType & FindOrAddByHash (uint32 KeyHash, const KeyType &Key, const ValueType &Value)
 See FindOrAdd() and class documentation section on ByHash() functions
 
FORCEINLINE ValueType FindRef (KeyConstPointerType Key) const
 Find the value associated with a specified key. 更多...
 
template<typename Allocator >
void GenerateKeyArray (TArray< KeyType, Allocator > &OutArray) const
 Generate an array from the keys in this map. 更多...
 
template<typename Allocator >
void GenerateValueArray (TArray< ValueType, Allocator > &OutArray) const
 Generate an array from the values in this map. 更多...
 
FORCEINLINE uint32 GetAllocatedSize () const
 Helper function to return the amount of memory allocated by this container . 更多...
 
template<typename Allocator >
int32 GetKeys (TArray< KeyType, Allocator > &OutKeys) const
 Get the unique keys contained within this map. 更多...
 
template<typename Allocator >
int32 GetKeys (TSet< KeyType, Allocator > &OutKeys) const
 Get the unique keys contained within this map. 更多...
 
FORCEINLINE int32 Num () const
 
bool OrderIndependentCompareEqual (const TMapBase &Other) const
 Compare this map with another for equality. 更多...
 
FORCEINLINE int32 Remove (KeyConstPointerType InKey)
 Remove all value associations for a key. 更多...
 
template<typename ComparableKey >
FORCEINLINE int32 RemoveByHash (uint32 KeyHash, const ComparableKey &Key)
 See Remove() and class documentation section on ByHash() functions
 
FORCEINLINE void Reserve (int32 Number)
 Preallocates enough memory to contain Number elements
 
FORCEINLINE void Reset ()
 Efficiently empties out the map but preserves all allocations and capacities
 
FORCEINLINE void Shrink ()
 Shrinks the pair set to avoid slack.
 

Protected 成员函数

template<typename OtherSetAllocator >
TMapBase & operator= (const TMapBase< KeyType, ValueType, OtherSetAllocator, KeyFuncs > &Other)
 Assignment operator for copying elements from a TMap with a different SetAllocator
 
template<typename OtherSetAllocator >
TMapBase & operator= (TMapBase< KeyType, ValueType, OtherSetAllocator, KeyFuncs > &&Other)
 Assignment operator for moving elements from a TMap with a different SetAllocator
 
template<typename OtherSetAllocator >
 TMapBase (const TMapBase< KeyType, ValueType, OtherSetAllocator, KeyFuncs > &Other)
 Constructor for copying elements from a TMap with a different SetAllocator
 
template<typename OtherSetAllocator >
 TMapBase (TMapBase< KeyType, ValueType, OtherSetAllocator, KeyFuncs > &&Other)
 Constructor for moving elements from a TMap with a different SetAllocator
 

Protected 属性

ElementSetType Pairs
 A set of the key-value pairs in the map.
 

友元

FORCEINLINE friend FArchive & operator<< (FArchive &Ar, TMapBase &Map)
 Serializer.
 
FORCEINLINE friend void operator<< (FStructuredArchive::FSlot Slot, TMapBase &InMap)
 Structured archive serializer.
 

详细描述

template<typename KeyType, typename ValueType, typename SetAllocator, typename KeyFuncs>
class TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >

The base class of maps from keys to values.

Implemented using a TSet of key-value pairs with a custom KeyFuncs, with the same O(1) addition, removal, and finding.

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. It is often important to incur the cache misses of reading key data and doing the hashing before acquiring the lock.

成员函数说明

◆ Add() [1/3]

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
FORCEINLINE ValueType & TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::Add ( const KeyType &  InKey)
inline

Set a default value associated with a key.

参数
InKeyThe key to associate the value with.
返回
A reference to the value as stored in the map. The reference is only valid until the next change to any key in the map.

◆ Add() [2/3]

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
FORCEINLINE ValueType & TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::Add ( const KeyType &  InKey,
const ValueType &  InValue 
)
inline

Set the value associated with a key.

参数
InKeyThe key to associate the value with.
InValueThe value to associate with the key.
返回
A reference to the value as stored in the map. The reference is only valid until the next change to any key in the map.

◆ Add() [3/3]

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
FORCEINLINE ValueType & TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::Add ( const TTuple< KeyType, ValueType > &  InKeyValue)
inline

Set the value associated with a key.

参数
InKeyValueA Tuple containing the Key and Value to associate together
返回
A reference to the value as stored in the map. The reference is only valid until the next change to any key in the map.

◆ CompactStable()

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
FORCEINLINE void TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::CompactStable ( )
inline

Compacts the pair set to remove holes.

Does not change the iteration order of the elements.

◆ Contains()

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
FORCEINLINE bool TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::Contains ( KeyConstPointerType  Key) const
inline

Check if map contains the specified key.

参数
KeyThe key to check for.
返回
true if the map contains the key.

◆ CountBytes()

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
FORCEINLINE void TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::CountBytes ( FArchive &  Ar) const
inline

Track the container's memory use through an archive.

参数
ArThe archive to use.
参见
GetAllocatedSize

◆ Dump()

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
void TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::Dump ( FOutputDevice &  Ar)
inline

Describes the map's contents through an output device.

参数
ArThe output device to describe the map's contents through.

◆ Emplace() [1/2]

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
template<typename InitKeyType >
ValueType & TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::Emplace ( InitKeyType &&  InKey)
inline

Set a default value associated with a key.

参数
InKeyThe key to associate the value with.
返回
A reference to the value as stored in the map. The reference is only valid until the next change to any key in the map.

◆ Emplace() [2/2]

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
template<typename InitKeyType , typename InitValueType >
ValueType & TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::Emplace ( InitKeyType &&  InKey,
InitValueType &&  InValue 
)
inline

Sets the value associated with a key.

参数
InKeyThe key to associate the value with.
InValueThe value to associate with the key.
返回
A reference to the value as stored in the map. The reference is only valid until the next change to any key in the map.

◆ Empty()

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
FORCEINLINE void TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::Empty ( int32  ExpectedNumElements = 0)
inline

Removes all elements from the map.

This method potentially leaves space allocated for an expected number of elements about to be added.

参数
ExpectedNumElementsThe number of elements about to be added to the set.

◆ Find()

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
FORCEINLINE ValueType * TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::Find ( KeyConstPointerType  Key)
inline

Find the value associated with a specified key.

参数
KeyThe key to search for.
返回
A pointer to the value associated with the specified key, or nullptr if the key isn't contained in this map. The pointer is only valid until the next change to any key in the map.

◆ FindChecked() [1/2]

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
FORCEINLINE ValueType & TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::FindChecked ( KeyConstPointerType  Key)
inline

Find a reference to the value associated with a specified key.

参数
KeyThe key to search for.
返回
The value associated with the specified key, or triggers an assertion if the key does not exist.

◆ FindChecked() [2/2]

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
FORCEINLINE const ValueType & TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::FindChecked ( KeyConstPointerType  Key) const
inline

Find a reference to the value associated with a specified key.

参数
KeyThe key to search for.
返回
The value associated with the specified key, or triggers an assertion if the key does not exist.

◆ FindKey()

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
const KeyType * TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::FindKey ( ValueInitType  Value) const
inline

Find the key associated with the specified value.

The time taken is O(N) in the number of pairs.

参数
ValueThe value to search for
返回
A pointer to the key associated with the specified value, or nullptr if the value isn't contained in this map. The pointer is only valid until the next change to any key in the map.

◆ FindOrAdd() [1/2]

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
FORCEINLINE ValueType & TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::FindOrAdd ( const KeyType &  Key)
inline

Find the value associated with a specified key, or if none exists, adds a value using the default constructor.

参数
KeyThe key to search for.
返回
A reference to the value associated with the specified key.

◆ FindOrAdd() [2/2]

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
FORCEINLINE ValueType & TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::FindOrAdd ( const KeyType &  Key,
const ValueType &  Value 
)
inline

Find the value associated with a specified key, or if none exists, adds a value using the default constructor.

参数
KeyThe key to search for.
ValueThe value to associate with the key.
返回
A reference to the value associated with the specified key.

◆ FindRef()

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
FORCEINLINE ValueType TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::FindRef ( KeyConstPointerType  Key) const
inline

Find the value associated with a specified key.

参数
KeyThe key to search for.
返回
The value associated with the specified key, or the default value for the ValueType if the key isn't contained in this map.

◆ GenerateKeyArray()

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
template<typename Allocator >
void TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::GenerateKeyArray ( TArray< KeyType, Allocator > &  OutArray) const
inline

Generate an array from the keys in this map.

参数
OutArrayWill contain the collection of keys.

◆ GenerateValueArray()

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
template<typename Allocator >
void TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::GenerateValueArray ( TArray< ValueType, Allocator > &  OutArray) const
inline

Generate an array from the values in this map.

参数
OutArrayWill contain the collection of values.

◆ GetAllocatedSize()

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
FORCEINLINE uint32 TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::GetAllocatedSize ( ) const
inline

Helper function to return the amount of memory allocated by this container .

Only returns the size of allocations made directly by the container, not the elements themselves.

返回
Number of bytes allocated by this container.
参见
CountBytes

◆ GetKeys() [1/2]

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
template<typename Allocator >
int32 TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::GetKeys ( TArray< KeyType, Allocator > &  OutKeys) const
inline

Get the unique keys contained within this map.

参数
OutKeysUpon return, contains the set of unique keys in this map.
返回
The number of unique keys in the map.

◆ GetKeys() [2/2]

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
template<typename Allocator >
int32 TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::GetKeys ( TSet< KeyType, Allocator > &  OutKeys) const
inline

Get the unique keys contained within this map.

参数
OutKeysUpon return, contains the set of unique keys in this map.
返回
The number of unique keys in the map.

◆ Num()

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
FORCEINLINE int32 TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::Num ( ) const
inline
返回
The number of elements in the map.

◆ OrderIndependentCompareEqual()

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
bool TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::OrderIndependentCompareEqual ( const TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs > &  Other) const
inline

Compare this map with another for equality.

Does not make any assumptions about Key order. NOTE: this might be a candidate for operator== but it was decided to make it an explicit function since it can potentially be quite slow.

参数
OtherThe other map to compare against
返回
True if both this and Other contain the same keys with values that compare ==

◆ Remove()

template<typename KeyType , typename ValueType , typename SetAllocator , typename KeyFuncs >
FORCEINLINE int32 TMapBase< KeyType, ValueType, SetAllocator, KeyFuncs >::Remove ( KeyConstPointerType  InKey)
inline

Remove all value associations for a key.

参数
InKeyThe key to remove associated values for.
返回
The number of values that were associated with the key.

该类的文档由以下文件生成: