Nugget
Public Types | Public Member Functions | List of all members
eastl::hash_map< Key, T, Hash, Predicate, Allocator, bCacheHashCode > Class Template Reference

#include <hash_map.h>

Inheritance diagram for eastl::hash_map< Key, T, Hash, Predicate, Allocator, bCacheHashCode >:
Inheritance graph
[legend]
Collaboration diagram for eastl::hash_map< Key, T, Hash, Predicate, Allocator, bCacheHashCode >:
Collaboration graph
[legend]

Public Types

typedef hashtable< Key, eastl::pair< const Key, T >, Allocator, eastl::use_first< eastl::pair< const Key, T > >, Predicate, Hash, mod_range_hashing, default_ranged_hash, prime_rehash_policy, bCacheHashCode, true, true > base_type
 
typedef hash_map< Key, T, Hash, Predicate, Allocator, bCacheHashCode > this_type
 
typedef base_type::size_type size_type
 
typedef base_type::key_type key_type
 
typedef T mapped_type
 
typedef base_type::value_type value_type
 
typedef base_type::allocator_type allocator_type
 
typedef base_type::node_type node_type
 
typedef base_type::insert_return_type insert_return_type
 
typedef base_type::iterator iterator
 
typedef base_type::const_iterator const_iterator
 
- Public Types inherited from eastl::hashtable< Key, eastl::pair< const Key, T >, EASTLAllocatorType, eastl::use_first< eastl::pair< const Key, T > >, eastl::equal_to< Key >, eastl::hash< Key >, mod_range_hashing, default_ranged_hash, prime_rehash_policy, false, true, true >
enum  
 
typedef Key key_type
 
typedef eastl::pair< const Key, T > value_type
 
typedef ExtractKey::result_type mapped_type
 
typedef hash_code_base< Key, eastl::pair< const Key, T >, eastl::use_first< eastl::pair< const Key, T > >, eastl::equal_to< Key >, eastl::hash< Key >, mod_range_hashing, default_ranged_hash, bCacheHashCode > hash_code_base_type
 
typedef hash_code_base_type::hash_code_t hash_code_t
 
typedef EASTLAllocatorType allocator_type
 
typedef eastl::equal_to< Key > key_equal
 
typedef ptrdiff_t difference_type
 
typedef eastl_size_t size_type
 
typedef value_typereference
 
typedef const value_typeconst_reference
 
typedef node_iterator< value_type, !bMutableIterators, bCacheHashCode > local_iterator
 
typedef node_iterator< value_type, true, bCacheHashCode > const_local_iterator
 
typedef hashtable_iterator< value_type, !bMutableIterators, bCacheHashCode > iterator
 
typedef hashtable_iterator< value_type, true, bCacheHashCode > const_iterator
 
typedef hash_node< value_type, bCacheHashCode > node_type
 
typedef type_select< bUniqueKeys, eastl::pair< iterator, bool >, iterator >::type insert_return_type
 
typedef hashtable< Key, eastl::pair< const Key, T >, EASTLAllocatorType, eastl::use_first< eastl::pair< const Key, T > >, eastl::equal_to< Key >, eastl::hash< Key >, mod_range_hashing, default_ranged_hash, prime_rehash_policy, bCacheHashCode, bMutableIterators, bUniqueKeys > this_type
 
typedef prime_rehash_policy rehash_policy_type
 
typedef eastl::use_first< eastl::pair< const Key, T > > extract_key_type
 
typedef eastl::hash< Key > h1_type
 
typedef mod_range_hashing h2_type
 
typedef default_ranged_hash h_type
 
typedef integral_constant< bool, bUniqueKeys > has_unique_keys_type
 

Public Member Functions

 hash_map (const allocator_type &allocator=EASTL_HASH_MAP_DEFAULT_ALLOCATOR)
 
 hash_map (size_type nBucketCount, const Hash &hashFunction=Hash(), const Predicate &predicate=Predicate(), const allocator_type &allocator=EASTL_HASH_MAP_DEFAULT_ALLOCATOR)
 
 hash_map (const this_type &x)
 
 hash_map (this_type &&x)
 
 hash_map (this_type &&x, const allocator_type &allocator)
 
 hash_map (std::initializer_list< value_type > ilist, size_type nBucketCount=0, const Hash &hashFunction=Hash(), const Predicate &predicate=Predicate(), const allocator_type &allocator=EASTL_HASH_MAP_DEFAULT_ALLOCATOR)
 
