45 #ifndef EASTL_HASH_MAP_H 46 #define EASTL_HASH_MAP_H 49 #include <stk_util/util/config_eastl.h> 50 #include <stk_util/util/hashtable_eastl.h> 51 #include <stk_util/util/functional_eastl.h> 52 #include <stk_util/util/utility_eastl.h> 63 #ifndef EASTL_HASH_MAP_DEFAULT_NAME 64 #define EASTL_HASH_MAP_DEFAULT_NAME EASTL_DEFAULT_NAME_PREFIX " hash_map" // Unless the user overrides something, this is "EASTL hash_map". 72 #ifndef EASTL_HASH_MULTIMAP_DEFAULT_NAME 73 #define EASTL_HASH_MULTIMAP_DEFAULT_NAME EASTL_DEFAULT_NAME_PREFIX " hash_multimap" // Unless the user overrides something, this is "EASTL hash_multimap". 79 #ifndef EASTL_HASH_MAP_DEFAULT_ALLOCATOR 80 #define EASTL_HASH_MAP_DEFAULT_ALLOCATOR allocator_type(EASTL_HASH_MAP_DEFAULT_NAME) 85 #ifndef EASTL_HASH_MULTIMAP_DEFAULT_ALLOCATOR 86 #define EASTL_HASH_MULTIMAP_DEFAULT_ALLOCATOR allocator_type(EASTL_HASH_MULTIMAP_DEFAULT_NAME) 124 template <
typename Key,
typename T,
typename Hash = eastl::hash<Key>,
typename Predicate = eastl::equal_to<Key>,
125 typename Allocator = EASTLAllocatorType,
bool bCacheHashCode = false>
127 :
public hashtable<Key, eastl::pair<const Key, T>, Allocator, eastl::use_first<eastl::pair<const Key, T> >, Predicate,
128 Hash, mod_range_hashing, default_ranged_hash, prime_rehash_policy, bCacheHashCode, true, true>
136 typedef typename base_type::size_type size_type;
137 typedef typename base_type::key_type key_type;
138 typedef T mapped_type;
140 typedef typename base_type::allocator_type allocator_type;
145 #if !defined(__GNUC__) || (__GNUC__ >= 3) // GCC 2.x has a bug which we work around. 146 using base_type::insert;
168 explicit hash_map(size_type nBucketCount,
const Hash& hashFunction = Hash(),
169 const Predicate& predicate = Predicate(),
const allocator_type&
allocator = EASTL_HASH_MAP_DEFAULT_ALLOCATOR)
182 template <
typename ForwardIterator>
183 hash_map(ForwardIterator first, ForwardIterator last, size_type nBucketCount = 0,
const Hash& hashFunction = Hash(),
184 const Predicate& predicate = Predicate(),
const allocator_type&
allocator = EASTL_HASH_MAP_DEFAULT_ALLOCATOR)
200 return base_type::DoInsertKey(key, true_type());
204 #if defined(__GNUC__) && (__GNUC__ < 3) // If using old GCC (GCC 2.x has a bug which we work around) 205 template <
typename InputIterator>
206 void insert(InputIterator first, InputIterator last) {
return base_type::insert(first, last); }
207 insert_return_type
insert(
const value_type& value) {
return base_type::insert(value); }
208 iterator
insert(const_iterator it,
const value_type& value) {
return base_type::insert(it, value); }
212 mapped_type& operator[](
const key_type& key)
214 const typename base_type::iterator it = base_type::find(key);
215 if(it != base_type::end())
217 return (*base_type::insert(value_type(key, mapped_type())).first).second;
233 template <
typename Key,
typename T,
typename Hash = eastl::hash<Key>,
typename Predicate = eastl::equal_to<Key>,
234 typename Allocator = EASTLAllocatorType,
bool bCacheHashCode = false>
236 :
public hashtable<Key, eastl::pair<const Key, T>, Allocator, eastl::use_first<eastl::pair<const Key, T> >, Predicate,
237 Hash, mod_range_hashing, default_ranged_hash, prime_rehash_policy, bCacheHashCode, true, false>
245 typedef typename base_type::size_type size_type;
246 typedef typename base_type::key_type key_type;
247 typedef T mapped_type;
249 typedef typename base_type::allocator_type allocator_type;
254 #if !defined(__GNUC__) || (__GNUC__ >= 3) // GCC 2.x has a bug which we work around. 255 using base_type::insert;
277 explicit hash_multimap(size_type nBucketCount,
const Hash& hashFunction = Hash(),
278 const Predicate& predicate = Predicate(),
const allocator_type&
allocator = EASTL_HASH_MULTIMAP_DEFAULT_ALLOCATOR)
291 template <
typename ForwardIterator>
292 hash_multimap(ForwardIterator first, ForwardIterator last, size_type nBucketCount = 0,
const Hash& hashFunction = Hash(),
293 const Predicate& predicate = Predicate(),
const allocator_type&
allocator = EASTL_HASH_MULTIMAP_DEFAULT_ALLOCATOR)
309 return base_type::DoInsertKey(key, false_type());
313 #if defined(__GNUC__) && (__GNUC__ < 3) // If using old GCC (GCC 2.x has a bug which we work around) 314 template <
typename InputIterator>
315 void insert(InputIterator first, InputIterator last) {
return base_type::insert(first, last); }
316 insert_return_type
insert(
const value_type& value) {
return base_type::insert(value); }
317 iterator
insert(const_iterator it,
const value_type& value) {
return base_type::insert(it, value); }
329 #endif // Header include guard
insert_return_type insert(const key_type &key)
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"))
hash_multimap(size_type nBucketCount, const Hash &hashFunction=Hash(), const Predicate &predicate=Predicate(), const allocator_type &allocator=allocator_type(EASTL_DEFAULT_NAME_PREFIX " hash_multimap"))
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"))
insert_return_type insert(const key_type &key)
hash_map(const allocator_type &allocator=allocator_type(EASTL_DEFAULT_NAME_PREFIX " hash_map"))
hash_multimap(const allocator_type &allocator=allocator_type(EASTL_DEFAULT_NAME_PREFIX " hash_multimap"))
hash_multimap(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_multimap"))
EA Standard Template Library.