Navigation
API > API/Runtime > API/Runtime/Chaos
A HashMap using FHashTable to index an array of elements of type TElementType, whcih should be uniquely identified by an object of type TIDType.
E.g., using FMyDataID = int32; struct FMyData { FMyDataID ID; // Every FMyData will require a unique ID if using the default THashMappedArrayTraits float MyValue; };
const int32 HashTableSize = 128; // Must be power of 2 THashMapedArray
MyDataMap.Add(1, { 1, 1.0 }); // NOTE: ID passed twice. Once for the hash map and once to construct FMyData MyDataMap.Emplace(2, 2, 2.0); // NOTE: ID passed twice. Once for the hash map and once for forwarding args to FMyData
const FMyData* MyData2 = MyDataMap.Find(2); // MyData2->MyValue == 2.0
| Name | THashMappedArray |
| Type | class |
| Header File | /Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/Framework/HashMappedArray.h |
| Include Path | #include "Chaos/Framework/HashMappedArray.h" |
Syntax
template<typename TIDType, typename TElementType , typename TTraits>
class THashMappedArray
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
THashMappedArray
(
const int32 InHashSize |
Initialize the hash table. InHashSize must be a power of two (asserted) | Chaos/Framework/HashMappedArray.h |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| FElementType | TElementType | Chaos/Framework/HashMappedArray.h | |
| FHashType | uint32 | Chaos/Framework/HashMappedArray.h | |
| FIDType | TIDType | Chaos/Framework/HashMappedArray.h | |
| FTraits | TTraits | Chaos/Framework/HashMappedArray.h | |
| FType | THashMappedArray< FIDType, FElementType, FTraits > | Chaos/Framework/HashMappedArray.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| Elements | TArray< FElementType > | Chaos/Framework/HashMappedArray.h | ||
| HashTable | FHashTable | Chaos/Framework/HashMappedArray.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void Add
(
const FIDType ID, |
Add an element with the specified ID to the map. Asserts if an Element with the same ID is already in the map. | Chaos/Framework/HashMappedArray.h | |
FElementType & At
(
const int32 ElementIndex |
Get the element at ElementIndex (indexed by order in which they were added) | Chaos/Framework/HashMappedArray.h | |
const FElementType & At
(
const int32 ElementIndex |
Get the element at ElementIndex (indexed by order in which they were added) | Chaos/Framework/HashMappedArray.h | |
void Emplace
(
const FIDType ID, |
Add an element with the specified ID to the map. | Chaos/Framework/HashMappedArray.h | |
TArray< FElementType > ExtractElements() |
Move the array elements into an external array and reset. | Chaos/Framework/HashMappedArray.h | |
const FElementType * Find
(
const FIDType ID |
Find the element with the specified ID. Roughly O(Max(1,N/M)) for N elements with a hash table of size M. | Chaos/Framework/HashMappedArray.h | |
FElementType * Find
(
const FIDType ID |
Find the element with the specified ID. Roughly O(Max(1,N/M)) for N elements with a hash table of size M. | Chaos/Framework/HashMappedArray.h | |
int32 Num() |
The number of elements that have been added to the map. | Chaos/Framework/HashMappedArray.h | |
void Remove
(
const FIDType ID |
Chaos/Framework/HashMappedArray.h | ||
void Reset
(
const int32 InReserveElements |
Clear the hash map and reserve space for the specified number of elements (will not shrink) | Chaos/Framework/HashMappedArray.h | |
bool TryAdd
(
const FIDType ID, |
Try to add an element with the specified ID to the map. | Chaos/Framework/HashMappedArray.h | |
bool TryEmplace
(
const FIDType ID, |
Try to add an element with the specified ID to the map. | Chaos/Framework/HashMappedArray.h |