template<typename ForwardIterator >
 hash_map (ForwardIterator first, ForwardIterator last, size_type nBucketCount=0, const Hash &hashFunction=Hash(), const Predicate &predicate=Predicate(), const allocator_type &allocator=EASTL_HASH_MAP_DEFAULT_ALLOCATOR)
 
this_typeoperator= (const this_type &x)
 
this_typeoperator= (std::initializer_list< value_type > ilist)
 
this_typeoperator= (this_type &&x)
 
insert_return_type insert (const key_type &key)
 
T & at (const key_type &k)
 
const T & at (const key_type &k) const
 
insert_return_type insert (key_type &&key)
 
mapped_type & operator[] (const key_type &key)
 
mapped_type & operator[] (key_type &&key)
 
insert_return_type insert (const value_type &value)
 
insert_return_type insert (value_type &&otherValue)
 
iterator insert (const_iterator hint, const value_type &value)
 
iterator insert (const_iterator hint, value_type &&value)
 
void insert (std::initializer_list< value_type > ilist)
 
template<typename InputIterator >
void insert (InputIterator first, InputIterator last)
 
template<class P , class = typename eastl::enable_if_t< !eastl::is_literal_type_v<P> && eastl::is_constructible_v<value_type, P&&>>>
insert_return_type insert (P &&otherValue)
 
template<class P >
insert_return_type insert (hash_code_t c, node_type *pNodeNew, P &&otherValue)
 
insert_return_type insert (hash_code_t c, node_type *pNodeNew, const value_type &value)
 
- Public Member Functions inherited from eastl::hashtable< Key, eastl::pair< const Key, T >, EASTLAllocatorType, eastl::use_first< eastl::pair< const Key, T > >, eastl::equal_to< Key >, eastl::hash< Key >, mod_range_hashing, default_ranged_hash, prime_rehash_policy, false, true, true >
 hashtable (size_type nBucketCount, const eastl::hash< Key > &, const mod_range_hashing &, const default_ranged_hash &, const eastl::equal_to< Key > &, const eastl::use_first< eastl::pair< const Key, T > > &, const allocator_type &allocator=EASTL_HASHTABLE_DEFAULT_ALLOCATOR)
 
 hashtable (FowardIterator first, FowardIterator last, size_type nBucketCount, const eastl::hash< Key > &, const mod_range_hashing &, const default_ranged_hash &, const eastl::equal_to< Key > &, const eastl::use_first< eastl::pair< const Key, T > > &, const allocator_type &allocator=EASTL_HASHTABLE_DEFAULT_ALLOCATOR)
 
 hashtable (const hashtable &x)
 
 hashtable (this_type &&x)
 
 hashtable (this_type &&x, const allocator_type &allocator)
 
 hashtable (FowardIterator first, FowardIterator last, size_type nBucketCount, const eastl::hash< Key > &h1, const mod_range_hashing &h2, const default_ranged_hash &h, const Eq &eq, const EK &ek, const allocator_type &allocator)
 
const allocator_type & get_allocator () const EA_NOEXCEPT
 
allocator_type & get_allocator () EA_NOEXCEPT
 
void set_allocator (const allocator_type &allocator)
 
this_typeoperator= (const this_type &x)
 
this_typeoperator= (std::initializer_list< value_type > ilist)
 
this_typeoperator= (this_type &&x)
 
void swap (this_type &x)
 
iterator begin () EA_NOEXCEPT
 
const_iterator begin () const EA_NOEXCEPT
 
local_iterator begin (size_type n) EA_NOEXCEPT
 
const_local_iterator begin (size_type n) const EA_NOEXCEPT
 
const_iterator cbegin () const EA_NOEXCEPT
 
