momo  3.9
unordered_map.h
Go to the documentation of this file.
1 /**********************************************************\
2 
3  This file is part of the
4  https://github.com/morzhovets/momo
5  project, distributed under the MIT License. See
6  https://github.com/morzhovets/momo/blob/branch_cpp11/LICENSE
7  for details.
8 
9  momo/stdish/unordered_map.h
10 
11  namespace momo::stdish:
12  class unordered_map
13  class unordered_map_open
14 
15 \**********************************************************/
16 
17 #ifndef MOMO_INCLUDE_GUARD_STDISH_UNORDERED_MAP
18 #define MOMO_INCLUDE_GUARD_STDISH_UNORDERED_MAP
19 
20 #include "../HashMap.h"
21 #include "node_handle.h"
22 
23 namespace momo
24 {
25 
26 namespace stdish
27 {
28 
55 template<typename TKey, typename TMapped,
56  typename THashFunc = HashCoder<TKey>,
57  typename TEqualFunc = std::equal_to<TKey>,
58  typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>,
59  typename THashMap = HashMap<TKey, TMapped, HashTraitsStd<TKey, THashFunc, TEqualFunc>,
60  MemManagerStd<TAllocator>>>
62 {
63 private:
64  typedef THashMap HashMap;
65  typedef typename HashMap::HashTraits HashTraits;
66  typedef typename HashMap::MemManager MemManager;
67 
68  typedef typename HashMap::Iterator HashMapIterator;
69 
70 public:
71  typedef TKey key_type;
72  typedef TMapped mapped_type;
73  typedef THashFunc hasher;
74  typedef TEqualFunc key_equal;
75  typedef TAllocator allocator_type;
76 
77  typedef HashMap nested_container_type;
78 
79  typedef size_t size_type;
80  typedef ptrdiff_t difference_type;
81 
82  typedef std::pair<const key_type, mapped_type> value_type;
83 
84  typedef momo::internal::HashDerivedIterator<HashMapIterator,
87 
88  typedef typename iterator::Reference reference;
90 
91  typedef typename iterator::Pointer pointer;
93  //typedef typename std::allocator_traits<allocator_type>::pointer pointer;
94  //typedef typename std::allocator_traits<allocator_type>::const_pointer const_pointer;
95 
98 
102 
103 private:
104  template<typename KeyArg>
105  struct IsValidKeyArg : public HashTraits::template IsValidKeyArg<KeyArg>
106  {
107  };
108 
109  struct ConstIteratorProxy : public const_iterator
110  {
111  typedef const_iterator ConstIterator;
112  MOMO_DECLARE_PROXY_CONSTRUCTOR(ConstIterator)
113  MOMO_DECLARE_PROXY_FUNCTION(ConstIterator, GetBaseIterator,
115  };
116 
117  struct IteratorProxy : public iterator
118  {
119  typedef iterator Iterator;
121  MOMO_DECLARE_PROXY_FUNCTION(Iterator, GetBaseIterator, HashMapIterator)
122  };
123 
124  struct ConstLocalIteratorProxy : public const_local_iterator
125  {
126  typedef const_local_iterator ConstLocalIterator;
127  MOMO_DECLARE_PROXY_CONSTRUCTOR(ConstLocalIterator)
128  };
129 
130  struct LocalIteratorProxy : public local_iterator
131  {
132  typedef local_iterator LocalIterator;
133  MOMO_DECLARE_PROXY_CONSTRUCTOR(LocalIterator)
134  };
135 
136  struct NodeTypeProxy : private node_type
137  {
138  typedef node_type NodeType;
139  MOMO_DECLARE_PROXY_FUNCTION(NodeType, GetExtractedPair,
140  typename NodeType::MapExtractedPair&)
141  };
142 
143 public:
145  {
146  }
147 
148  explicit unordered_map(const allocator_type& alloc)
149  : mHashMap(HashTraits(), MemManager(alloc))
150  {
151  }
152 
153  explicit unordered_map(size_type bucketCount, const allocator_type& alloc = allocator_type())
154  : mHashMap(HashTraits(bucketCount), MemManager(alloc))
155  {
156  }
157 
158  unordered_map(size_type bucketCount, const hasher& hashFunc,
159  const allocator_type& alloc = allocator_type())
160  : mHashMap(HashTraits(bucketCount, hashFunc), MemManager(alloc))
161  {
162  }
163 
164  unordered_map(size_type bucketCount, const hasher& hashFunc, const key_equal& equalFunc,
165  const allocator_type& alloc = allocator_type())
166  : mHashMap(HashTraits(bucketCount, hashFunc, equalFunc), MemManager(alloc))
167  {
168  }
169 
170  template<typename Iterator>
171  unordered_map(Iterator first, Iterator last)
172  {
173  insert(first, last);
174  }
175 
176  template<typename Iterator>
177  unordered_map(Iterator first, Iterator last, size_type bucketCount,
178  const allocator_type& alloc = allocator_type())
179  : unordered_map(bucketCount, alloc)
180  {
181  insert(first, last);
182  }
183 
184  template<typename Iterator>
185  unordered_map(Iterator first, Iterator last, size_type bucketCount, const hasher& hashFunc,
186  const allocator_type& alloc = allocator_type())
187  : unordered_map(bucketCount, hashFunc, alloc)
188  {
189  insert(first, last);
190  }
191 
192  template<typename Iterator>
193  unordered_map(Iterator first, Iterator last, size_type bucketCount, const hasher& hashFunc,
194  const key_equal& equalFunc, const allocator_type& alloc = allocator_type())
195  : unordered_map(bucketCount, hashFunc, equalFunc, alloc)
196  {
197  insert(first, last);
198  }
199 
200  unordered_map(std::initializer_list<value_type> values)
201  : unordered_map(values.begin(), values.end())
202  {
203  }
204 
205  unordered_map(std::initializer_list<value_type> values, size_type bucketCount,
206  const allocator_type& alloc = allocator_type())
207  : unordered_map(values.begin(), values.end(), bucketCount, alloc)
208  {
209  }
210 
211  unordered_map(std::initializer_list<value_type> values, size_type bucketCount,
212  const hasher& hashFunc, const allocator_type& alloc = allocator_type())
213  : unordered_map(values.begin(), values.end(), bucketCount, hashFunc, alloc)
214  {
215  }
216 
217  unordered_map(std::initializer_list<value_type> values, size_type bucketCount,
218  const hasher& hashFunc, const key_equal& equalFunc,
219  const allocator_type& alloc = allocator_type())
220  : unordered_map(values.begin(), values.end(), bucketCount, hashFunc, equalFunc, alloc)
221  {
222  }
223 
224  unordered_map(unordered_map&& right) noexcept
225  : mHashMap(std::move(right.mHashMap))
226  {
227  }
228 
230  noexcept(std::is_empty<allocator_type>::value)
231  : mHashMap(pvCreateMap(std::move(right), alloc))
232  {
233  }
234 
236  : mHashMap(right.mHashMap)
237  {
238  }
239 
241  : mHashMap(right.mHashMap, MemManager(alloc))
242  {
243  }
244 
245  ~unordered_map() = default;
246 
248  noexcept(std::is_empty<allocator_type>::value ||
249  std::allocator_traits<allocator_type>::propagate_on_container_move_assignment::value)
250  {
251  if (this != &right)
252  {
253  bool propagate = std::is_empty<allocator_type>::value ||
254  std::allocator_traits<allocator_type>::propagate_on_container_move_assignment::value;
255  allocator_type alloc = (propagate ? &right : this)->get_allocator();
256  mHashMap = pvCreateMap(std::move(right), alloc);
257  }
258  return *this;
259  }
260 
262  {
263  if (this != &right)
264  {
265  bool propagate = std::is_empty<allocator_type>::value ||
266  std::allocator_traits<allocator_type>::propagate_on_container_copy_assignment::value;
267  allocator_type alloc = (propagate ? &right : this)->get_allocator();
268  mHashMap = HashMap(right.mHashMap, MemManager(alloc));
269  }
270  return *this;
271  }
272 
273  unordered_map& operator=(std::initializer_list<value_type> values)
274  {
275  HashMap hashMap(mHashMap.GetHashTraits(), MemManager(get_allocator()));
276  hashMap.Insert(values.begin(), values.end());
277  mHashMap = std::move(hashMap);
278  return *this;
279  }
280 
281  void swap(unordered_map& right) noexcept
282  {
283  MOMO_ASSERT(std::allocator_traits<allocator_type>::propagate_on_container_swap::value
284  || get_allocator() == right.get_allocator());
285  mHashMap.Swap(right.mHashMap);
286  }
287 
288  friend void swap(unordered_map& left, unordered_map& right) noexcept
289  {
290  left.swap(right);
291  }
292 
294  {
295  return mHashMap;
296  }
297 
299  {
300  return mHashMap;
301  }
302 
303  const_iterator begin() const noexcept
304  {
305  return ConstIteratorProxy(mHashMap.GetBegin());
306  }
307 
308  iterator begin() noexcept
309  {
310  return IteratorProxy(mHashMap.GetBegin());
311  }
312 
313  const_iterator end() const noexcept
314  {
315  return ConstIteratorProxy(mHashMap.GetEnd());
316  }
317 
318  iterator end() noexcept
319  {
320  return IteratorProxy(mHashMap.GetEnd());
321  }
322 
323  const_iterator cbegin() const noexcept
324  {
325  return begin();
326  }
327 
328  const_iterator cend() const noexcept
329  {
330  return end();
331  }
332 
333  float max_load_factor() const noexcept
334  {
335  return mHashMap.GetHashTraits().GetMaxLoadFactor(HashMap::bucketMaxItemCount);
336  }
337 
338  void max_load_factor(float maxLoadFactor)
339  {
340  if (maxLoadFactor == max_load_factor())
341  return;
342  if (maxLoadFactor <= 0.0 || maxLoadFactor > static_cast<float>(HashMap::bucketMaxItemCount))
343  throw std::out_of_range("invalid load factor");
344  HashTraits hashTraits(mHashMap.GetHashTraits(), maxLoadFactor);
345  HashMap hashMap(hashTraits, MemManager(get_allocator()));
346  hashMap.Reserve(size());
347  hashMap.Insert(begin(), end());
348  mHashMap = std::move(hashMap);
349  }
350 
352  {
353  return mHashMap.GetHashTraits().GetHashFunc();
354  }
355 
357  {
358  return mHashMap.GetHashTraits().GetEqualFunc();
359  }
360 
361  allocator_type get_allocator() const noexcept
362  {
363  return allocator_type(mHashMap.GetMemManager().GetByteAllocator());
364  }
365 
366  size_type max_size() const noexcept
367  {
368  return std::allocator_traits<allocator_type>::max_size(get_allocator());
369  }
370 
371  size_type size() const noexcept
372  {
373  return mHashMap.GetCount();
374  }
375 
376  MOMO_NODISCARD bool empty() const noexcept
377  {
378  return mHashMap.IsEmpty();
379  }
380 
381  void clear() noexcept
382  {
383  mHashMap.Clear();
384  }
385 
386  void rehash(size_type bucketCount)
387  {
388  bucketCount = std::minmax(bucketCount, size_t{2}).second;
389  size_t logBucketCount = momo::internal::UIntMath<>::Log2(bucketCount - 1) + 1;
390  bucketCount = size_t{1} << logBucketCount;
391  reserve(mHashMap.GetHashTraits().CalcCapacity(bucketCount, HashMap::bucketMaxItemCount));
392  }
393 
395  {
396  mHashMap.Reserve(count);
397  }
398 
400  {
401  return ConstIteratorProxy(mHashMap.Find(key));
402  }
403 
405  {
406  return IteratorProxy(mHashMap.Find(key));
407  }
408 
409  template<typename KeyArg>
411  const_iterator> find(const KeyArg& key) const
412  {
413  return ConstIteratorProxy(mHashMap.Find(key));
414  }
415 
416  template<typename KeyArg>
418  iterator> find(const KeyArg& key)
419  {
420  return IteratorProxy(mHashMap.Find(key));
421  }
422 
424  {
425  return contains(key) ? 1 : 0;
426  }
427 
428  template<typename KeyArg>
430  size_type> count(const KeyArg& key) const
431  {
432  return contains(key) ? 1 : 0;
433  }
434 
435  MOMO_FORCEINLINE bool contains(const key_type& key) const
436  {
437  return mHashMap.ContainsKey(key);
438  }
439 
440  template<typename KeyArg>
442  bool> contains(const KeyArg& key) const
443  {
444  return mHashMap.ContainsKey(key);
445  }
446 
447  MOMO_FORCEINLINE std::pair<const_iterator, const_iterator> equal_range(const key_type& key) const
448  {
449  return { find(key), end() };
450  }
451 
452  MOMO_FORCEINLINE std::pair<iterator, iterator> equal_range(const key_type& key)
453  {
454  return { find(key), end() };
455  }
456 
457  template<typename KeyArg>
459  std::pair<const_iterator, const_iterator>> equal_range(const KeyArg& key) const
460  {
461  return { find(key), end() };
462  }
463 
464  template<typename KeyArg>
466  std::pair<iterator, iterator>> equal_range(const KeyArg& key)
467  {
468  return { find(key), end() };
469  }
470 
471  //template<typename Value>
472  //momo::internal::EnableIf<std::is_constructible<value_type, Value>::value,
473  //std::pair<iterator, bool>> insert(Value&& value)
474 
475  //template<typename Value>
476  //momo::internal::EnableIf<std::is_constructible<value_type, Value>::value,
477  //iterator> insert(const_iterator hint, Value&& value)
478 
479  //std::pair<iterator, bool> insert(value_type&& value)
480 
481  //iterator insert(const_iterator hint, value_type&& value)
482 
483  //std::pair<iterator, bool> insert(const value_type& value)
484 
485  //iterator insert(const_iterator hint, const value_type& value)
486 
487  std::pair<iterator, bool> insert(std::pair<key_type, mapped_type>&& value)
488  {
489  return pvEmplace(nullptr, std::forward_as_tuple(std::move(value.first)),
490  std::forward_as_tuple(std::move(value.second)));
491  }
492 
493  iterator insert(const_iterator hint, std::pair<key_type, mapped_type>&& value)
494  {
495  return pvEmplace(hint, std::forward_as_tuple(std::move(value.first)),
496  std::forward_as_tuple(std::move(value.second))).first;
497  }
498 
499  template<typename First, typename Second>
501  && std::is_constructible<mapped_type, const Second&>::value,
502  std::pair<iterator, bool>> insert(const std::pair<First, Second>& value)
503  {
504  return pvEmplace(nullptr, std::forward_as_tuple(value.first),
505  std::forward_as_tuple(value.second));
506  }
507 
508  template<typename First, typename Second>
510  && std::is_constructible<mapped_type, const Second&>::value,
511  iterator> insert(const_iterator hint, const std::pair<First, Second>& value)
512  {
513  return pvEmplace(hint, std::forward_as_tuple(value.first),
514  std::forward_as_tuple(value.second)).first;
515  }
516 
517  template<typename First, typename Second>
519  && std::is_constructible<mapped_type, Second&&>::value,
520  std::pair<iterator, bool>> insert(std::pair<First, Second>&& value)
521  {
522  return pvEmplace(nullptr, std::forward_as_tuple(std::forward<First>(value.first)),
523  std::forward_as_tuple(std::forward<Second>(value.second)));
524  }
525 
526  template<typename First, typename Second>
528  && std::is_constructible<mapped_type, Second&&>::value,
529  iterator> insert(const_iterator hint, std::pair<First, Second>&& value)
530  {
531  return pvEmplace(hint, std::forward_as_tuple(std::forward<First>(value.first)),
532  std::forward_as_tuple(std::forward<Second>(value.second))).first;
533  }
534 
536  {
537  if (node.empty())
538  return { end(), false, node_type() };
539  typename HashMap::InsertResult res = mHashMap.Insert(
540  std::move(NodeTypeProxy::GetExtractedPair(node)));
541  return { IteratorProxy(res.position), res.inserted,
542  res.inserted ? node_type() : std::move(node) };
543  }
544 
546  {
547 #ifdef MOMO_USE_UNORDERED_HINT_ITERATORS
548  if (node.empty())
549  return end();
550  return IteratorProxy(mHashMap.Add(ConstIteratorProxy::GetBaseIterator(hint),
551  std::move(NodeTypeProxy::GetExtractedPair(node))));
552 #else
553  (void)hint;
554  return insert(std::move(node)).position;
555 #endif
556  }
557 
558  template<typename Iterator>
559  void insert(Iterator first, Iterator last)
560  {
562  }
563 
564  void insert(std::initializer_list<value_type> values)
565  {
566  mHashMap.Insert(values.begin(), values.end());
567  }
568 
569  std::pair<iterator, bool> emplace()
570  {
571  return pvEmplace(nullptr, std::tuple<>(), std::tuple<>());
572  }
573 
575  {
576  return pvEmplace(hint, std::tuple<>(), std::tuple<>()).first;
577  }
578 
579  template<typename ValueArg>
580  std::pair<iterator, bool> emplace(ValueArg&& valueArg)
581  {
582  return insert(std::forward<ValueArg>(valueArg));
583  }
584 
585  template<typename ValueArg>
586  iterator emplace_hint(const_iterator hint, ValueArg&& valueArg)
587  {
588  return insert(hint, std::forward<ValueArg>(valueArg));
589  }
590 
591  template<typename KeyArg, typename MappedArg>
592  std::pair<iterator, bool> emplace(KeyArg&& keyArg, MappedArg&& mappedArg)
593  {
594  return pvEmplace(nullptr, std::forward_as_tuple(std::forward<KeyArg>(keyArg)),
595  std::forward_as_tuple(std::forward<MappedArg>(mappedArg)));
596  }
597 
598  template<typename KeyArg, typename MappedArg>
599  iterator emplace_hint(const_iterator hint, KeyArg&& keyArg, MappedArg&& mappedArg)
600  {
601  return pvEmplace(hint, std::forward_as_tuple(std::forward<KeyArg>(keyArg)),
602  std::forward_as_tuple(std::forward<MappedArg>(mappedArg))).first;
603  }
604 
605  template<typename... KeyArgs, typename... MappedArgs>
606  std::pair<iterator, bool> emplace(std::piecewise_construct_t,
607  std::tuple<KeyArgs...> keyArgs, std::tuple<MappedArgs...> mappedArgs)
608  {
609  return pvEmplace(nullptr, std::move(keyArgs), std::move(mappedArgs));
610  }
611 
612  template<typename... KeyArgs, typename... MappedArgs>
613  iterator emplace_hint(const_iterator hint, std::piecewise_construct_t,
614  std::tuple<KeyArgs...> keyArgs, std::tuple<MappedArgs...> mappedArgs)
615  {
616  return pvEmplace(hint, std::move(keyArgs), std::move(mappedArgs)).first;
617  }
618 
620  {
621  return IteratorProxy(mHashMap.Remove(ConstIteratorProxy::GetBaseIterator(where)));
622  }
623 
625  {
626  return erase(static_cast<const_iterator>(where));
627  }
628 
630  {
631  if (first == begin() && last == end())
632  {
633  clear();
634  return end();
635  }
636  if (first == last)
637  {
638  return IteratorProxy(mHashMap.MakeMutableIterator(
639  ConstIteratorProxy::GetBaseIterator(first)));
640  }
641  if (first != end() && std::next(first) == last)
642  return erase(first);
643  throw std::invalid_argument("invalid unordered_map erase arguments");
644  }
645 
647  {
648  return mHashMap.Remove(key) ? 1 : 0;
649  }
650 
651  template<typename ValueFilter>
652  friend size_type erase_if(unordered_map& cont, const ValueFilter& valueFilter)
653  {
654  auto pairFilter = [&valueFilter] (const key_type& key, const mapped_type& mapped)
655  { return valueFilter(const_reference(key, mapped)); };
656  return cont.mHashMap.Remove(pairFilter);
657  }
658 
660  {
661  return mHashMap[std::move(key)];
662  }
663 
665  {
666  return mHashMap[key];
667  }
668 
669  MOMO_FORCEINLINE const mapped_type& at(const key_type& key) const
670  {
671  const_iterator iter = find(key);
672  if (iter == end())
673  throw std::out_of_range("invalid unordered_map key");
674  return iter->second;
675  }
676 
678  {
679  iterator iter = find(key);
680  if (iter == end())
681  throw std::out_of_range("invalid unordered_map key");
682  return iter->second;
683  }
684 
685  template<typename... MappedArgs>
686  std::pair<iterator, bool> try_emplace(key_type&& key, MappedArgs&&... mappedArgs)
687  {
688  return pvEmplace(nullptr, std::forward_as_tuple(std::move(key)),
689  std::forward_as_tuple(std::forward<MappedArgs>(mappedArgs)...));
690  }
691 
692  template<typename... MappedArgs>
693  iterator try_emplace(const_iterator hint, key_type&& key, MappedArgs&&... mappedArgs)
694  {
695  return pvEmplace(hint, std::forward_as_tuple(std::move(key)),
696  std::forward_as_tuple(std::forward<MappedArgs>(mappedArgs)...)).first;
697  }
698 
699  template<typename... MappedArgs>
700  std::pair<iterator, bool> try_emplace(const key_type& key, MappedArgs&&... mappedArgs)
701  {
702  return pvEmplace(nullptr, std::forward_as_tuple(key),
703  std::forward_as_tuple(std::forward<MappedArgs>(mappedArgs)...));
704  }
705 
706  template<typename... MappedArgs>
707  iterator try_emplace(const_iterator hint, const key_type& key, MappedArgs&&... mappedArgs)
708  {
709  return pvEmplace(hint, std::forward_as_tuple(key),
710  std::forward_as_tuple(std::forward<MappedArgs>(mappedArgs)...)).first;
711  }
712 
713  template<typename MappedArg>
714  std::pair<iterator, bool> insert_or_assign(key_type&& key, MappedArg&& mappedArg)
715  {
716  return pvInsertOrAssign(nullptr, std::move(key), std::forward<MappedArg>(mappedArg));
717  }
718 
719  template<typename MappedArg>
720  iterator insert_or_assign(const_iterator hint, key_type&& key, MappedArg&& mappedArg)
721  {
722  return pvInsertOrAssign(hint, std::move(key), std::forward<MappedArg>(mappedArg)).first;
723  }
724 
725  template<typename MappedArg>
726  std::pair<iterator, bool> insert_or_assign(const key_type& key, MappedArg&& mappedArg)
727  {
728  return pvInsertOrAssign(nullptr, key, std::forward<MappedArg>(mappedArg));
729  }
730 
731  template<typename MappedArg>
732  iterator insert_or_assign(const_iterator hint, const key_type& key, MappedArg&& mappedArg)
733  {
734  return pvInsertOrAssign(hint, key, std::forward<MappedArg>(mappedArg)).first;
735  }
736 
738  {
739  return node_type(*this, where); // need RVO for exception safety
740  }
741 
743  {
744  const_iterator iter = find(key);
745  return (iter != end()) ? extract(iter) : node_type();
746  }
747 
748  template<typename Map>
749  void merge(Map&& map)
750  {
751  mHashMap.MergeFrom(map.get_nested_container());
752  }
753 
754  size_type max_bucket_count() const noexcept
755  {
757  //return momo::internal::HashSetBuckets<Bucket>::maxBucketCount;
758  }
759 
760  size_type bucket_count() const noexcept
761  {
762  return mHashMap.GetBucketCount();
763  }
764 
765  size_type bucket_size(size_type bucketIndex) const
766  {
767  return mHashMap.GetBucketBounds(bucketIndex).GetCount();
768  }
769 
771  {
772  return LocalIteratorProxy(mHashMap.GetBucketBounds(bucketIndex).GetBegin());
773  }
774 
776  {
777  return ConstLocalIteratorProxy(mHashMap.GetBucketBounds(bucketIndex).GetBegin());
778  }
779 
781  {
782  return LocalIteratorProxy(mHashMap.GetBucketBounds(bucketIndex).GetEnd());
783  }
784 
785  const_local_iterator end(size_type bucketIndex) const
786  {
787  return ConstLocalIteratorProxy(mHashMap.GetBucketBounds(bucketIndex).GetEnd());
788  }
789 
791  {
792  return begin(bucketIndex);
793  }
794 
796  {
797  return end(bucketIndex);
798  }
799 
800  size_type bucket(const key_type& key) const
801  {
802  return mHashMap.GetBucketIndex(key);
803  }
804 
805  float load_factor() const noexcept
806  {
807  size_t count = size();
808  size_t bucketCount = bucket_count();
809  if (count == 0 && bucketCount == 0)
810  return 0.0;
811  return static_cast<float>(count) / static_cast<float>(bucketCount);
812  }
813 
814  bool operator==(const unordered_map& right) const
815  {
816  if (size() != right.size())
817  return false;
818  for (const_reference ref : *this)
819  {
820  const_iterator iter = right.find(ref.first);
821  if (iter == right.end())
822  return false;
823  if (!(iter->second == ref.second))
824  return false;
825  }
826  return true;
827  }
828 
829  bool operator!=(const unordered_map& right) const
830  {
831  return !(*this == right);
832  }
833 
834 private:
835  static HashMap pvCreateMap(unordered_map&& right, const allocator_type& alloc)
836  {
837  if (right.get_allocator() == alloc)
838  return std::move(right.mHashMap);
839  HashMap hashMap(right.mHashMap.GetHashTraits(), MemManager(alloc));
840  hashMap.MergeFrom(right.mHashMap);
841  return hashMap;
842  }
843 
844  template<typename Hint, typename... KeyArgs, typename... MappedArgs>
845  std::pair<iterator, bool> pvEmplace(Hint hint, std::tuple<KeyArgs...>&& keyArgs,
846  std::tuple<MappedArgs...>&& mappedArgs)
847  {
848  typedef typename HashMap::KeyValueTraits
849  ::template ValueCreator<MappedArgs...> MappedCreator;
850  return pvInsert(hint, std::move(keyArgs),
851  MappedCreator(mHashMap.GetMemManager(), std::move(mappedArgs)));
852  }
853 
854  template<typename Hint, typename... KeyArgs, typename MappedCreator>
855  std::pair<iterator, bool> pvInsert(Hint /*hint*/, std::tuple<KeyArgs...>&& keyArgs,
856  MappedCreator&& mappedCreator)
857  {
858  MemManager& memManager = mHashMap.GetMemManager();
861  typedef typename KeyManager::template Creator<KeyArgs...> KeyCreator;
862  KeyBuffer keyBuffer;
863  KeyCreator(memManager, std::move(keyArgs))(&keyBuffer);
864  bool keyDestroyed = false;
865  try
866  {
867  typename HashMap::Position pos = mHashMap.Find(*&keyBuffer);
868  if (!!pos)
869  {
870  KeyManager::Destroy(memManager, *&keyBuffer);
871  keyDestroyed = true;
872  return { IteratorProxy(pos), false };
873  }
874  auto valueCreator = [&memManager, &keyBuffer, &mappedCreator, &keyDestroyed]
875  (key_type* newKey, mapped_type* newMapped)
876  {
877  KeyManager::Relocate(memManager, *&keyBuffer, newKey);
878  keyDestroyed = true;
879  try
880  {
881  std::forward<MappedCreator>(mappedCreator)(newMapped);
882  }
883  catch (...)
884  {
885  KeyManager::Destroy(memManager, *newKey);
886  throw;
887  }
888  };
889  typename HashMap::Position resPos = mHashMap.AddCrt(pos, valueCreator);
890  return { IteratorProxy(resPos), true };
891  }
892  catch (...)
893  {
894  if (!keyDestroyed)
895  KeyManager::Destroy(memManager, *&keyBuffer);
896  throw;
897  }
898  }
899 
900  template<typename Hint, typename RKey, typename MappedCreator,
901  typename Key = typename std::decay<RKey>::type>
903  std::pair<iterator, bool>> pvInsert(Hint /*hint*/, std::tuple<RKey>&& key,
904  MappedCreator&& mappedCreator)
905  {
906  typename HashMap::InsertResult res = mHashMap.InsertCrt(
907  std::forward<RKey>(std::get<0>(key)), std::forward<MappedCreator>(mappedCreator));
908  return { IteratorProxy(res.position), res.inserted };
909  }
910 
911 #ifdef MOMO_USE_UNORDERED_HINT_ITERATORS
912  template<typename... KeyArgs, typename MappedCreator>
913  std::pair<iterator, bool> pvInsert(const_iterator hint, std::tuple<KeyArgs...>&& keyArgs,
914  MappedCreator&& mappedCreator)
915  {
916  MemManager& memManager = mHashMap.GetMemManager();
918  typedef typename KeyManager::template Creator<KeyArgs...> KeyCreator;
919  auto valueCreator = [&memManager, &keyArgs, &mappedCreator]
920  (key_type* newKey, mapped_type* newMapped)
921  {
922  KeyCreator(memManager, std::move(keyArgs))(newKey);
923  try
924  {
925  std::forward<MappedCreator>(mappedCreator)(newMapped);
926  }
927  catch (...)
928  {
929  KeyManager::Destroy(memManager, *newKey);
930  throw;
931  }
932  };
933  typename HashMap::Position resPos = mHashMap.AddCrt(
934  ConstIteratorProxy::GetBaseIterator(hint), valueCreator);
935  return { IteratorProxy(resPos), true };
936  }
937 
938  template<typename RKey, typename MappedCreator,
939  typename Key = typename std::decay<RKey>::type>
941  std::pair<iterator, bool>> pvInsert(const_iterator hint, std::tuple<RKey>&& key,
942  MappedCreator&& mappedCreator)
943  {
944  typename HashMap::Position resPos = mHashMap.AddCrt(ConstIteratorProxy::GetBaseIterator(hint),
945  std::forward<RKey>(std::get<0>(key)), std::forward<MappedCreator>(mappedCreator));
946  return { IteratorProxy(resPos), true };
947  }
948 #endif // MOMO_USE_UNORDERED_HINT_ITERATORS
949 
950  template<typename Iterator>
951  void pvInsert(Iterator first, Iterator last, std::true_type /*isMapArgIterator*/)
952  {
953  mHashMap.Insert(first, last);
954  }
955 
956  template<typename Iterator>
957  void pvInsert(Iterator first, Iterator last, std::false_type /*isMapArgIterator*/)
958  {
959  for (Iterator iter = first; iter != last; ++iter)
960  insert(*iter);
961  }
962 
963  template<typename Hint, typename RKey, typename MappedArg>
964  std::pair<iterator, bool> pvInsertOrAssign(Hint hint, RKey&& key, MappedArg&& mappedArg)
965  {
966  std::pair<iterator, bool> res = pvEmplace(hint,
967  std::forward_as_tuple(std::forward<RKey>(key)),
968  std::forward_as_tuple(std::forward<MappedArg>(mappedArg)));
969  if (!res.second)
970  res.first->second = std::forward<MappedArg>(mappedArg);
971  return res;
972  }
973 
974 private:
975  HashMap mHashMap;
976 };
977 
987 template<typename TKey, typename TMapped,
988  typename THashFunc = HashCoder<TKey>,
989  typename TEqualFunc = std::equal_to<TKey>,
990  typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>>
991 class unordered_map_open : public unordered_map<TKey, TMapped, THashFunc, TEqualFunc, TAllocator,
992  HashMap<TKey, TMapped, HashTraitsStd<TKey, THashFunc, TEqualFunc, HashBucketOpenDefault>,
993  MemManagerStd<TAllocator>>>
994 {
995 private:
996  typedef unordered_map<TKey, TMapped, THashFunc, TEqualFunc, TAllocator,
999 
1000 public:
1001  using typename UnorderedMap::key_type;
1002  using typename UnorderedMap::mapped_type;
1003  using typename UnorderedMap::size_type;
1004  using typename UnorderedMap::value_type;
1005  using typename UnorderedMap::const_reference;
1006 
1007 public:
1008  using UnorderedMap::UnorderedMap;
1009 
1010  unordered_map_open() {} // clang 3.6
1011 
1012  unordered_map_open& operator=(std::initializer_list<value_type> values)
1013  {
1014  UnorderedMap::operator=(values);
1015  return *this;
1016  }
1017 
1018  friend void swap(unordered_map_open& left, unordered_map_open& right) noexcept
1019  {
1020  left.swap(right);
1021  }
1022 
1023  template<typename ValueFilter>
1024  friend size_type erase_if(unordered_map_open& cont, const ValueFilter& valueFilter)
1025  {
1026  auto pairFilter = [&valueFilter] (const key_type& key, const mapped_type& mapped)
1027  { return valueFilter(const_reference(key, mapped)); };
1028  return cont.get_nested_container().Remove(pairFilter);
1029  }
1030 };
1031 
1032 #ifdef MOMO_HAS_DEDUCTION_GUIDES
1033 
1034 #define MOMO_DECLARE_DEDUCTION_GUIDES(unordered_map) \
1035 template<typename Iterator, \
1036  typename Key = std::remove_const_t<typename std::iterator_traits<Iterator>::value_type::first_type>, \
1037  typename Mapped = typename std::iterator_traits<Iterator>::value_type::second_type> \
1038 unordered_map(Iterator, Iterator) \
1039  -> unordered_map<Key, Mapped>; \
1040 template<typename Iterator, \
1041  typename Key = std::remove_const_t<typename std::iterator_traits<Iterator>::value_type::first_type>, \
1042  typename Mapped = typename std::iterator_traits<Iterator>::value_type::second_type, \
1043  typename Allocator = std::allocator<std::pair<const Key, Mapped>>, \
1044  typename = decltype(std::declval<Allocator&>().allocate(size_t{}))> \
1045 unordered_map(Iterator, Iterator, size_t, Allocator = Allocator()) \
1046  -> unordered_map<Key, Mapped, HashCoder<Key>, std::equal_to<Key>, Allocator>; \
1047 template<typename Iterator, typename HashFunc, \
1048  typename Key = std::remove_const_t<typename std::iterator_traits<Iterator>::value_type::first_type>, \
1049  typename Mapped = typename std::iterator_traits<Iterator>::value_type::second_type, \
1050  typename Allocator = std::allocator<std::pair<const Key, Mapped>>, \
1051  typename = decltype(std::declval<HashFunc&>()(std::declval<const Key&>())), \
1052  typename = decltype(std::declval<Allocator&>().allocate(size_t{}))> \
1053 unordered_map(Iterator, Iterator, size_t, HashFunc, Allocator = Allocator()) \
1054  -> unordered_map<Key, Mapped, HashFunc, std::equal_to<Key>, Allocator>; \
1055 template<typename Iterator, typename HashFunc, typename EqualFunc, \
1056  typename Key = std::remove_const_t<typename std::iterator_traits<Iterator>::value_type::first_type>, \
1057  typename Mapped = typename std::iterator_traits<Iterator>::value_type::second_type, \
1058  typename Allocator = std::allocator<std::pair<const Key, Mapped>>, \
1059  typename = decltype(std::declval<HashFunc&>()(std::declval<const Key&>())), \
1060  typename = decltype(std::declval<EqualFunc&>()(std::declval<const Key&>(), std::declval<const Key&>()))> \
1061 unordered_map(Iterator, Iterator, size_t, HashFunc, EqualFunc, Allocator = Allocator()) \
1062  -> unordered_map<Key, Mapped, HashFunc, EqualFunc, Allocator>; \
1063 template<typename Key, typename Mapped> \
1064 unordered_map(std::initializer_list<std::pair<Key, Mapped>>) \
1065  -> unordered_map<Key, Mapped>; \
1066 template<typename Key, typename Mapped, \
1067  typename Allocator = std::allocator<std::pair<const Key, Mapped>>, \
1068  typename = decltype(std::declval<Allocator&>().allocate(size_t{}))> \
1069 unordered_map(std::initializer_list<std::pair<Key, Mapped>>, size_t, Allocator = Allocator()) \
1070  -> unordered_map<Key, Mapped, HashCoder<Key>, std::equal_to<Key>, Allocator>; \
1071 template<typename Key, typename Mapped, typename HashFunc, \
1072  typename Allocator = std::allocator<std::pair<const Key, Mapped>>, \
1073  typename = decltype(std::declval<HashFunc&>()(std::declval<const Key&>())), \
1074  typename = decltype(std::declval<Allocator&>().allocate(size_t{}))> \
1075 unordered_map(std::initializer_list<std::pair<Key, Mapped>>, size_t, HashFunc, Allocator = Allocator()) \
1076  -> unordered_map<Key, Mapped, HashFunc, std::equal_to<Key>, Allocator>; \
1077 template<typename Key, typename Mapped, typename HashFunc, typename EqualFunc, \
1078  typename Allocator = std::allocator<std::pair<const Key, Mapped>>, \
1079  typename = decltype(std::declval<HashFunc&>()(std::declval<const Key&>())), \
1080  typename = decltype(std::declval<EqualFunc&>()(std::declval<const Key&>(), std::declval<const Key&>()))> \
1081 unordered_map(std::initializer_list<std::pair<Key, Mapped>>, size_t, HashFunc, EqualFunc, Allocator = Allocator()) \
1082  -> unordered_map<Key, Mapped, HashFunc, EqualFunc, Allocator>;
1083 
1084 MOMO_DECLARE_DEDUCTION_GUIDES(unordered_map)
1085 MOMO_DECLARE_DEDUCTION_GUIDES(unordered_map_open)
1086 
1087 #undef MOMO_DECLARE_DEDUCTION_GUIDES
1088 
1089 #endif // MOMO_HAS_DEDUCTION_GUIDES
1090 
1091 } // namespace stdish
1092 
1093 } // namespace momo
1094 
1095 #endif // MOMO_INCLUDE_GUARD_STDISH_UNORDERED_MAP
momo::internal::ObjectManager
Definition: ObjectManager.h:196
momo::stdish::unordered_map::unordered_map
unordered_map(const unordered_map &right)
Definition: unordered_map.h:235
momo::internal::InsertResult::position
Position position
Definition: IteratorUtility.h:183
momo::stdish::unordered_map::end
iterator end() noexcept
Definition: unordered_map.h:318
momo::internal::UIntConst::maxSize
static const size_t maxSize
Definition: Utility.h:384
momo::stdish::unordered_map::size_type
size_t size_type
Definition: unordered_map.h:79
momo::stdish::unordered_map::get_allocator
allocator_type get_allocator() const noexcept
Definition: unordered_map.h:361
momo::internal::HashDerivedIterator::Reference
TReference< typename BaseIterator::Reference > Reference
Definition: IteratorUtility.h:396
momo::stdish::unordered_map::emplace
std::pair< iterator, bool > emplace(std::piecewise_construct_t, std::tuple< KeyArgs... > keyArgs, std::tuple< MappedArgs... > mappedArgs)
Definition: unordered_map.h:606
momo::stdish::unordered_map::nested_container_type
HashMap nested_container_type
Definition: unordered_map.h:77
momo::stdish::map
momo::stdish::map is similar to std::map, but much more efficient in memory usage....
Definition: map.h:869
momo::stdish::unordered_map::operator[]
MOMO_FORCEINLINE HashMap::ValueReferenceCKey operator[](const key_type &key)
Definition: unordered_map.h:664
momo::stdish::unordered_map::max_load_factor
float max_load_factor() const noexcept
Definition: unordered_map.h:333
momo::internal::HashMapBucketBounds::Iterator
HashMapIterator< typename HashSetBucketBounds::Iterator, isConst > Iterator
Definition: HashMap.h:219
momo::stdish::unordered_map::begin
local_iterator begin(size_type bucketIndex)
Definition: unordered_map.h:770
momo::stdish::unordered_map::insert_or_assign
iterator insert_or_assign(const_iterator hint, key_type &&key, MappedArg &&mappedArg)
Definition: unordered_map.h:720
momo::stdish::unordered_map::swap
friend void swap(unordered_map &left, unordered_map &right) noexcept
Definition: unordered_map.h:288
momo::stdish::unordered_map::emplace_hint
iterator emplace_hint(const_iterator hint, std::piecewise_construct_t, std::tuple< KeyArgs... > keyArgs, std::tuple< MappedArgs... > mappedArgs)
Definition: unordered_map.h:613
momo::internal::IsMapArgIteratorStd
Definition: MapUtility.h:1004
momo::stdish::unordered_map::unordered_map
unordered_map(Iterator first, Iterator last, size_type bucketCount, const hasher &hashFunc, const allocator_type &alloc=allocator_type())
Definition: unordered_map.h:185
momo::HashMap::ValueReferenceCKey
ValueReferencer::template ValueReference< const Key & > ValueReferenceCKey
Definition: HashMap.h:406
momo::stdish::unordered_map::get_nested_container
const nested_container_type & get_nested_container() const noexcept
Definition: unordered_map.h:293
momo::stdish::unordered_map::iterator
momo::internal::HashDerivedIterator< HashMapIterator, momo::internal::MapReferenceStd > iterator
Definition: unordered_map.h:85
momo::stdish::unordered_map::emplace_hint
iterator emplace_hint(const_iterator hint, KeyArg &&keyArg, MappedArg &&mappedArg)
Definition: unordered_map.h:599
momo::stdish::unordered_map::erase
iterator erase(const_iterator first, const_iterator last)
Definition: unordered_map.h:629
momo::stdish::unordered_map::insert_return_type
internal::insert_return_type< iterator, node_type > insert_return_type
Definition: unordered_map.h:97
momo::stdish::unordered_map::unordered_map
unordered_map(std::initializer_list< value_type > values, size_type bucketCount, const hasher &hashFunc, const allocator_type &alloc=allocator_type())
Definition: unordered_map.h:211
momo::stdish::internal::insert_return_type
Definition: node_handle.h:190
momo::stdish::unordered_map_open
momo::stdish::unordered_map_open is similar to std::unordered_map, but much more efficient in operati...
Definition: unordered_map.h:994
momo::HashMap::InsertResult
internal::InsertResult< Position > InsertResult
Definition: HashMap.h:392
momo::internal::UIntMath::Log2
static UInt Log2(UInt value) noexcept
Definition: Utility.h:322
momo::internal::HashMapIterator
Definition: HashMap.h:33
momo::stdish::unordered_map::try_emplace
iterator try_emplace(const_iterator hint, const key_type &key, MappedArgs &&... mappedArgs)
Definition: unordered_map.h:707
momo::stdish::unordered_map::equal_range
MOMO_FORCEINLINE momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, std::pair< iterator, iterator > > equal_range(const KeyArg &key)
Definition: unordered_map.h:466
momo::stdish::unordered_map::try_emplace
iterator try_emplace(const_iterator hint, key_type &&key, MappedArgs &&... mappedArgs)
Definition: unordered_map.h:693
momo::stdish::unordered_map::erase
iterator erase(iterator where)
Definition: unordered_map.h:624
momo::stdish::unordered_map::value_type
std::pair< const key_type, mapped_type > value_type
Definition: unordered_map.h:82
momo::stdish::unordered_map::key_eq
key_equal key_eq() const
Definition: unordered_map.h:356
momo::HashMap
Definition: HashMap.h:363
momo::MemManagerStd
MemManagerStd uses allocator<unsigned char>::allocate and deallocate
Definition: MemManager.h:176
momo::stdish::unordered_map::swap
void swap(unordered_map &right) noexcept
Definition: unordered_map.h:281
momo::stdish::unordered_map::cend
const_local_iterator cend(size_type bucketIndex) const
Definition: unordered_map.h:795
momo::stdish::unordered_map_open::const_reference
const_iterator::Reference const_reference
Definition: unordered_map.h:89
momo::stdish::unordered_map::insert_or_assign
iterator insert_or_assign(const_iterator hint, const key_type &key, MappedArg &&mappedArg)
Definition: unordered_map.h:732
momo::stdish::unordered_map_open::mapped_type
TMapped mapped_type
Definition: unordered_map.h:72
momo::stdish::unordered_map::load_factor
float load_factor() const noexcept
Definition: unordered_map.h:805
momo::stdish::unordered_map::begin
iterator begin() noexcept
Definition: unordered_map.h:308
momo::stdish::unordered_map_open::operator=
unordered_map_open & operator=(std::initializer_list< value_type > values)
Definition: unordered_map.h:1012
momo::stdish::unordered_map::equal_range
MOMO_FORCEINLINE momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, std::pair< const_iterator, const_iterator > > equal_range(const KeyArg &key) const
Definition: unordered_map.h:459
momo::stdish::unordered_map::operator=
unordered_map & operator=(const unordered_map &right)
Definition: unordered_map.h:261
momo::stdish::unordered_map::emplace_hint
iterator emplace_hint(const_iterator hint)
Definition: unordered_map.h:574
momo::internal::InsertResult
Definition: IteratorUtility.h:151
momo::stdish::unordered_map::find
MOMO_FORCEINLINE momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, iterator > find(const KeyArg &key)
Definition: unordered_map.h:418
momo::stdish::internal::map_node_handle::MapExtractedPair
TMapExtractedPair MapExtractedPair
Definition: node_handle.h:101
momo::stdish::unordered_map::const_reference
const_iterator::Reference const_reference
Definition: unordered_map.h:89
momo::stdish::unordered_map::merge
void merge(Map &&map)
Definition: unordered_map.h:749
momo::stdish::unordered_map::at
MOMO_FORCEINLINE mapped_type & at(const key_type &key)
Definition: unordered_map.h:677
momo::stdish::unordered_map::insert
iterator insert(const_iterator hint, std::pair< key_type, mapped_type > &&value)
Definition: unordered_map.h:493
momo::stdish::internal::map_node_handle
Definition: node_handle.h:99
momo::stdish::unordered_map::unordered_map
unordered_map(Iterator first, Iterator last, size_type bucketCount, const allocator_type &alloc=allocator_type())
Definition: unordered_map.h:177
momo::stdish::unordered_map::insert
momo::internal::EnableIf< std::is_constructible< key_type, First && >::value &&std::is_constructible< mapped_type, Second && >::value, iterator > insert(const_iterator hint, std::pair< First, Second > &&value)
Definition: unordered_map.h:529
momo::internal::EnableIf
typename std::enable_if< value, Type >::type EnableIf
Definition: Utility.h:174
momo::stdish::unordered_map::contains
MOMO_FORCEINLINE bool contains(const key_type &key) const
Definition: unordered_map.h:435
momo::stdish::unordered_map::bucket_count
size_type bucket_count() const noexcept
Definition: unordered_map.h:760
momo::stdish::unordered_map::end
local_iterator end(size_type bucketIndex)
Definition: unordered_map.h:780
momo::stdish::unordered_map::~unordered_map
~unordered_map()=default
momo::stdish::unordered_map::unordered_map
unordered_map(size_type bucketCount, const hasher &hashFunc, const key_equal &equalFunc, const allocator_type &alloc=allocator_type())
Definition: unordered_map.h:164
momo
Definition: Array.h:26
momo::stdish::unordered_map::unordered_map
unordered_map(const allocator_type &alloc)
Definition: unordered_map.h:148
momo::stdish::unordered_map::operator[]
MOMO_FORCEINLINE HashMap::ValueReferenceRKey operator[](key_type &&key)
Definition: unordered_map.h:659
momo::stdish::unordered_map
momo::stdish::unordered_map is similar to std::unordered_map, but much more efficient in memory usage...
Definition: unordered_map.h:62
momo::stdish::unordered_map::unordered_map
unordered_map(const unordered_map &right, const momo::internal::Identity< allocator_type > &alloc)
Definition: unordered_map.h:240
momo::stdish::unordered_map_open::key_type
TKey key_type
Definition: unordered_map.h:71
momo::stdish::unordered_map::emplace
std::pair< iterator, bool > emplace(KeyArg &&keyArg, MappedArg &&mappedArg)
Definition: unordered_map.h:592
momo::stdish::unordered_map::empty
MOMO_NODISCARD bool empty() const noexcept
Definition: unordered_map.h:376
momo::stdish::unordered_map::insert
momo::internal::EnableIf< std::is_constructible< key_type, const First & >::value &&std::is_constructible< mapped_type, const Second & >::value, iterator > insert(const_iterator hint, const std::pair< First, Second > &value)
Definition: unordered_map.h:511
momo::stdish::unordered_map::unordered_map
unordered_map(Iterator first, Iterator last)
Definition: unordered_map.h:171
momo::internal::IteratorPointer
Definition: IteratorUtility.h:279
momo::stdish::unordered_map::bucket_size
size_type bucket_size(size_type bucketIndex) const
Definition: unordered_map.h:765
momo::internal::InsertResult::inserted
bool inserted
Definition: IteratorUtility.h:186
momo::stdish::unordered_map::unordered_map
unordered_map(unordered_map &&right) noexcept
Definition: unordered_map.h:224
momo::internal::Identity
EnableIf< true, Type > Identity
Definition: Utility.h:177
momo::stdish::unordered_map::insert
std::pair< iterator, bool > insert(std::pair< key_type, mapped_type > &&value)
Definition: unordered_map.h:487
momo::stdish::unordered_map::difference_type
ptrdiff_t difference_type
Definition: unordered_map.h:80
momo::stdish::unordered_map::insert
momo::internal::EnableIf< std::is_constructible< key_type, First && >::value &&std::is_constructible< mapped_type, Second && >::value, std::pair< iterator, bool > > insert(std::pair< First, Second > &&value)
Definition: unordered_map.h:520
momo::stdish::unordered_map::max_bucket_count
size_type max_bucket_count() const noexcept
Definition: unordered_map.h:754
momo::stdish::unordered_map::unordered_map
unordered_map(size_type bucketCount, const allocator_type &alloc=allocator_type())
Definition: unordered_map.h:153
momo::stdish::unordered_map_open::size_type
size_t size_type
Definition: unordered_map.h:79
momo::internal::HashDerivedIterator::BaseIterator
TBaseIterator BaseIterator
Definition: IteratorUtility.h:393
momo::stdish::unordered_map::insert
momo::internal::EnableIf< std::is_constructible< key_type, const First & >::value &&std::is_constructible< mapped_type, const Second & >::value, std::pair< iterator, bool > > insert(const std::pair< First, Second > &value)
Definition: unordered_map.h:502
momo::stdish::unordered_map::max_load_factor
void max_load_factor(float maxLoadFactor)
Definition: unordered_map.h:338
momo::stdish::unordered_map::try_emplace
std::pair< iterator, bool > try_emplace(key_type &&key, MappedArgs &&... mappedArgs)
Definition: unordered_map.h:686
momo::stdish::unordered_map::cbegin
const_local_iterator cbegin(size_type bucketIndex) const
Definition: unordered_map.h:790
momo::HashMap::HashTraits
THashTraits HashTraits
Definition: HashMap.h:367
momo::stdish::unordered_map::begin
const_iterator begin() const noexcept
Definition: unordered_map.h:303
momo::stdish::unordered_map::operator=
unordered_map & operator=(std::initializer_list< value_type > values)
Definition: unordered_map.h:273
momo::stdish::unordered_map::reference
iterator::Reference reference
Definition: unordered_map.h:88
momo::stdish::unordered_map::node_type
internal::map_node_handle< typename HashMap::ExtractedPair > node_type
Definition: unordered_map.h:96
momo::stdish::unordered_map::operator!=
bool operator!=(const unordered_map &right) const
Definition: unordered_map.h:829
MOMO_DECLARE_PROXY_CONSTRUCTOR
#define MOMO_DECLARE_PROXY_CONSTRUCTOR(Object)
Definition: Utility.h:85
momo::stdish::unordered_map::at
MOMO_FORCEINLINE const mapped_type & at(const key_type &key) const
Definition: unordered_map.h:669
momo::stdish::unordered_map::insert
void insert(Iterator first, Iterator last)
Definition: unordered_map.h:559
momo::HashMap::bucketMaxItemCount
static const size_t bucketMaxItemCount
Definition: HashMap.h:399
momo::stdish::unordered_map_open::swap
friend void swap(unordered_map_open &left, unordered_map_open &right) noexcept
Definition: unordered_map.h:1018
momo::stdish::unordered_map::erase
iterator erase(const_iterator where)
Definition: unordered_map.h:619
momo::stdish::unordered_map::contains
MOMO_FORCEINLINE momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, bool > contains(const KeyArg &key) const
Definition: unordered_map.h:442
momo::stdish::unordered_map::count
MOMO_FORCEINLINE size_type count(const key_type &key) const
Definition: unordered_map.h:423
momo::stdish::unordered_map::begin
const_local_iterator begin(size_type bucketIndex) const
Definition: unordered_map.h:775
momo::stdish::unordered_map::insert
void insert(std::initializer_list< value_type > values)
Definition: unordered_map.h:564
momo::internal::HashDerivedIterator
Definition: IteratorUtility.h:391
momo::stdish::unordered_map::emplace_hint
iterator emplace_hint(const_iterator hint, ValueArg &&valueArg)
Definition: unordered_map.h:586
momo::stdish::unordered_map::bucket
size_type bucket(const key_type &key) const
Definition: unordered_map.h:800
momo::stdish::unordered_map::hash_function
hasher hash_function() const
Definition: unordered_map.h:351
momo::stdish::unordered_map::erase_if
friend size_type erase_if(unordered_map &cont, const ValueFilter &valueFilter)
Definition: unordered_map.h:652
momo::stdish::unordered_map::hasher
THashFunc hasher
Definition: unordered_map.h:73
momo::stdish::unordered_map::unordered_map
unordered_map(std::initializer_list< value_type > values, size_type bucketCount, const hasher &hashFunc, const key_equal &equalFunc, const allocator_type &alloc=allocator_type())
Definition: unordered_map.h:217
momo::stdish::unordered_map::local_iterator
momo::internal::HashDerivedIterator< typename HashMap::BucketBounds::Iterator, momo::internal::MapReferenceStd > local_iterator
Definition: unordered_map.h:100
momo::stdish::unordered_map::find
MOMO_FORCEINLINE const_iterator find(const key_type &key) const
Definition: unordered_map.h:399
momo::internal::ObjectBuffer
Definition: ObjectManager.h:161
momo::stdish::unordered_map::emplace
std::pair< iterator, bool > emplace()
Definition: unordered_map.h:569
momo::stdish::unordered_map::key_type
TKey key_type
Definition: unordered_map.h:71
momo::stdish::unordered_map::unordered_map
unordered_map(Iterator first, Iterator last, size_type bucketCount, const hasher &hashFunc, const key_equal &equalFunc, const allocator_type &alloc=allocator_type())
Definition: unordered_map.h:193
momo::stdish::unordered_map::end
const_iterator end() const noexcept
Definition: unordered_map.h:313
momo::stdish::unordered_map::equal_range
MOMO_FORCEINLINE std::pair< iterator, iterator > equal_range(const key_type &key)
Definition: unordered_map.h:452
momo::stdish::unordered_map::count
MOMO_FORCEINLINE momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, size_type > count(const KeyArg &key) const
Definition: unordered_map.h:430
std
Definition: ArrayUtility.h:299
momo::stdish::unordered_map::const_iterator
iterator::ConstIterator const_iterator
Definition: unordered_map.h:86
momo::stdish::unordered_map::clear
void clear() noexcept
Definition: unordered_map.h:381
MOMO_FORCEINLINE
#define MOMO_FORCEINLINE
Definition: UserSettings.h:114
momo::stdish::unordered_map::operator==
bool operator==(const unordered_map &right) const
Definition: unordered_map.h:814
momo::stdish::unordered_map::unordered_map
unordered_map(std::initializer_list< value_type > values, size_type bucketCount, const allocator_type &alloc=allocator_type())
Definition: unordered_map.h:205
momo::stdish::unordered_map::find
MOMO_FORCEINLINE momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, const_iterator > find(const KeyArg &key) const
Definition: unordered_map.h:411
momo::stdish::unordered_map::cbegin
const_iterator cbegin() const noexcept
Definition: unordered_map.h:323
momo::stdish::unordered_map::unordered_map
unordered_map()
Definition: unordered_map.h:144
momo::stdish::unordered_map::equal_range
MOMO_FORCEINLINE std::pair< const_iterator, const_iterator > equal_range(const key_type &key) const
Definition: unordered_map.h:447
momo::stdish::unordered_map::extract
node_type extract(const_iterator where)
Definition: unordered_map.h:737
momo::stdish::unordered_map::size
size_type size() const noexcept
Definition: unordered_map.h:371
momo::stdish::unordered_map::insert_or_assign
std::pair< iterator, bool > insert_or_assign(key_type &&key, MappedArg &&mappedArg)
Definition: unordered_map.h:714
momo::stdish::unordered_map::mapped_type
TMapped mapped_type
Definition: unordered_map.h:72
momo::HashMap::Position
internal::HashMapPosition< HashSetConstPosition > Position
Definition: HashMap.h:389
momo::stdish::unordered_map::try_emplace
std::pair< iterator, bool > try_emplace(const key_type &key, MappedArgs &&... mappedArgs)
Definition: unordered_map.h:700
momo::stdish::unordered_map_open::erase_if
friend size_type erase_if(unordered_map_open &cont, const ValueFilter &valueFilter)
Definition: unordered_map.h:1024
momo::stdish::unordered_map::operator=
unordered_map & operator=(unordered_map &&right) noexcept(std::is_empty< allocator_type >::value||std::allocator_traits< allocator_type >::propagate_on_container_move_assignment::value)
Definition: unordered_map.h:247
momo::stdish::unordered_map::extract
node_type extract(const key_type &key)
Definition: unordered_map.h:742
momo::stdish::unordered_map::unordered_map
unordered_map(unordered_map &&right, const momo::internal::Identity< allocator_type > &alloc) noexcept(std::is_empty< allocator_type >::value)
Definition: unordered_map.h:229
momo::stdish::unordered_map::unordered_map
unordered_map(size_type bucketCount, const hasher &hashFunc, const allocator_type &alloc=allocator_type())
Definition: unordered_map.h:158
momo::stdish::unordered_map::end
const_local_iterator end(size_type bucketIndex) const
Definition: unordered_map.h:785
momo::HashMap::MemManager
TMemManager MemManager
Definition: HashMap.h:368
momo::HashMap::ValueReferenceRKey
ValueReferencer::template ValueReference< Key && > ValueReferenceRKey
Definition: HashMap.h:405
momo::stdish::unordered_map::get_nested_container
nested_container_type & get_nested_container() noexcept
Definition: unordered_map.h:298
momo::stdish::unordered_map::unordered_map
unordered_map(std::initializer_list< value_type > values)
Definition: unordered_map.h:200
momo::stdish::unordered_map::const_local_iterator
local_iterator::ConstIterator const_local_iterator
Definition: unordered_map.h:101
momo::stdish::unordered_map::allocator_type
TAllocator allocator_type
Definition: unordered_map.h:75
momo::stdish::unordered_map::insert_or_assign
std::pair< iterator, bool > insert_or_assign(const key_type &key, MappedArg &&mappedArg)
Definition: unordered_map.h:726
momo::stdish::unordered_map::reserve
void reserve(size_type count)
Definition: unordered_map.h:394
momo::stdish::unordered_map::erase
size_type erase(const key_type &key)
Definition: unordered_map.h:646
node_handle.h
momo::stdish::unordered_map::emplace
std::pair< iterator, bool > emplace(ValueArg &&valueArg)
Definition: unordered_map.h:580
momo::stdish::unordered_map::pointer
iterator::Pointer pointer
Definition: unordered_map.h:91
MOMO_ASSERT
#define MOMO_ASSERT(expr)
Definition: UserSettings.h:162
momo::stdish::unordered_map::const_pointer
const_iterator::Pointer const_pointer
Definition: unordered_map.h:92
MOMO_DECLARE_PROXY_FUNCTION
#define MOMO_DECLARE_PROXY_FUNCTION(Object, Func, Result)
Definition: Utility.h:94
momo::stdish::unordered_map::insert
insert_return_type insert(node_type &&node)
Definition: unordered_map.h:535
MOMO_NODISCARD
#define MOMO_NODISCARD
Definition: UserSettings.h:192
momo::stdish::unordered_map::cend
const_iterator cend() const noexcept
Definition: unordered_map.h:328
momo::stdish::unordered_map::find
MOMO_FORCEINLINE iterator find(const key_type &key)
Definition: unordered_map.h:404
momo::stdish::unordered_map::rehash
void rehash(size_type bucketCount)
Definition: unordered_map.h:386
momo::stdish::unordered_map::insert
iterator insert(const_iterator hint, node_type &&node)
Definition: unordered_map.h:545
momo::stdish::unordered_map::key_equal
TEqualFunc key_equal
Definition: unordered_map.h:74
momo::stdish::unordered_map::max_size
size_type max_size() const noexcept
Definition: unordered_map.h:366
momo::stdish::unordered_map_open::unordered_map_open
unordered_map_open()
Definition: unordered_map.h:1010
momo::internal::MapReferenceStd
Definition: MapUtility.h:68