11 #ifndef EASTL_FIXED_HASH_MAP_H
12 #define EASTL_FIXED_HASH_MAP_H
15 #include <EASTL/hash_map.h>
16 #include <EASTL/internal/fixed_pool.h>
18 EA_DISABLE_VC_WARNING(4127)
20 #if defined(EA_PRAGMA_ONCE_SUPPORTED)
33 #ifndef EASTL_FIXED_HASH_MAP_DEFAULT_NAME
34 #define EASTL_FIXED_HASH_MAP_DEFAULT_NAME EASTL_DEFAULT_NAME_PREFIX " fixed_hash_map"
37 #ifndef EASTL_FIXED_HASH_MULTIMAP_DEFAULT_NAME
38 #define EASTL_FIXED_HASH_MULTIMAP_DEFAULT_NAME EASTL_DEFAULT_NAME_PREFIX " fixed_hash_multimap"
45 #ifndef EASTL_FIXED_HASH_MAP_DEFAULT_ALLOCATOR
46 #define EASTL_FIXED_HASH_MAP_DEFAULT_ALLOCATOR overflow_allocator_type(EASTL_FIXED_HASH_MAP_DEFAULT_NAME)
49 #ifndef EASTL_FIXED_HASH_MULTIMAP_DEFAULT_ALLOCATOR
50 #define EASTL_FIXED_HASH_MULTIMAP_DEFAULT_ALLOCATOR overflow_allocator_type(EASTL_FIXED_HASH_MULTIMAP_DEFAULT_NAME)
69 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount = nodeCount + 1,
bool bEnableOverflow =
true,
71 class fixed_hash_map :
public hash_map<Key,
75 fixed_hashtable_allocator<
77 sizeof(typename hash_map<Key, T, Hash, Predicate, OverflowAllocator, bCacheHashCode>::node_type),
79 EASTL_ALIGN_OF(eastl::pair<Key, T>),
86 typedef fixed_hashtable_allocator<bucketCount + 1,
sizeof(
typename hash_map<Key, T, Hash, Predicate,
87 OverflowAllocator, bCacheHashCode>::node_type), nodeCount, EASTL_ALIGN_OF(
eastl::pair<Key, T>), 0,
88 bEnableOverflow, OverflowAllocator> fixed_allocator_type;
89 typedef typename fixed_allocator_type::overflow_allocator_type overflow_allocator_type;
90 typedef hash_map<Key, T, Hash, Predicate, fixed_allocator_type, bCacheHashCode> base_type;
91 typedef fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator> this_type;
92 typedef typename base_type::value_type value_type;
93 typedef typename base_type::node_type node_type;
94 typedef typename base_type::size_type size_type;
96 enum { kMaxSize = nodeCount };
98 using base_type::mAllocator;
99 using base_type::clear;
102 node_type** mBucketBuffer[bucketCount + 1];
103 char mNodeBuffer[fixed_allocator_type::kBufferSize];
106 explicit fixed_hash_map(
const overflow_allocator_type& overflowAllocator);
108 explicit fixed_hash_map(
const Hash& hashFunction = Hash(),
109 const Predicate& predicate = Predicate());
111 fixed_hash_map(
const Hash& hashFunction,
112 const Predicate& predicate,
113 const overflow_allocator_type& overflowAllocator);
115 template <
typename InputIterator>
116 fixed_hash_map(InputIterator first, InputIterator last,
117 const Hash& hashFunction = Hash(),
118 const Predicate& predicate = Predicate());
120 fixed_hash_map(
const this_type& x);
121 fixed_hash_map(this_type&& x);
122 fixed_hash_map(this_type&& x,
const overflow_allocator_type& overflowAllocator);
125 this_type& operator=(
const this_type& x);
127 this_type& operator=(this_type&& x);
129 void swap(this_type& x);
131 void reset_lose_memory();
133 size_type max_size()
const;
135 const overflow_allocator_type& get_overflow_allocator() const EA_NOEXCEPT;
136 overflow_allocator_type& get_overflow_allocator() EA_NOEXCEPT;
137 void set_overflow_allocator(const overflow_allocator_type& allocator);
139 void clear(
bool clearBuckets);
160 template <typename Key, typename T,
size_t nodeCount,
size_t bucketCount = nodeCount + 1,
bool bEnableOverflow = true,
161 typename Hash =
eastl::hash<Key>, typename Predicate =
eastl::equal_to<Key>,
bool bCacheHashCode = false, typename OverflowAllocator = EASTLAllocatorType>
162 class fixed_hash_multimap : public hash_multimap<Key,
166 fixed_hashtable_allocator<
168 sizeof(typename hash_multimap<Key, T, Hash, Predicate, OverflowAllocator, bCacheHashCode>::node_type),
170 EASTL_ALIGN_OF(
eastl::pair<Key, T>),
177 typedef fixed_hashtable_allocator<bucketCount + 1,
sizeof(
typename hash_multimap<Key, T, Hash, Predicate,
178 OverflowAllocator, bCacheHashCode>::node_type), nodeCount, EASTL_ALIGN_OF(
eastl::pair<Key, T>), 0,
179 bEnableOverflow, OverflowAllocator> fixed_allocator_type;
180 typedef typename fixed_allocator_type::overflow_allocator_type overflow_allocator_type;
181 typedef hash_multimap<Key, T, Hash, Predicate, fixed_allocator_type, bCacheHashCode> base_type;
182 typedef fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator> this_type;
183 typedef typename base_type::value_type value_type;
184 typedef typename base_type::node_type node_type;
185 typedef typename base_type::size_type size_type;
187 enum { kMaxSize = nodeCount };
189 using base_type::mAllocator;
190 using base_type::clear;
193 node_type** mBucketBuffer[bucketCount + 1];
194 char mNodeBuffer[fixed_allocator_type::kBufferSize];
197 explicit fixed_hash_multimap(
const overflow_allocator_type& overflowAllocator);
199 explicit fixed_hash_multimap(
const Hash& hashFunction = Hash(),
200 const Predicate& predicate = Predicate());
202 fixed_hash_multimap(
const Hash& hashFunction,
203 const Predicate& predicate,
204 const overflow_allocator_type& overflowAllocator);
206 template <
typename InputIterator>
207 fixed_hash_multimap(InputIterator first, InputIterator last,
208 const Hash& hashFunction = Hash(),
209 const Predicate& predicate = Predicate());
211 fixed_hash_multimap(
const this_type& x);
212 fixed_hash_multimap(this_type&& x);
213 fixed_hash_multimap(this_type&& x,
const overflow_allocator_type& overflowAllocator);
216 this_type& operator=(
const this_type& x);
218 this_type& operator=(this_type&& x);
220 void swap(this_type& x);
222 void reset_lose_memory();
224 size_type max_size()
const;
226 const overflow_allocator_type& get_overflow_allocator() const EA_NOEXCEPT;
227 overflow_allocator_type& get_overflow_allocator() EA_NOEXCEPT;
228 void set_overflow_allocator(const overflow_allocator_type& allocator);
230 void clear(
bool clearBuckets);
242 template <typename Key, typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow, typename Hash, typename Predicate,
bool bCacheHashCode, typename OverflowAllocator>
243 inline fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::
244 fixed_hash_map(const overflow_allocator_type& overflowAllocator)
245 : base_type(prime_rehash_policy::GetPrevBucketCountOnly(bucketCount), Hash(),
246 Predicate(), fixed_allocator_type(NULL, mBucketBuffer, overflowAllocator))
248 EASTL_CT_ASSERT((nodeCount >= 1) && (bucketCount >= 2));
251 base_type::set_max_load_factor(10000.f);
253 #if EASTL_NAME_ENABLED
254 mAllocator.set_name(EASTL_FIXED_HASH_MAP_DEFAULT_NAME);
257 mAllocator.reset(mNodeBuffer);
261 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
262 inline fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::
263 fixed_hash_map(
const Hash& hashFunction,
264 const Predicate& predicate)
265 : base_type(prime_rehash_policy::GetPrevBucketCountOnly(bucketCount), hashFunction,
266 predicate, fixed_allocator_type(NULL, mBucketBuffer))
268 EASTL_CT_ASSERT((nodeCount >= 1) && (bucketCount >= 2));
270 if (!bEnableOverflow)
272 base_type::set_max_load_factor(10000.f);
275 #if EASTL_NAME_ENABLED
276 mAllocator.set_name(EASTL_FIXED_HASH_MAP_DEFAULT_NAME);
279 mAllocator.reset(mNodeBuffer);
283 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
284 inline fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::
285 fixed_hash_map(
const Hash& hashFunction,
286 const Predicate& predicate,
287 const overflow_allocator_type& overflowAllocator)
288 : base_type(prime_rehash_policy::GetPrevBucketCountOnly(bucketCount), hashFunction,
289 predicate, fixed_allocator_type(NULL, mBucketBuffer, overflowAllocator))
291 EASTL_CT_ASSERT((nodeCount >= 1) && (bucketCount >= 2));
293 if (!bEnableOverflow)
295 base_type::set_max_load_factor(10000.f);
298 #if EASTL_NAME_ENABLED
299 mAllocator.set_name(EASTL_FIXED_HASH_MAP_DEFAULT_NAME);
302 mAllocator.reset(mNodeBuffer);
306 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
307 template <
typename InputIterator>
308 fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::
309 fixed_hash_map(InputIterator first, InputIterator last,
310 const Hash& hashFunction,
311 const Predicate& predicate)
312 : base_type(prime_rehash_policy::GetPrevBucketCountOnly(bucketCount), hashFunction,
313 predicate, fixed_allocator_type(NULL, mBucketBuffer))
315 EASTL_CT_ASSERT((nodeCount >= 1) && (bucketCount >= 2));
318 base_type::set_max_load_factor(10000.f);
320 #if EASTL_NAME_ENABLED
321 mAllocator.set_name(EASTL_FIXED_HASH_MAP_DEFAULT_NAME);
324 mAllocator.reset(mNodeBuffer);
325 base_type::insert(first, last);
329 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
330 inline fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::
331 fixed_hash_map(
const this_type& x)
332 : base_type(prime_rehash_policy::GetPrevBucketCountOnly(bucketCount), x.hash_function(),
333 x.equal_function(), fixed_allocator_type(NULL, mBucketBuffer))
335 mAllocator.copy_overflow_allocator(x.mAllocator);
337 #if EASTL_NAME_ENABLED
338 mAllocator.set_name(x.mAllocator.get_name());
341 EASTL_CT_ASSERT((nodeCount >= 1) && (bucketCount >= 2));
344 base_type::set_max_load_factor(10000.f);
346 mAllocator.reset(mNodeBuffer);
347 base_type::insert(x.begin(), x.end());
351 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
352 inline fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::
353 fixed_hash_map(this_type&& x)
354 : base_type(prime_rehash_policy::GetPrevBucketCountOnly(bucketCount), x.hash_function(),
355 x.equal_function(), fixed_allocator_type(NULL, mBucketBuffer))
358 mAllocator.copy_overflow_allocator(x.mAllocator);
360 #if EASTL_NAME_ENABLED
361 mAllocator.set_name(x.mAllocator.get_name());
364 EASTL_CT_ASSERT((nodeCount >= 1) && (bucketCount >= 2));
367 base_type::set_max_load_factor(10000.f);
369 mAllocator.reset(mNodeBuffer);
370 base_type::insert(x.begin(), x.end());
374 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
375 inline fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::
376 fixed_hash_map(this_type&& x,
const overflow_allocator_type& overflowAllocator)
377 : base_type(prime_rehash_policy::GetPrevBucketCountOnly(bucketCount), x.hash_function(),
378 x.equal_function(), fixed_allocator_type(NULL, mBucketBuffer, overflowAllocator))
381 mAllocator.copy_overflow_allocator(x.mAllocator);
383 #if EASTL_NAME_ENABLED
384 mAllocator.set_name(x.mAllocator.get_name());
387 EASTL_CT_ASSERT((nodeCount >= 1) && (bucketCount >= 2));
390 base_type::set_max_load_factor(10000.f);
392 mAllocator.reset(mNodeBuffer);
393 base_type::insert(x.begin(), x.end());
397 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
398 inline fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::
400 : base_type(prime_rehash_policy::GetPrevBucketCountOnly(bucketCount), Hash(),
401 Predicate(), fixed_allocator_type(NULL, mBucketBuffer, overflowAllocator))
403 EASTL_CT_ASSERT((nodeCount >= 1) && (bucketCount >= 2));
406 base_type::set_max_load_factor(10000.f);
408 #if EASTL_NAME_ENABLED
409 mAllocator.set_name(EASTL_FIXED_HASH_MAP_DEFAULT_NAME);
412 mAllocator.reset(mNodeBuffer);
413 base_type::insert(ilist.begin(), ilist.end());
417 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
418 inline typename fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::this_type&
419 fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::operator=(
const this_type& x)
421 base_type::operator=(x);
426 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
427 inline typename fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::this_type&
428 fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::operator=(this_type&& x)
430 base_type::operator=(x);
435 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
436 inline typename fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::this_type&
437 fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::operator=(
std::initializer_list<value_type> ilist)
440 base_type::insert(ilist.begin(), ilist.end());
445 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
446 inline void fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::
450 eastl::fixed_swap(*
this, x);
454 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
455 inline void fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::
458 base_type::mnBucketCount = (size_type)base_type::mRehashPolicy.GetPrevBucketCount((uint32_t)bucketCount);
459 base_type::mnElementCount = 0;
460 base_type::mRehashPolicy.mnNextResize = 0;
461 base_type::get_allocator().reset(mNodeBuffer);
465 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
466 inline typename fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::size_type
467 fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::max_size()
const
473 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
474 inline const typename fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::overflow_allocator_type&
475 fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::get_overflow_allocator() const EA_NOEXCEPT
477 return mAllocator.get_overflow_allocator();
481 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
482 inline typename fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::overflow_allocator_type&
483 fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::get_overflow_allocator() EA_NOEXCEPT
485 return mAllocator.get_overflow_allocator();
489 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
490 inline void fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::
491 set_overflow_allocator(
const overflow_allocator_type& allocator)
493 mAllocator.set_overflow_allocator(allocator);
497 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
498 inline void fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::
499 clear(
bool clearBuckets)
501 base_type::DoFreeNodes(base_type::mpBucketArray, base_type::mnBucketCount);
504 base_type::DoFreeBuckets(base_type::mpBucketArray, base_type::mnBucketCount);
507 base_type::mpBucketArray = (node_type**)mBucketBuffer;
508 base_type::mnElementCount = 0;
516 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode>
517 inline void swap(fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode>& a,
518 fixed_hash_map<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode>& b)
521 eastl::fixed_swap(a, b);
531 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
532 inline fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::
533 fixed_hash_multimap(
const overflow_allocator_type& overflowAllocator)
534 : base_type(prime_rehash_policy::GetPrevBucketCountOnly(bucketCount), Hash(),
535 Predicate(), fixed_allocator_type(NULL, mBucketBuffer, overflowAllocator))
537 EASTL_CT_ASSERT((nodeCount >= 1) && (bucketCount >= 2));
539 if (!bEnableOverflow)
541 base_type::set_max_load_factor(10000.f);
544 #if EASTL_NAME_ENABLED
545 mAllocator.set_name(EASTL_FIXED_HASH_MULTIMAP_DEFAULT_NAME);
548 mAllocator.reset(mNodeBuffer);
552 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
553 inline fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::
554 fixed_hash_multimap(
const Hash& hashFunction,
555 const Predicate& predicate)
556 : base_type(prime_rehash_policy::GetPrevBucketCountOnly(bucketCount), hashFunction,
557 predicate, fixed_allocator_type(NULL, mBucketBuffer))
559 EASTL_CT_ASSERT((nodeCount >= 1) && (bucketCount >= 2));
562 base_type::set_max_load_factor(10000.f);
564 #if EASTL_NAME_ENABLED
565 mAllocator.set_name(EASTL_FIXED_HASH_MULTIMAP_DEFAULT_NAME);
568 mAllocator.reset(mNodeBuffer);
572 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
573 inline fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::
574 fixed_hash_multimap(
const Hash& hashFunction,
575 const Predicate& predicate,
576 const overflow_allocator_type& overflowAllocator)
577 : base_type(prime_rehash_policy::GetPrevBucketCountOnly(bucketCount), hashFunction,
578 predicate, fixed_allocator_type(NULL, mBucketBuffer, overflowAllocator))
580 EASTL_CT_ASSERT((nodeCount >= 1) && (bucketCount >= 2));
583 base_type::set_max_load_factor(10000.f);
585 #if EASTL_NAME_ENABLED
586 mAllocator.set_name(EASTL_FIXED_HASH_MULTIMAP_DEFAULT_NAME);
589 mAllocator.reset(mNodeBuffer);
593 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
594 template <
typename InputIterator>
595 fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::
596 fixed_hash_multimap(InputIterator first, InputIterator last,
597 const Hash& hashFunction,
598 const Predicate& predicate)
599 : base_type(prime_rehash_policy::GetPrevBucketCountOnly(bucketCount), hashFunction,
600 predicate, fixed_allocator_type(NULL, mBucketBuffer))
602 EASTL_CT_ASSERT((nodeCount >= 1) && (bucketCount >= 2));
605 base_type::set_max_load_factor(10000.f);
607 #if EASTL_NAME_ENABLED
608 mAllocator.set_name(EASTL_FIXED_HASH_MULTIMAP_DEFAULT_NAME);
611 mAllocator.reset(mNodeBuffer);
612 base_type::insert(first, last);
616 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
617 inline fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::
618 fixed_hash_multimap(
const this_type& x)
619 : base_type(prime_rehash_policy::GetPrevBucketCountOnly(bucketCount), x.hash_function(),
620 x.equal_function(),fixed_allocator_type(NULL, mBucketBuffer))
622 mAllocator.copy_overflow_allocator(x.mAllocator);
624 #if EASTL_NAME_ENABLED
625 mAllocator.set_name(x.mAllocator.get_name());
628 EASTL_CT_ASSERT((nodeCount >= 1) && (bucketCount >= 2));
631 base_type::set_max_load_factor(10000.f);
633 mAllocator.reset(mNodeBuffer);
634 base_type::insert(x.begin(), x.end());
638 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
639 inline fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::
640 fixed_hash_multimap(this_type&& x)
641 : base_type(prime_rehash_policy::GetPrevBucketCountOnly(bucketCount), x.hash_function(),
642 x.equal_function(),fixed_allocator_type(NULL, mBucketBuffer))
645 mAllocator.copy_overflow_allocator(x.mAllocator);
647 #if EASTL_NAME_ENABLED
648 mAllocator.set_name(x.mAllocator.get_name());
651 EASTL_CT_ASSERT((nodeCount >= 1) && (bucketCount >= 2));
654 base_type::set_max_load_factor(10000.f);
656 mAllocator.reset(mNodeBuffer);
657 base_type::insert(x.begin(), x.end());
661 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
662 inline fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::
663 fixed_hash_multimap(this_type&& x,
const overflow_allocator_type& overflowAllocator)
664 : base_type(prime_rehash_policy::GetPrevBucketCountOnly(bucketCount), x.hash_function(),
665 x.equal_function(), fixed_allocator_type(NULL, mBucketBuffer, overflowAllocator))
668 mAllocator.copy_overflow_allocator(x.mAllocator);
670 #if EASTL_NAME_ENABLED
671 mAllocator.set_name(x.mAllocator.get_name());
674 EASTL_CT_ASSERT((nodeCount >= 1) && (bucketCount >= 2));
677 base_type::set_max_load_factor(10000.f);
679 mAllocator.reset(mNodeBuffer);
680 base_type::insert(x.begin(), x.end());
684 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
685 inline fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::
687 : base_type(prime_rehash_policy::GetPrevBucketCountOnly(bucketCount), Hash(),
688 Predicate(), fixed_allocator_type(NULL, mBucketBuffer, overflowAllocator))
690 EASTL_CT_ASSERT((nodeCount >= 1) && (bucketCount >= 2));
693 base_type::set_max_load_factor(10000.f);
695 #if EASTL_NAME_ENABLED
696 mAllocator.set_name(EASTL_FIXED_HASH_MULTIMAP_DEFAULT_NAME);
699 mAllocator.reset(mNodeBuffer);
700 base_type::insert(ilist.begin(), ilist.end());
704 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
705 inline typename fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::this_type&
706 fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::operator=(
const this_type& x)
708 base_type::operator=(x);
713 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
714 inline typename fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::this_type&
715 fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::operator=(this_type&& x)
717 base_type::operator=(x);
722 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
723 inline typename fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::this_type&
724 fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::operator=(
std::initializer_list<value_type> ilist)
727 base_type::insert(ilist.begin(), ilist.end());
732 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
733 inline void fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::
737 eastl::fixed_swap(*
this, x);
741 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
742 inline void fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::
745 base_type::mnBucketCount = (size_type)base_type::mRehashPolicy.GetPrevBucketCount((uint32_t)bucketCount);
746 base_type::mnElementCount = 0;
747 base_type::mRehashPolicy.mnNextResize = 0;
748 base_type::get_allocator().reset(mNodeBuffer);
752 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
753 inline typename fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::size_type
754 fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::max_size()
const
760 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
761 inline const typename fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::overflow_allocator_type&
762 fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::get_overflow_allocator() const EA_NOEXCEPT
764 return mAllocator.get_overflow_allocator();
768 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
769 inline typename fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::overflow_allocator_type&
770 fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::get_overflow_allocator() EA_NOEXCEPT
772 return mAllocator.get_overflow_allocator();
776 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
777 inline void fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::set_overflow_allocator(
const overflow_allocator_type& allocator)
779 mAllocator.set_overflow_allocator(allocator);
783 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode,
typename OverflowAllocator>
784 inline void fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode, OverflowAllocator>::
785 clear(
bool clearBuckets)
787 base_type::DoFreeNodes(base_type::mpBucketArray, base_type::mnBucketCount);
790 base_type::DoFreeBuckets(base_type::mpBucketArray, base_type::mnBucketCount);
793 base_type::mpBucketArray = (node_type**)mBucketBuffer;
794 base_type::mnElementCount = 0;
802 template <
typename Key,
typename T,
size_t nodeCount,
size_t bucketCount,
bool bEnableOverflow,
typename Hash,
typename Predicate,
bool bCacheHashCode>
803 inline void swap(fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode>& a,
804 fixed_hash_multimap<Key, T, nodeCount, bucketCount, bEnableOverflow, Hash, Predicate, bCacheHashCode>& b)
807 eastl::fixed_swap(a, b);
814 EA_RESTORE_VC_WARNING()
Definition: initializer_list.h:38
EA Standard Template Library.
Definition: algorithm.h:288
Definition: functional.h:139
Definition: functional.h:1015
Definition: utility.h:371