const_local_iterator cbegin (size_type n) const EA_NOEXCEPT
 
iterator end () EA_NOEXCEPT
 
const_iterator end () const EA_NOEXCEPT
 
local_iterator end (size_type) EA_NOEXCEPT
 
const_local_iterator end (size_type) const EA_NOEXCEPT
 
const_iterator cend () const EA_NOEXCEPT
 
const_local_iterator cend (size_type) const EA_NOEXCEPT
 
bool empty () const EA_NOEXCEPT
 
size_type size () const EA_NOEXCEPT
 
size_type bucket_count () const EA_NOEXCEPT
 
size_type bucket_size (size_type n) const EA_NOEXCEPT
 
float load_factor () const EA_NOEXCEPT
 
const rehash_policy_typerehash_policy () const EA_NOEXCEPT
 
void rehash_policy (const rehash_policy_type &rehashPolicy)
 
insert_return_type emplace (Args &&... args)
 
iterator emplace_hint (const_iterator position, Args &&... args)
 
insert_return_type try_emplace (const key_type &k, Args &&... args)
 
insert_return_type try_emplace (key_type &&k, Args &&... args)
 
iterator try_emplace (const_iterator position, const key_type &k, Args &&... args)
 
iterator try_emplace (const_iterator position, key_type &&k, Args &&... args)
 
insert_return_type insert (const value_type &value)
 
insert_return_type insert (value_type &&otherValue)
 
iterator insert (const_iterator hint, const value_type &value)
 
iterator insert (const_iterator hint, value_type &&value)
 
void insert (std::initializer_list< value_type > ilist)
 
void insert (InputIterator first, InputIterator last)
 
insert_return_type insert (P &&otherValue)
 
insert_return_type insert (hash_code_t c, node_type *pNodeNew, P &&otherValue)
 
insert_return_type insert (hash_code_t c, node_type *pNodeNew, const value_type &value)
 
eastl::pair< iterator, bool > insert_or_assign (const key_type &k, M &&obj)
 
eastl::pair< iterator, bool > insert_or_assign (key_type &&k, M &&obj)
 
iterator insert_or_assign (const_iterator hint, const key_type &k, M &&obj)
 
iterator insert_or_assign (const_iterator hint, key_type &&k, M &&obj)
 
eastl::pair< typename hashtable< K, V, A, EK, Eq, eastl::hash< Key >, mod_range_hashing, default_ranged_hash, RP, bC, bM, bU >::iterator, bool > insert_or_assign (const key_type &k, M &&obj)
 
eastl::pair< typename hashtable< K, V, A, EK, Eq, eastl::hash< Key >, mod_range_hashing, default_ranged_hash, RP, bC, bM, bU >::iterator, bool > insert_or_assign (key_type &&k, M &&obj)
 
node_typeallocate_uninitialized_node ()
 
void free_uninitialized_node (node_type *pNode)
 
iterator erase (const_iterator position)
 
iterator erase (const_iterator first, const_iterator last)
 
size_type erase (const key_type &k)
 
void clear ()
 
void clear (bool clearBuckets)
 
void reset_lose_memory () EA_NOEXCEPT
 
void rehash (size_type nBucketCount)
 
void reserve (size_type nElementCount)
 
iterator find (const key_type &key)
 
const_iterator find (const key_type &key) const
 
iterator find_as (const U &u, UHash uhash, BinaryPredicate predicate)
 
const_iterator find_as (const U &u, UHash uhash, BinaryPredicate predicate) const
 
iterator find_as (const U &u)
 
const_iterator find_as (const U &u) const
 
 ENABLE_IF_HASHCODE_EASTLSIZET (HashCodeT, iterator) find_by_hash(HashCodeT c)
 
 ENABLE_IF_HASHCODE_EASTLSIZET (HashCodeT, const_iterator) find_by_hash(HashCodeT c) const
 
iterator find_by_hash (const key_type &k, hash_code_t c)
 
const_iterator find_by_hash (const key_type &k, hash_code_t c) const
 
eastl::pair< iterator, iteratorfind_range_by_hash (hash_code_t c)
 
