12template <
class Key,
class Value>
17 static const Key &
sGetKey(
const std::pair<Key, Value> &inKeyValue)
19 return inKeyValue.first;
28template <
class Key,
class Value,
class Hash = JPH::Hash<Key>,
class KeyEqual = std::equal_to<Key>>
29class UnorderedMap :
public HashTable<Key, std::pair<Key, Value>, UnorderedMapDetail<Key, Value>, Hash, KeyEqual>
42 bool inserted = this->
InsertKey(inKey, index);
46 return key_value.second;
49 template<
class... Args>
50 std::pair<iterator, bool>
try_emplace(
const Key &inKey, Args &&...inArgs)
53 bool inserted = this->
InsertKey(inKey, index);
55 ::new (&this->
GetElement(index))
value_type(std::piecewise_construct, std::forward_as_tuple(inKey), std::forward_as_tuple(std::forward<Args>(inArgs)...));
56 return std::make_pair(
iterator(
this, index), inserted);
59 template<
class... Args>
60 std::pair<iterator, bool>
try_emplace(Key &&inKey, Args &&...inArgs)
63 bool inserted = this->
InsertKey(inKey, index);
65 ::new (&this->
GetElement(index))
value_type(std::piecewise_construct, std::forward_as_tuple(std::move(inKey)), std::forward_as_tuple(std::forward<Args>(inArgs)...));
66 return std::make_pair(
iterator(
this, index), inserted);
#define JPH_NAMESPACE_END
Definition Core.h:379
#define JPH_NAMESPACE_BEGIN
Definition Core.h:373
Const iterator.
Definition HashTable.h:357
Non-const iterator.
Definition HashTable.h:320
Definition HashTable.h:16
KeyValue & GetElement(size_type inIndex) const
Get an element by index.
Definition HashTable.h:200
const_iterator find(const Key &inKey) const
Find an element, returns iterator to element or end() if not found.
Definition HashTable.h:520
KeyValue value_type
Properties.
Definition HashTable.h:19
bool InsertKey(const Key &inKey, size_type &outIndex)
Definition HashTable.h:208
uint32 size_type
Definition HashTable.h:20
Internal helper class to provide context for UnorderedMap.
Definition UnorderedMap.h:14
static const Key & sGetKey(const std::pair< Key, Value > &inKeyValue)
Get key from key value pair.
Definition UnorderedMap.h:17
Definition UnorderedMap.h:30
typename Base::const_iterator const_iterator
Definition UnorderedMap.h:36
Value & operator[](const Key &inKey)
Definition UnorderedMap.h:39
typename Base::value_type value_type
Definition UnorderedMap.h:37
std::pair< iterator, bool > try_emplace(const Key &inKey, Args &&...inArgs)
Definition UnorderedMap.h:50
iterator find(const Key &inKey)
Non-const version of find.
Definition UnorderedMap.h:73
std::pair< iterator, bool > try_emplace(Key &&inKey, Args &&...inArgs)
Definition UnorderedMap.h:60
typename Base::size_type size_type
Definition UnorderedMap.h:34
typename Base::iterator iterator
Definition UnorderedMap.h:35
Fallback hash function that calls T::GetHash()
Definition HashCombine.h:59