Jolt Physics
A multi core friendly Game Physics Engine
|
#include <LockFreeHashMap.h>
Classes | |
struct | Iterator |
Non-const iterator. More... | |
class | KeyValue |
A key / value pair that is inserted in the map. More... | |
Public Types | |
using | MapType = LockFreeHashMap< Key, Value > |
Public Member Functions | |
LockFreeHashMap (LFHMAllocator &inAllocator) | |
Destructor. | |
~LockFreeHashMap () | |
void | Init (uint32 inMaxBuckets) |
void | Clear () |
uint32 | GetNumBuckets () const |
Get the current amount of buckets that the map is using. | |
uint32 | GetMaxBuckets () const |
Get the maximum amount of buckets that this map supports. | |
void | SetNumBuckets (uint32 inNumBuckets) |
template<class... Params> | |
KeyValue * | Create (LFHMAllocatorContext &ioContext, const Key &inKey, uint64 inKeyHash, int inExtraBytes, Params &&... inConstructorParams) |
const KeyValue * | Find (const Key &inKey, uint64 inKeyHash) const |
Find an element, returns null if not found. | |
uint32 | ToHandle (const KeyValue *inKeyValue) const |
Get convert key value pair to uint32 handle. | |
const KeyValue * | FromHandle (uint32 inHandle) const |
Convert uint32 handle back to key and value. | |
void | GetAllKeyValues (Array< const KeyValue * > &outAll) const |
Get all key/value pairs. | |
Iterator | begin () |
Iterator | end () |
Public Member Functions inherited from NonCopyable | |
NonCopyable ()=default | |
NonCopyable (const NonCopyable &)=delete | |
void | operator= (const NonCopyable &)=delete |
Static Public Attributes | |
static const uint32 | cInvalidHandle = uint32(-1) |
Value of an invalid handle. | |
Very simple lock free hash map that only allows insertion, retrieval and provides a fixed amount of buckets and fixed storage. Note: This class currently assumes key and value are simple types that need no calls to the destructor.
using LockFreeHashMap< Key, Value >::MapType = LockFreeHashMap<Key, Value> |
|
inlineexplicit |
Destructor.
LockFreeHashMap< Key, Value >::~LockFreeHashMap | ( | ) |
LockFreeHashMap< Key, Value >::Iterator LockFreeHashMap< Key, Value >::begin | ( | ) |
Iterate over the map, note that it is not safe to do this in parallel to Clear(). It is safe to do this while adding elements to the map, but newly added elements may or may not be returned by the iterator.
void LockFreeHashMap< Key, Value >::Clear | ( | ) |
Remove all elements. Note that this cannot happen simultaneously with adding new elements.
|
inline |
Insert a new element, returns null if map full. Multiple threads can be inserting in the map at the same time.
LockFreeHashMap< Key, Value >::Iterator LockFreeHashMap< Key, Value >::end | ( | ) |
|
inline |
Find an element, returns null if not found.
|
inline |
Convert uint32 handle back to key and value.
|
inline |
Get all key/value pairs.
|
inline |
Get the maximum amount of buckets that this map supports.
|
inline |
Get the current amount of buckets that the map is using.
void LockFreeHashMap< Key, Value >::Init | ( | uint32 | inMaxBuckets | ) |
Initialization
inMaxBuckets | Max amount of buckets to use in the hashmap. Must be power of 2. |
void LockFreeHashMap< Key, Value >::SetNumBuckets | ( | uint32 | inNumBuckets | ) |
Update the number of buckets. This must be done after clearing the map and cannot be done concurrently with any other operations on the map. Note that the number of buckets can never become bigger than the specified max buckets during initialization and that it must be a power of 2.
|
inline |
Get convert key value pair to uint32 handle.
|
static |
Value of an invalid handle.