eastl::pair< const_iterator, const_iteratorfind_range_by_hash (hash_code_t c) const
 
size_type count (const key_type &k) const EA_NOEXCEPT
 
eastl::pair< iterator, iteratorequal_range (const key_type &k)
 
eastl::pair< const_iterator, const_iteratorequal_range (const key_type &k) const
 
bool validate () const
 
int validate_iterator (const_iterator i) const
 
eastl::pair< typename hashtable< K, V, A, EK, Eq, eastl::hash< Key >, mod_range_hashing, default_ranged_hash, RP, bC, bM, bU >::iterator, bool > DoInsertValue (BoolConstantT, Args &&... args)
 
eastl::pair< typename hashtable< K, V, A, EK, Eq, eastl::hash< Key >, mod_range_hashing, default_ranged_hash, RP, bC, bM, bU >::iterator, bool > DoInsertValue (BoolConstantT, value_type &&value, ENABLE_IF_TRUETYPE(BoolConstantT))
 
eastl::pair< typename hashtable< K, V, A, EK, Eq, eastl::hash< Key >, mod_range_hashing, default_ranged_hash, RP, bC, bM, bU >::iterator, bool > DoInsertValue (BoolConstantT, const value_type &value, ENABLE_IF_TRUETYPE(BoolConstantT))
 
eastl::pair< typename hashtable< K, V, A, EK, Eq, eastl::hash< Key >, mod_range_hashing, default_ranged_hash, RP, bC, bM, bU >::iterator, bool > DoInsertValueExtra (BoolConstantT, const key_type &k, hash_code_t c, node_type *pNodeNew, value_type &&value, ENABLE_IF_TRUETYPE(BoolConstantT))
 
eastl::pair< typename hashtable< K, V, A, EK, Eq, eastl::hash< Key >, mod_range_hashing, default_ranged_hash, RP, bC, bM, bU >::iterator, bool > DoInsertValueExtra (BoolConstantT, const key_type &k, hash_code_t c, node_type *pNodeNew, const value_type &value, ENABLE_IF_TRUETYPE(BoolConstantT))
 

Additional Inherited Members

- Static Public Attributes inherited from eastl::hashtable< Key, eastl::pair< const Key, T >, EASTLAllocatorType, eastl::use_first< eastl::pair< const Key, T > >, eastl::equal_to< Key >, eastl::hash< Key >, mod_range_hashing, default_ranged_hash, prime_rehash_policy, false, true, true >
static const bool kCacheHashCode
 
- Protected Member Functions inherited from eastl::hashtable< Key, eastl::pair< const Key, T >, EASTLAllocatorType, eastl::use_first< eastl::pair< const Key, T > >, eastl::equal_to< Key >, eastl::hash< Key >, mod_range_hashing, default_ranged_hash, prime_rehash_policy, false, true, true >
iterator DoGetResultIterator (BoolConstantT, const insert_return_type &irt, ENABLE_IF_TRUETYPE(BoolConstantT)=nullptr) const EA_NOEXCEPT
 
iterator DoGetResultIterator (BoolConstantT, const insert_return_type &irt, DISABLE_IF_TRUETYPE(BoolConstantT)=nullptr) const EA_NOEXCEPT
 
node_typeDoAllocateNodeFromKey (const key_type &key)
 
node_typeDoAllocateNodeFromKey (key_type &&key)
 
void DoFreeNode (node_type *pNode)
 
void DoFreeNodes (node_type **pBucketArray, size_type)
 
node_type ** DoAllocateBuckets (size_type n)
 
void DoFreeBuckets (node_type **pBucketArray, size_type n)
 
eastl::pair< iterator, bool > DoInsertValue (BoolConstantT, Args &&... args)
 
iterator DoInsertValue (BoolConstantT, Args &&... args)
 
eastl::pair< iterator, bool > DoInsertValue (BoolConstantT, value_type &&value, ENABLE_IF_TRUETYPE(BoolConstantT)=nullptr)
 
iterator DoInsertValue (BoolConstantT, value_type &&value, DISABLE_IF_TRUETYPE(BoolConstantT)=nullptr)
 
