Sierra Toolkit
Version of the Day
|
#include <hash_map_eastl.h>
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 |
![]() | |
enum | |
typedef Key | key_type |
typedef eastl::pair< const Key, T > | value_type |
typedef eastl::use_first< eastl::pair< const Key, T > > ::result_type | mapped_type |
typedef hash_code_base< Key, eastl::pair< const Key, T >, eastl::use_first< eastl::pair< const Key, T > >, Predicate, Hash, mod_range_hashing, default_ranged_hash, bCacheHashCode > | hash_code_base_type |
typedef hash_code_base_type::hash_code_t | hash_code_t |
typedef Allocator | allocator_type |
typedef Predicate | key_equal |
typedef ptrdiff_t | difference_type |
typedef eastl_size_t | size_type |
typedef value_type & | reference |
typedef const value_type & | const_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 eastl::reverse_iterator< iterator > | reverse_iterator |
typedef eastl::reverse_iterator< const_iterator > | const_reverse_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 >, Allocator, eastl::use_first< eastl::pair< const Key, T > >, Predicate, Hash, 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 Hash | h1_type |
typedef mod_range_hashing | h2_type |
typedef default_ranged_hash | h_type |
Public Member Functions | |
hash_map (const allocator_type &allocator=allocator_type(EASTL_DEFAULT_NAME_PREFIX " hash_map")) | |
hash_map (size_type nBucketCount, const Hash &hashFunction=Hash(), const Predicate &predicate=Predicate(), const allocator_type &allocator=allocator_type(EASTL_DEFAULT_NAME_PREFIX " hash_map")) | |
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=allocator_type(EASTL_DEFAULT_NAME_PREFIX " hash_map")) | |
insert_return_type | insert (const key_type &key) |
mapped_type & | operator[] (const key_type &key) |
![]() | |
hashtable (size_type nBucketCount, const Hash &, const mod_range_hashing &, const default_ranged_hash &, const Predicate &, const eastl::use_first< eastl::pair< const Key, T > > &, const allocator_type &allocator=allocator_type(EASTL_DEFAULT_NAME_PREFIX " hashtable")) | |
hashtable (FowardIterator first, FowardIterator last, size_type nBucketCount, const Hash &, const mod_range_hashing &, const default_ranged_hash &, const Predicate &, const eastl::use_first< eastl::pair< const Key, T > > &, const allocator_type &allocator=allocator_type(EASTL_DEFAULT_NAME_PREFIX " hashtable")) | |
hashtable (const hashtable &x) | |
allocator_type & | get_allocator () |
void | set_allocator (const allocator_type &allocator) |
this_type & | operator= (const this_type &x) |
void | swap (this_type &x) |
iterator | begin () |
const_iterator | begin () const |
local_iterator | begin (size_type n) |
const_local_iterator | begin (size_type n) const |
iterator | end () |
const_iterator | end () const |
local_iterator | end (size_type) |
const_local_iterator | end (size_type) const |
bool | empty () const |
size_type | size () const |
size_type | bucket_count () const |
size_type | bucket_size (size_type n) const |
float | load_factor () const |
const rehash_policy_type & | rehash_policy () const |
void | rehash_policy (const rehash_policy_type &rehashPolicy) |
insert_return_type | insert (const value_type &value) |
iterator | insert (const_iterator, const value_type &value) |
void | insert (InputIterator first, InputIterator last) |
iterator | erase (iterator position) |
iterator | erase (iterator first, iterator last) |
reverse_iterator | erase (reverse_iterator position) |
reverse_iterator | erase (reverse_iterator first, reverse_iterator last) |
size_type | erase (const key_type &k) |
void | clear () |
void | clear (bool clearBuckets) |
void | reset () |
void | rehash (size_type nBucketCount) |
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 |
iterator | find_by_hash (hash_code_t c) |
const_iterator | find_by_hash (hash_code_t c) const |
size_type | count (const key_type &k) const |
eastl::pair< iterator, iterator > | equal_range (const key_type &k) |
eastl::pair< const_iterator, const_iterator > | equal_range (const key_type &k) const |
bool | validate () const |
int | validate_iterator (const_iterator i) const |
Additional Inherited Members | |
![]() | |
static const bool | kCacheHashCode |
![]() | |
node_type * | DoAllocateNode (const value_type &value) |
node_type * | DoAllocateNodeFromKey (const 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 (const value_type &value, true_type) |
iterator | DoInsertValue (const value_type &value, false_type) |
eastl::pair< iterator, bool > | DoInsertKey (const key_type &key, true_type) |
iterator | DoInsertKey (const key_type &key, false_type) |
void | DoRehash (size_type nBucketCount) |
node_type * | DoFindNode (node_type *pNode, const key_type &k, hash_code_t c) const |
node_type * | DoFindNode (node_type *pNode, const U &u, BinaryPredicate predicate) const |
node_type * | DoFindNode (node_type *pNode, hash_code_t c) const |
![]() | |
node_type ** | mpBucketArray |
size_type | mnBucketCount |
size_type | mnElementCount |
prime_rehash_policy | mRehashPolicy |
allocator_type | mAllocator |
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.
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*>());
Definition at line 126 of file hash_map_eastl.h.
|
inlineexplicit |
|
inlineexplicit |
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.
Definition at line 168 of file hash_map_eastl.h.
|
inline |
An input bucket count of <= 1 causes the bucket count to be equal to the number of elements in the input range.
Definition at line 183 of file hash_map_eastl.h.
|
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.
Definition at line 198 of file hash_map_eastl.h.