eastl::pair< iterator, bool > DoInsertValue (BoolConstantT, const value_type &value, ENABLE_IF_TRUETYPE(BoolConstantT)=nullptr)
 
iterator DoInsertValue (BoolConstantT, const value_type &value, DISABLE_IF_TRUETYPE(BoolConstantT)=nullptr)
 
eastl::pair< iterator, bool > DoInsertValueExtra (BoolConstantT, const key_type &k, hash_code_t c, node_type *pNodeNew, value_type &&value, ENABLE_IF_TRUETYPE(BoolConstantT)=nullptr)
 
iterator DoInsertValueExtra (BoolConstantT, const key_type &k, hash_code_t c, node_type *pNodeNew, value_type &&value, DISABLE_IF_TRUETYPE(BoolConstantT)=nullptr)
 
eastl::pair< iterator, bool > DoInsertValueExtra (BoolConstantT, const key_type &k, hash_code_t c, node_type *pNodeNew, const value_type &value, ENABLE_IF_TRUETYPE(BoolConstantT)=nullptr)
 
iterator DoInsertValueExtra (BoolConstantT, const key_type &k, hash_code_t c, node_type *pNodeNew, const value_type &value, DISABLE_IF_TRUETYPE(BoolConstantT)=nullptr)
 
node_typeDoAllocateNode (Args &&... args)
 
node_typeDoAllocateNode (value_type &&value)
 
node_typeDoAllocateNode (const value_type &value)
 
eastl::pair< iterator, bool > DoInsertKey (true_type, const key_type &key, hash_code_t c)
 
iterator DoInsertKey (false_type, const key_type &key, hash_code_t c)
 
eastl::pair< iterator, bool > DoInsertKey (true_type, key_type &&key, hash_code_t c)
 
iterator DoInsertKey (false_type, key_type &&key, hash_code_t c)
 
eastl::pair< iterator, bool > DoInsertKey (true_type, const key_type &key)
 
iterator DoInsertKey (false_type, const key_type &key)
 
eastl::pair< iterator, bool > DoInsertKey (true_type, key_type &&key)
 
iterator DoInsertKey (false_type, key_type &&key)
 
void DoRehash (size_type nBucketCount)
 
node_typeDoFindNode (node_type *pNode, const key_type &k, hash_code_t c) const
 
 ENABLE_IF_HAS_HASHCODE (T, node_type) DoFindNode(T *pNode
 
node_typeDoFindNodeT (node_type *pNode, const U &u, BinaryPredicate predicate) const
 
- Protected Attributes inherited from eastl::hashtable< Key, eastl::pair< const Key, T >, EASTLAllocatorType, eastl::use_first< eastl::pair< const Key, T > >, eastl::equal_to< Key >, eastl::hash< Key >, mod_range_hashing, default_ranged_hash, prime_rehash_policy, false, true, true >
node_type ** mpBucketArray
 
size_type mnBucketCount
 
size_type mnElementCount
 
prime_rehash_policy mRehashPolicy
 
allocator_type mAllocator
 
hash_code_t c const
 

Detailed Description

template<typename Key, typename T, typename Hash = eastl::hash<Key>, typename Predicate = eastl::equal_to<Key>, typename Allocator = EASTLAllocatorType, bool bCacheHashCode = false>
class eastl::hash_map< Key, T, Hash, Predicate, Allocator, bCacheHashCode >

hash_map

Implements a hash_map, which is a hashed associative container. Lookups are O(1) (that is, they are fast) but the container is not sorted. Note that lookups are only O(1) if the hash table is well-distributed (non-colliding). The lookup approaches O(n) behavior as the table becomes increasingly poorly distributed.

set_max_load_factor If you want to make a hashtable never increase its bucket usage, call set_max_load_factor with a very high value such as 100000.f.

bCacheHashCode We provide the boolean bCacheHashCode template parameter in order to allow the storing of the hash code of the key within the map. When this option is disabled, the rehashing of the table will call the hash function on the key. Setting bCacheHashCode to true is useful for cases whereby the calculation of the hash value for a contained object is very expensive.

find_as In order to support the ability to have a hashtable of strings but be able to do efficiently lookups via char pointers (i.e. so they aren't converted to string objects), we provide the find_as function. This function allows you to do a find with a key of a type other than the hashtable key type.

Example find_as usage: hash_map<string, int> hashMap; i = hashMap.find_as("hello"); // Use default hash and compare.

Example find_as usage (namespaces omitted for brevity): hash_map<string, int> hashMap; i = hashMap.find_as("hello", hash<char*>(), equal_to_2<string, char*>());

Constructor & Destructor Documentation

◆ hash_map() [1/4]

template<typename Key , typename T , typename Hash = eastl::hash<Key>, typename Predicate = eastl::equal_to<Key>, typename Allocator = EASTLAllocatorType, bool bCacheHashCode = false>
eastl::hash_map< Key, T, Hash, Predicate, Allocator, bCacheHashCode >::hash_map ( const allocator_type &  allocator = EASTL_HASH_MAP_DEFAULT_ALLOCATOR)
inlineexplicit

hash_map

Default constructor.

◆ hash_map() [2/4]

template<typename Key , typename T , typename Hash = eastl::hash<Key>, typename Predicate = eastl::equal_to<Key>, typename Allocator = EASTLAllocatorType, bool bCacheHashCode = false>
eastl::hash_map< Key, T, Hash, Predicate, Allocator, bCacheHashCode >::hash_map ( size_type  nBucketCount,
const Hash &  hashFunction = Hash(),
const Predicate &  predicate = Predicate(),
const allocator_type &  allocator = EASTL_HASH_MAP_DEFAULT_ALLOCATOR 
)
inlineexplicit

hash_map

Constructor which creates an empty container, but start with nBucketCount buckets. We default to a small nBucketCount value, though the user really should manually specify an appropriate value in order to prevent memory from being reallocated.

◆ hash_map() [3/4]

template<typename Key , typename T , typename Hash = eastl::hash<Key>, typename Predicate = eastl::equal_to<Key>, typename Allocator = EASTLAllocatorType, bool bCacheHashCode = false>
eastl::hash_map< Key, T, Hash, Predicate, Allocator, bCacheHashCode >::hash_map ( std::initializer_list< value_type >  ilist,
size_type  nBucketCount = 0,
const Hash &  hashFunction = Hash(),
const Predicate &  predicate = Predicate(),
const allocator_type &  allocator = EASTL_HASH_MAP_DEFAULT_ALLOCATOR 
)
inline

hash_map

initializer_list-based constructor. Allows for initializing with brace values (e.g. hash_map<int, char*> hm = { {3,"c"}, {4,"d"}, {5,"e"} }; )

◆ hash_map() [4/4]

template<typename Key , typename T , typename Hash = eastl::hash<Key>, typename Predicate = eastl::equal_to<Key>, typename Allocator = EASTLAllocatorType, bool bCacheHashCode = false>
template<typename ForwardIterator >
eastl::hash_map< Key, T, Hash, Predicate, Allocator, bCacheHashCode >::hash_map ( ForwardIterator  first,
ForwardIterator  last,
size_type  nBucketCount = 0,
const Hash &  hashFunction = Hash(),
const Predicate &  predicate = Predicate(),
const allocator_type &  allocator = EASTL_HASH_MAP_DEFAULT_ALLOCATOR 
)
inline

hash_map

An input bucket count of <= 1 causes the bucket count to be equal to the number of elements in the input range.

Member Function Documentation

◆ insert()

template<typename Key , typename T , typename Hash = eastl::hash<Key>, typename Predicate = eastl::equal_to<Key>, typename Allocator = EASTLAllocatorType, bool bCacheHashCode = false>
insert_return_type eastl::hash_map< Key, T, Hash, Predicate, Allocator, bCacheHashCode >::insert ( const key_type &  key)
inline

insert

This is an extension to the C++ standard. We insert a default-constructed element with the given key. The reason for this is that we can avoid the potentially expensive operation of creating and/or copying a mapped_type object on the stack.


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