momo  3.9
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/map.h
10 
11  namespace momo::stdish:
12  class map
13  class multimap
14 
15 \**********************************************************/
16 
17 #ifndef MOMO_INCLUDE_GUARD_STDISH_MAP
18 #define MOMO_INCLUDE_GUARD_STDISH_MAP
19 
20 #include "../TreeMap.h"
21 #include "node_handle.h"
22 
23 namespace momo
24 {
25 
26 namespace stdish
27 {
28 
29 namespace internal
30 {
31  template<typename TKey, typename TLessFunc>
33  {
34  protected:
35  typedef TKey Key;
36  typedef TLessFunc LessFunc;
37 
38  public:
39  template<typename Value>
40  bool operator()(const Value& value1, const Value& value2) const
41  {
42  MOMO_STATIC_ASSERT((std::is_same<Key,
43  typename std::decay<decltype(value1.first)>::type>::value));
44  return comp(value1.first, value2.first);
45  }
46 
47  protected:
48  map_value_compare(const LessFunc& lessFunc)
49  : comp(lessFunc)
50  {
51  }
52 
53  protected:
55  };
56 
57  template<typename TKey, typename TMapped, typename TLessFunc, typename TAllocator,
58  typename TTreeMap>
59  class map_base
60  {
61  private:
62  typedef TTreeMap TreeMap;
63  typedef typename TreeMap::TreeTraits TreeTraits;
64  typedef typename TreeMap::MemManager MemManager;
65 
66  typedef typename TreeMap::Iterator TreeMapIterator;
67 
68  public:
69  typedef TKey key_type;
70  typedef TMapped mapped_type;
71  typedef TLessFunc key_compare;
72  typedef TAllocator allocator_type;
73 
74  typedef TreeMap nested_container_type;
75 
76  typedef size_t size_type;
77  typedef ptrdiff_t difference_type;
78 
79  typedef std::pair<const key_type, mapped_type> value_type;
80 
82 
86 
87  typedef typename iterator::Reference reference;
89 
90  typedef typename iterator::Pointer pointer;
92  //typedef typename std::allocator_traits<allocator_type>::pointer pointer;
93  //typedef typename std::allocator_traits<allocator_type>::const_pointer const_pointer;
94 
95  typedef std::reverse_iterator<iterator> reverse_iterator;
96  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
97 
100 
101  private:
102  template<typename KeyArg>
103  struct IsValidKeyArg : public TreeTraits::template IsValidKeyArg<KeyArg>
104  {
105  };
106 
107  struct ConstIteratorProxy : public const_iterator
108  {
109  typedef const_iterator ConstIterator;
110  MOMO_DECLARE_PROXY_CONSTRUCTOR(ConstIterator)
111  MOMO_DECLARE_PROXY_FUNCTION(ConstIterator, GetBaseIterator,
113  };
114 
115  struct IteratorProxy : public iterator
116  {
117  typedef iterator Iterator;
119  MOMO_DECLARE_PROXY_FUNCTION(Iterator, GetBaseIterator, TreeMapIterator)
120  };
121 
122  struct NodeTypeProxy : private node_type
123  {
124  typedef node_type NodeType;
125  MOMO_DECLARE_PROXY_FUNCTION(NodeType, GetExtractedPair,
126  typename NodeType::MapExtractedPair&)
127  };
128 
129  public:
131  {
132  }
133 
134  explicit map_base(const allocator_type& alloc)
135  : mTreeMap(TreeTraits(), MemManager(alloc))
136  {
137  }
138 
139  explicit map_base(const key_compare& lessFunc, const allocator_type& alloc = allocator_type())
140  : mTreeMap(TreeTraits(lessFunc), MemManager(alloc))
141  {
142  }
143 
144  template<typename Iterator>
145  map_base(Iterator first, Iterator last, const allocator_type& alloc = allocator_type())
146  : map_base(alloc)
147  {
148  insert(first, last);
149  }
150 
151  template<typename Iterator>
152  map_base(Iterator first, Iterator last, const key_compare& lessFunc,
153  const allocator_type& alloc = allocator_type())
154  : map_base(lessFunc, alloc)
155  {
156  insert(first, last);
157  }
158 
159  map_base(std::initializer_list<value_type> values,
160  const allocator_type& alloc = allocator_type())
161  : map_base(values.begin(), values.end(), alloc)
162  {
163  }
164 
165  map_base(std::initializer_list<value_type> values, const key_compare& lessFunc,
166  const allocator_type& alloc = allocator_type())
167  : map_base(values.begin(), values.end(), lessFunc, alloc)
168  {
169  }
170 
171  map_base(map_base&& right) noexcept
172  : mTreeMap(std::move(right.mTreeMap))
173  {
174  }
175 
177  noexcept(std::is_empty<allocator_type>::value)
178  : mTreeMap(pvCreateMap(std::move(right), alloc))
179  {
180  }
181 
182  map_base(const map_base& right)
183  : mTreeMap(right.mTreeMap)
184  {
185  }
186 
188  : mTreeMap(right.mTreeMap, MemManager(alloc))
189  {
190  }
191 
192  ~map_base() = default;
193 
195  noexcept(std::is_empty<allocator_type>::value ||
196  std::allocator_traits<allocator_type>::propagate_on_container_move_assignment::value)
197  {
198  if (this != &right)
199  {
200  bool propagate = std::is_empty<allocator_type>::value ||
201  std::allocator_traits<allocator_type>::propagate_on_container_move_assignment::value;
202  allocator_type alloc = (propagate ? &right : this)->get_allocator();
203  mTreeMap = pvCreateMap(std::move(right), alloc);
204  }
205  return *this;
206  }
207 
208  map_base& operator=(const map_base& right)
209  {
210  if (this != &right)
211  {
212  bool propagate = std::is_empty<allocator_type>::value ||
213  std::allocator_traits<allocator_type>::propagate_on_container_copy_assignment::value;
214  allocator_type alloc = (propagate ? &right : this)->get_allocator();
215  mTreeMap = TreeMap(right.mTreeMap, MemManager(alloc));
216  }
217  return *this;
218  }
219 
220  void swap(map_base& right) noexcept
221  {
222  MOMO_ASSERT(std::allocator_traits<allocator_type>::propagate_on_container_swap::value
223  || get_allocator() == right.get_allocator());
224  mTreeMap.Swap(right.mTreeMap);
225  }
226 
228  {
229  return mTreeMap;
230  }
231 
233  {
234  return mTreeMap;
235  }
236 
237  const_iterator begin() const noexcept
238  {
239  return ConstIteratorProxy(mTreeMap.GetBegin());
240  }
241 
242  iterator begin() noexcept
243  {
244  return IteratorProxy(mTreeMap.GetBegin());
245  }
246 
247  const_iterator end() const noexcept
248  {
249  return ConstIteratorProxy(mTreeMap.GetEnd());
250  }
251 
252  iterator end() noexcept
253  {
254  return IteratorProxy(mTreeMap.GetEnd());
255  }
256 
258  {
259  return const_reverse_iterator(end());
260  }
261 
263  {
264  return reverse_iterator(end());
265  }
266 
267  const_reverse_iterator rend() const noexcept
268  {
269  return const_reverse_iterator(begin());
270  }
271 
273  {
274  return reverse_iterator(begin());
275  }
276 
277  const_iterator cbegin() const noexcept
278  {
279  return begin();
280  }
281 
282  const_iterator cend() const noexcept
283  {
284  return end();
285  }
286 
288  {
289  return rbegin();
290  }
291 
292  const_reverse_iterator crend() const noexcept
293  {
294  return rend();
295  }
296 
298  {
299  return mTreeMap.GetTreeTraits().GetLessFunc();
300  }
301 
303  {
304  struct ValueCompareProxy : public value_compare
305  {
306  explicit ValueCompareProxy(const key_compare& keyComp)
307  : value_compare(keyComp)
308  {
309  }
310  };
311  return ValueCompareProxy(key_comp());
312  }
313 
314  allocator_type get_allocator() const noexcept
315  {
316  return allocator_type(mTreeMap.GetMemManager().GetByteAllocator());
317  }
318 
319  size_type max_size() const noexcept
320  {
321  return std::allocator_traits<allocator_type>::max_size(get_allocator());
322  }
323 
324  size_type size() const noexcept
325  {
326  return mTreeMap.GetCount();
327  }
328 
329  MOMO_NODISCARD bool empty() const noexcept
330  {
331  return mTreeMap.IsEmpty();
332  }
333 
334  void clear() noexcept
335  {
336  mTreeMap.Clear();
337  }
338 
339  const_iterator find(const key_type& key) const
340  {
341  return ConstIteratorProxy(mTreeMap.Find(key));
342  }
343 
344  iterator find(const key_type& key)
345  {
346  return IteratorProxy(mTreeMap.Find(key));
347  }
348 
349  template<typename KeyArg>
351  const_iterator> find(const KeyArg& key) const
352  {
353  return ConstIteratorProxy(mTreeMap.Find(key));
354  }
355 
356  template<typename KeyArg>
358  iterator> find(const KeyArg& key)
359  {
360  return IteratorProxy(mTreeMap.Find(key));
361  }
362 
363  size_type count(const key_type& key) const
364  {
365  return mTreeMap.GetKeyCount(key);
366  }
367 
368  template<typename KeyArg>
370  size_type> count(const KeyArg& key) const
371  {
372  return mTreeMap.GetKeyCount(key);
373  }
374 
375  bool contains(const key_type& key) const
376  {
377  return mTreeMap.ContainsKey(key);
378  }
379 
380  template<typename KeyArg>
382  bool> contains(const KeyArg& key) const
383  {
384  return mTreeMap.ContainsKey(key);
385  }
386 
388  {
389  return ConstIteratorProxy(mTreeMap.GetLowerBound(key));
390  }
391 
393  {
394  return IteratorProxy(mTreeMap.GetLowerBound(key));
395  }
396 
397  template<typename KeyArg>
399  const_iterator> lower_bound(const KeyArg& key) const
400  {
401  return ConstIteratorProxy(mTreeMap.GetLowerBound(key));
402  }
403 
404  template<typename KeyArg>
406  iterator> lower_bound(const KeyArg& key)
407  {
408  return IteratorProxy(mTreeMap.GetLowerBound(key));
409  }
410 
412  {
413  return ConstIteratorProxy(mTreeMap.GetUpperBound(key));
414  }
415 
417  {
418  return IteratorProxy(mTreeMap.GetUpperBound(key));
419  }
420 
421  template<typename KeyArg>
423  const_iterator> upper_bound(const KeyArg& key) const
424  {
425  return ConstIteratorProxy(mTreeMap.GetUpperBound(key));
426  }
427 
428  template<typename KeyArg>
430  iterator> upper_bound(const KeyArg& key)
431  {
432  return IteratorProxy(mTreeMap.GetUpperBound(key));
433  }
434 
435  std::pair<const_iterator, const_iterator> equal_range(const key_type& key) const
436  {
437  const_iterator iter = lower_bound(key);
439  return { iter, upper_bound(key) };
440  if (iter == end() || mTreeMap.GetTreeTraits().IsLess(key, iter->first))
441  return { iter, iter };
442  return { iter, std::next(iter) };
443  }
444 
445  std::pair<iterator, iterator> equal_range(const key_type& key)
446  {
447  iterator iter = lower_bound(key);
449  return { iter, upper_bound(key) };
450  if (iter == end() || mTreeMap.GetTreeTraits().IsLess(key, iter->first))
451  return { iter, iter };
452  return { iter, std::next(iter) };
453  }
454 
455  template<typename KeyArg>
457  std::pair<const_iterator, const_iterator>> equal_range(const KeyArg& key) const
458  {
459  return { lower_bound(key), upper_bound(key) };
460  }
461 
462  template<typename KeyArg>
464  std::pair<iterator, iterator>> equal_range(const KeyArg& key)
465  {
466  return { lower_bound(key), upper_bound(key) };
467  }
468 
469  //template<typename Value>
470  //momo::internal::EnableIf<std::is_constructible<value_type, Value>::value,
471  //std::pair<iterator, bool>> insert(Value&& value)
472 
473  //template<typename Value>
474  //momo::internal::EnableIf<std::is_constructible<value_type, Value>::value,
475  //iterator> insert(const_iterator hint, Value&& value)
476 
477  //std::pair<iterator, bool> insert(value_type&& value)
478 
479  //iterator insert(const_iterator hint, value_type&& value)
480 
481  //std::pair<iterator, bool> insert(const value_type& value)
482 
483  //iterator insert(const_iterator hint, const value_type& value)
484 
485  std::pair<iterator, bool> insert(std::pair<key_type, mapped_type>&& value)
486  {
487  return ptEmplace(nullptr, std::forward_as_tuple(std::move(value.first)),
488  std::forward_as_tuple(std::move(value.second)));
489  }
490 
491  iterator insert(const_iterator hint, std::pair<key_type, mapped_type>&& value)
492  {
493  return ptEmplace(hint, std::forward_as_tuple(std::move(value.first)),
494  std::forward_as_tuple(std::move(value.second))).first;
495  }
496 
497  template<typename First, typename Second>
499  && std::is_constructible<mapped_type, const Second&>::value,
500  std::pair<iterator, bool>> insert(const std::pair<First, Second>& value)
501  {
502  return ptEmplace(nullptr, std::forward_as_tuple(value.first),
503  std::forward_as_tuple(value.second));
504  }
505 
506  template<typename First, typename Second>
508  && std::is_constructible<mapped_type, const Second&>::value,
509  iterator> insert(const_iterator hint, const std::pair<First, Second>& value)
510  {
511  return ptEmplace(hint, std::forward_as_tuple(value.first),
512  std::forward_as_tuple(value.second)).first;
513  }
514 
515  template<typename First, typename Second>
517  && std::is_constructible<mapped_type, Second&&>::value,
518  std::pair<iterator, bool>> insert(std::pair<First, Second>&& value)
519  {
520  return ptEmplace(nullptr, std::forward_as_tuple(std::forward<First>(value.first)),
521  std::forward_as_tuple(std::forward<Second>(value.second)));
522  }
523 
524  template<typename First, typename Second>
526  && std::is_constructible<mapped_type, Second&&>::value,
527  iterator> insert(const_iterator hint, std::pair<First, Second>&& value)
528  {
529  return ptEmplace(hint, std::forward_as_tuple(std::forward<First>(value.first)),
530  std::forward_as_tuple(std::forward<Second>(value.second))).first;
531  }
532 
534  {
535  if (node.empty())
536  return { end(), false, node_type() };
537  typename TreeMap::InsertResult res = mTreeMap.Insert(
538  std::move(NodeTypeProxy::GetExtractedPair(node)));
539  return { IteratorProxy(res.position), res.inserted,
540  res.inserted ? node_type() : std::move(node) };
541  }
542 
544  {
545  if (node.empty())
546  return end();
547  std::pair<iterator, bool> res = pvFind(hint, node.key());
548  if (!res.second)
549  return res.first;
550  return IteratorProxy(mTreeMap.Add(IteratorProxy::GetBaseIterator(res.first),
551  std::move(NodeTypeProxy::GetExtractedPair(node))));
552  }
553 
554  template<typename Iterator>
555  void insert(Iterator first, Iterator last)
556  {
558  }
559 
560  void insert(std::initializer_list<value_type> values)
561  {
562  mTreeMap.Insert(values.begin(), values.end());
563  }
564 
565  std::pair<iterator, bool> emplace()
566  {
567  return ptEmplace(nullptr, std::tuple<>(), std::tuple<>());
568  }
569 
571  {
572  return ptEmplace(hint, std::tuple<>(), std::tuple<>()).first;
573  }
574 
575  template<typename ValueArg>
576  std::pair<iterator, bool> emplace(ValueArg&& valueArg)
577  {
578  return insert(std::forward<ValueArg>(valueArg));
579  }
580 
581  template<typename ValueArg>
582  iterator emplace_hint(const_iterator hint, ValueArg&& valueArg)
583  {
584  return insert(hint, std::forward<ValueArg>(valueArg));
585  }
586 
587  template<typename KeyArg, typename MappedArg>
588  std::pair<iterator, bool> emplace(KeyArg&& keyArg, MappedArg&& mappedArg)
589  {
590  return ptEmplace(nullptr, std::forward_as_tuple(std::forward<KeyArg>(keyArg)),
591  std::forward_as_tuple(std::forward<MappedArg>(mappedArg)));
592  }
593 
594  template<typename KeyArg, typename MappedArg>
595  iterator emplace_hint(const_iterator hint, KeyArg&& keyArg, MappedArg&& mappedArg)
596  {
597  return ptEmplace(hint, std::forward_as_tuple(std::forward<KeyArg>(keyArg)),
598  std::forward_as_tuple(std::forward<MappedArg>(mappedArg))).first;
599  }
600 
601  template<typename... KeyArgs, typename... MappedArgs>
602  std::pair<iterator, bool> emplace(std::piecewise_construct_t,
603  std::tuple<KeyArgs...> keyArgs, std::tuple<MappedArgs...> mappedArgs)
604  {
605  return ptEmplace(nullptr, std::move(keyArgs), std::move(mappedArgs));
606  }
607 
608  template<typename... KeyArgs, typename... MappedArgs>
609  iterator emplace_hint(const_iterator hint, std::piecewise_construct_t,
610  std::tuple<KeyArgs...> keyArgs, std::tuple<MappedArgs...> mappedArgs)
611  {
612  return ptEmplace(hint, std::move(keyArgs), std::move(mappedArgs)).first;
613  }
614 
616  {
617  return IteratorProxy(mTreeMap.Remove(ConstIteratorProxy::GetBaseIterator(where)));
618  }
619 
621  {
622  return erase(static_cast<const_iterator>(where));
623  }
624 
626  {
627  return IteratorProxy(mTreeMap.Remove(ConstIteratorProxy::GetBaseIterator(first),
628  ConstIteratorProxy::GetBaseIterator(last)));
629  }
630 
632  {
633  return mTreeMap.Remove(key);
634  }
635 
637  {
638  return node_type(*this, where); // need RVO for exception safety
639  }
640 
642  {
643  const_iterator iter = find(key);
644  return (iter != end()) ? extract(iter) : node_type();
645  }
646 
647  template<typename Map>
648  void merge(Map&& map)
649  {
650  mTreeMap.MergeFrom(map.get_nested_container());
651  }
652 
653  bool operator==(const map_base& right) const
654  {
655  return size() == right.size() && std::equal(begin(), end(), right.begin());
656  }
657 
658  bool operator!=(const map_base& right) const
659  {
660  return !(*this == right);
661  }
662 
663 #ifdef MOMO_HAS_THREE_WAY_COMPARISON
664  auto operator<=>(const map_base& right) const
665  requires requires (const_reference ref) { ref <=> ref; }
666  {
667  return std::lexicographical_compare_three_way(begin(), end(),
668  right.begin(), right.end());
669  }
670 #else
671  bool operator<(const map_base& right) const
672  {
673  return std::lexicographical_compare(begin(), end(), right.begin(), right.end());
674  }
675 
676  bool operator>(const map_base& right) const
677  {
678  return right < *this;
679  }
680 
681  bool operator<=(const map_base& right) const
682  {
683  return !(right < *this);
684  }
685 
686  bool operator>=(const map_base& right) const
687  {
688  return right <= *this;
689  }
690 #endif
691 
692  protected: //?
693  void ptAssign(std::initializer_list<value_type> values)
694  {
695  TreeMap treeMap(mTreeMap.GetTreeTraits(), MemManager(get_allocator()));
696  treeMap.Insert(values.begin(), values.end());
697  mTreeMap = std::move(treeMap);
698  }
699 
700  template<typename Hint, typename... KeyArgs, typename... MappedArgs>
701  std::pair<iterator, bool> ptEmplace(Hint hint, std::tuple<KeyArgs...>&& keyArgs,
702  std::tuple<MappedArgs...>&& mappedArgs)
703  {
704  typedef typename TreeMap::KeyValueTraits
705  ::template ValueCreator<MappedArgs...> MappedCreator;
706  return pvInsert(hint, std::move(keyArgs),
707  MappedCreator(mTreeMap.GetMemManager(), std::move(mappedArgs)));
708  }
709 
710  private:
711  static TreeMap pvCreateMap(map_base&& right, const allocator_type& alloc)
712  {
713  if (right.get_allocator() == alloc)
714  return std::move(right.mTreeMap);
715  TreeMap treeMap(right.mTreeMap.GetTreeTraits(), MemManager(alloc));
716  treeMap.MergeFrom(right.mTreeMap);
717  return treeMap;
718  }
719 
720  bool pvIsOrdered(const key_type& key1, const key_type& key2) const
721  {
722  const TreeTraits& treeTraits = mTreeMap.GetTreeTraits();
723  return TreeTraits::multiKey ? !treeTraits.IsLess(key2, key1)
724  : treeTraits.IsLess(key1, key2);
725  }
726 
727  std::pair<iterator, bool> pvFind(std::nullptr_t /*hint*/, const key_type& key)
728  {
729  iterator iter = upper_bound(key);
730  if (!TreeTraits::multiKey && iter != begin())
731  {
732  iterator prevIter = std::prev(iter);
733  if (!mTreeMap.GetTreeTraits().IsLess(prevIter->first, key))
734  return { prevIter, false };
735  }
736  return { iter, true };
737  }
738 
739  std::pair<iterator, bool> pvFind(const_iterator hint, const key_type& key)
740  {
741  if (hint != begin() && !pvIsOrdered(std::prev(hint)->first, key))
742  return pvFind(nullptr, key);
743  if (hint != end() && !pvIsOrdered(key, hint->first))
744  {
746  return { lower_bound(key), true };
747  else
748  return pvFind(nullptr, key);
749  }
750  return { IteratorProxy(mTreeMap.MakeMutableIterator(
751  ConstIteratorProxy::GetBaseIterator(hint))), true };
752  }
753 
754  template<typename Hint, typename... KeyArgs, typename MappedCreator>
755  std::pair<iterator, bool> pvInsert(Hint hint, std::tuple<KeyArgs...>&& keyArgs,
756  MappedCreator&& mappedCreator)
757  {
758  MemManager& memManager = mTreeMap.GetMemManager();
760  TreeMap::KeyValueTraits::keyAlignment> KeyBuffer;
762  typedef typename KeyManager::template Creator<KeyArgs...> KeyCreator;
763  KeyBuffer keyBuffer;
764  KeyCreator(memManager, std::move(keyArgs))(&keyBuffer);
765  bool keyDestroyed = false;
766  try
767  {
768  std::pair<iterator, bool> res = pvFind(hint, *&keyBuffer);
769  if (!res.second)
770  {
771  KeyManager::Destroy(memManager, *&keyBuffer);
772  keyDestroyed = true;
773  return res;
774  }
775  auto valueCreator = [&memManager, &keyBuffer, &mappedCreator, &keyDestroyed]
776  (key_type* newKey, mapped_type* newMapped)
777  {
778  KeyManager::Relocate(memManager, *&keyBuffer, newKey);
779  keyDestroyed = true;
780  try
781  {
782  std::forward<MappedCreator>(mappedCreator)(newMapped);
783  }
784  catch (...)
785  {
786  KeyManager::Destroy(memManager, *newKey);
787  throw;
788  }
789  };
790  TreeMapIterator resIter = mTreeMap.AddCrt(
791  IteratorProxy::GetBaseIterator(res.first), valueCreator);
792  return { IteratorProxy(resIter), true };
793  }
794  catch (...)
795  {
796  if (!keyDestroyed)
797  KeyManager::Destroy(memManager, *&keyBuffer);
798  throw;
799  }
800  }
801 
802  template<typename Hint, typename RKey, typename MappedCreator,
803  typename Key = typename std::decay<RKey>::type>
805  std::pair<iterator, bool>> pvInsert(Hint hint, std::tuple<RKey>&& key,
806  MappedCreator&& mappedCreator)
807  {
808  std::pair<iterator, bool> res = pvFind(hint,
809  static_cast<const key_type&>(std::get<0>(key)));
810  if (!res.second)
811  return res;
812  TreeMapIterator resIter = mTreeMap.AddCrt(IteratorProxy::GetBaseIterator(res.first),
813  std::forward<RKey>(std::get<0>(key)), std::forward<MappedCreator>(mappedCreator));
814  return { IteratorProxy(resIter), true };
815  }
816 
817  template<typename Iterator>
818  void pvInsert(Iterator first, Iterator last, std::true_type /*isMapArgIterator*/)
819  {
820  mTreeMap.Insert(first, last);
821  }
822 
823  template<typename Iterator>
824  void pvInsert(Iterator first, Iterator last, std::false_type /*isMapArgIterator*/)
825  {
826  for (Iterator iter = first; iter != last; ++iter)
827  insert(*iter);
828  }
829 
830  private:
831  TreeMap mTreeMap;
832  };
833 }
834 
863 template<typename TKey, typename TMapped,
864  typename TLessFunc = std::less<TKey>,
865  typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>,
866  typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>,
867  MemManagerStd<TAllocator>>>
868 class map : public internal::map_base<TKey, TMapped, TLessFunc, TAllocator, TTreeMap>
869 {
870 private:
872  typedef TTreeMap TreeMap;
873 
874 public:
875  using typename BaseMap::key_type;
876  using typename BaseMap::mapped_type;
877  using typename BaseMap::size_type;
878  using typename BaseMap::value_type;
879  using typename BaseMap::const_reference;
880  using typename BaseMap::const_iterator;
881  using typename BaseMap::iterator;
882 
883 public:
884  using BaseMap::BaseMap;
885 
886  map& operator=(std::initializer_list<value_type> values)
887  {
888  BaseMap::ptAssign(values);
889  return *this;
890  }
891 
892  friend void swap(map& left, map& right) noexcept
893  {
894  left.swap(right);
895  }
896 
898  {
899  return BaseMap::get_nested_container()[std::move(key)];
900  }
901 
903  {
904  return BaseMap::get_nested_container()[key];
905  }
906 
907  const mapped_type& at(const key_type& key) const
908  {
909  const_iterator iter = BaseMap::find(key);
910  if (iter == BaseMap::end())
911  throw std::out_of_range("invalid map key");
912  return iter->second;
913  }
914 
915  mapped_type& at(const key_type& key)
916  {
917  iterator iter = BaseMap::find(key);
918  if (iter == BaseMap::end())
919  throw std::out_of_range("invalid map key");
920  return iter->second;
921  }
922 
923  template<typename... MappedArgs>
924  std::pair<iterator, bool> try_emplace(key_type&& key, MappedArgs&&... mappedArgs)
925  {
926  return BaseMap::ptEmplace(nullptr, std::forward_as_tuple(std::move(key)),
927  std::forward_as_tuple(std::forward<MappedArgs>(mappedArgs)...));
928  }
929 
930  template<typename... MappedArgs>
931  iterator try_emplace(const_iterator hint, key_type&& key, MappedArgs&&... mappedArgs)
932  {
933  return BaseMap::ptEmplace(hint, std::forward_as_tuple(std::move(key)),
934  std::forward_as_tuple(std::forward<MappedArgs>(mappedArgs)...)).first;
935  }
936 
937  template<typename... MappedArgs>
938  std::pair<iterator, bool> try_emplace(const key_type& key, MappedArgs&&... mappedArgs)
939  {
940  return BaseMap::ptEmplace(nullptr, std::forward_as_tuple(key),
941  std::forward_as_tuple(std::forward<MappedArgs>(mappedArgs)...));
942  }
943 
944  template<typename... MappedArgs>
945  iterator try_emplace(const_iterator hint, const key_type& key, MappedArgs&&... mappedArgs)
946  {
947  return BaseMap::ptEmplace(hint, std::forward_as_tuple(key),
948  std::forward_as_tuple(std::forward<MappedArgs>(mappedArgs)...)).first;
949  }
950 
951  template<typename MappedArg>
952  std::pair<iterator, bool> insert_or_assign(key_type&& key, MappedArg&& mappedArg)
953  {
954  return pvInsertOrAssign(nullptr, std::move(key), std::forward<MappedArg>(mappedArg));
955  }
956 
957  template<typename MappedArg>
958  iterator insert_or_assign(const_iterator hint, key_type&& key, MappedArg&& mappedArg)
959  {
960  return pvInsertOrAssign(hint, std::move(key), std::forward<MappedArg>(mappedArg)).first;
961  }
962 
963  template<typename MappedArg>
964  std::pair<iterator, bool> insert_or_assign(const key_type& key, MappedArg&& mappedArg)
965  {
966  return pvInsertOrAssign(nullptr, key, std::forward<MappedArg>(mappedArg));
967  }
968 
969  template<typename MappedArg>
970  iterator insert_or_assign(const_iterator hint, const key_type& key, MappedArg&& mappedArg)
971  {
972  return pvInsertOrAssign(hint, key, std::forward<MappedArg>(mappedArg)).first;
973  }
974 
975  template<typename ValueFilter>
976  friend size_type erase_if(map& cont, const ValueFilter& valueFilter)
977  {
978  auto pairFilter = [&valueFilter] (const key_type& key, const mapped_type& mapped)
979  { return valueFilter(const_reference(key, mapped)); };
980  return cont.get_nested_container().Remove(pairFilter);
981  }
982 
983 private:
984  template<typename Hint, typename RKey, typename MappedArg>
985  std::pair<iterator, bool> pvInsertOrAssign(Hint hint, RKey&& key, MappedArg&& mappedArg)
986  {
987  std::pair<iterator, bool> res = BaseMap::ptEmplace(hint,
988  std::forward_as_tuple(std::forward<RKey>(key)),
989  std::forward_as_tuple(std::forward<MappedArg>(mappedArg)));
990  if (!res.second)
991  res.first->second = std::forward<MappedArg>(mappedArg);
992  return res;
993  }
994 };
995 
1004 template<typename TKey, typename TMapped,
1005  typename TLessFunc = std::less<TKey>,
1006  typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>,
1007  typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc, true>,
1008  MemManagerStd<TAllocator>>>
1009 class multimap : public internal::map_base<TKey, TMapped, TLessFunc, TAllocator, TTreeMap>
1010 {
1011 private:
1013 
1014 public:
1015  using typename BaseMap::key_type;
1016  using typename BaseMap::mapped_type;
1017  using typename BaseMap::size_type;
1018  using typename BaseMap::value_type;
1019  using typename BaseMap::iterator;
1020  using typename BaseMap::const_reference;
1021  using typename BaseMap::const_iterator;
1022  using typename BaseMap::node_type;
1023 
1025 
1026 public:
1027  using BaseMap::BaseMap;
1028 
1029  multimap& operator=(std::initializer_list<value_type> values)
1030  {
1031  BaseMap::ptAssign(values);
1032  return *this;
1033  }
1034 
1035  friend void swap(multimap& left, multimap& right) noexcept
1036  {
1037  left.swap(right);
1038  }
1039 
1040  //using BaseMap::insert; // gcc 5 & 6
1041 
1042  iterator insert(std::pair<key_type, mapped_type>&& value)
1043  {
1044  return BaseMap::insert(std::move(value)).first;
1045  }
1046 
1047  iterator insert(const_iterator hint, std::pair<key_type, mapped_type>&& value)
1048  {
1049  return BaseMap::insert(hint, std::move(value));
1050  }
1051 
1052  template<typename First, typename Second>
1054  && std::is_constructible<mapped_type, const Second&>::value,
1055  iterator> insert(const std::pair<First, Second>& value)
1056  {
1057  return BaseMap::insert(value).first;
1058  }
1059 
1060  template<typename First, typename Second>
1062  && std::is_constructible<mapped_type, const Second&>::value,
1063  iterator> insert(const_iterator hint, const std::pair<First, Second>& value)
1064  {
1065  return BaseMap::insert(hint, value);
1066  }
1067 
1068  template<typename First, typename Second>
1070  && std::is_constructible<mapped_type, Second&&>::value,
1071  iterator> insert(std::pair<First, Second>&& value)
1072  {
1073  return BaseMap::insert(std::move(value)).first;
1074  }
1075 
1076  template<typename First, typename Second>
1078  && std::is_constructible<mapped_type, Second&&>::value,
1079  iterator> insert(const_iterator hint, std::pair<First, Second>&& value)
1080  {
1081  return BaseMap::insert(hint, std::move(value));
1082  }
1083 
1085  {
1086  return BaseMap::insert(std::move(node)).position;
1087  }
1088 
1090  {
1091  return BaseMap::insert(hint, std::move(node));
1092  }
1093 
1094  template<typename Iterator>
1095  void insert(Iterator first, Iterator last)
1096  {
1097  BaseMap::insert(first, last);
1098  }
1099 
1100  void insert(std::initializer_list<value_type> values)
1101  {
1102  BaseMap::insert(values);
1103  }
1104 
1105  template<typename... ValueArgs>
1106  iterator emplace(ValueArgs&&... valueArgs)
1107  {
1108  return BaseMap::emplace(std::forward<ValueArgs>(valueArgs)...).first;
1109  }
1110 
1111  template<typename ValueFilter>
1112  friend size_type erase_if(multimap& cont, const ValueFilter& valueFilter)
1113  {
1114  auto pairFilter = [&valueFilter] (const key_type& key, const mapped_type& mapped)
1115  { return valueFilter(const_reference(key, mapped)); };
1116  return cont.get_nested_container().Remove(pairFilter);
1117  }
1118 };
1119 
1120 #ifdef MOMO_HAS_DEDUCTION_GUIDES
1121 
1122 #define MOMO_DECLARE_DEDUCTION_GUIDES(map) \
1123 template<typename Iterator, \
1124  typename Key = std::remove_const_t<typename std::iterator_traits<Iterator>::value_type::first_type>, \
1125  typename Mapped = typename std::iterator_traits<Iterator>::value_type::second_type, \
1126  typename Allocator = std::allocator<std::pair<const Key, Mapped>>, \
1127  typename = decltype(std::declval<Allocator&>().allocate(size_t{}))> \
1128 map(Iterator, Iterator, Allocator = Allocator()) \
1129  -> map<Key, Mapped, std::less<Key>, Allocator>; \
1130 template<typename Iterator, typename LessFunc, \
1131  typename Key = std::remove_const_t<typename std::iterator_traits<Iterator>::value_type::first_type>, \
1132  typename Mapped = typename std::iterator_traits<Iterator>::value_type::second_type, \
1133  typename Allocator = std::allocator<std::pair<const Key, Mapped>>, \
1134  typename = decltype(std::declval<LessFunc&>()(std::declval<const Key&>(), std::declval<const Key&>()))> \
1135 map(Iterator, Iterator, LessFunc, Allocator = Allocator()) \
1136  -> map<Key, Mapped, LessFunc, Allocator>; \
1137 template<typename Key, typename Mapped, \
1138  typename Allocator = std::allocator<std::pair<const Key, Mapped>>, \
1139  typename = decltype(std::declval<Allocator&>().allocate(size_t{}))> \
1140 map(std::initializer_list<std::pair<Key, Mapped>>, Allocator = Allocator()) \
1141  -> map<Key, Mapped, std::less<Key>, Allocator>; \
1142 template<typename Key, typename Mapped, typename LessFunc, \
1143  typename Allocator = std::allocator<std::pair<const Key, Mapped>>, \
1144  typename = decltype(std::declval<LessFunc&>()(std::declval<const Key&>(), std::declval<const Key&>()))> \
1145 map(std::initializer_list<std::pair<Key, Mapped>>, LessFunc, Allocator = Allocator()) \
1146  -> map<Key, Mapped, LessFunc, Allocator>;
1147 
1148 MOMO_DECLARE_DEDUCTION_GUIDES(map)
1149 MOMO_DECLARE_DEDUCTION_GUIDES(multimap)
1150 
1151 #undef MOMO_DECLARE_DEDUCTION_GUIDES
1152 
1153 #endif // MOMO_HAS_DEDUCTION_GUIDES
1154 
1155 } // namespace stdish
1156 
1157 } // namespace momo
1158 
1159 #endif // MOMO_INCLUDE_GUARD_STDISH_MAP
momo::stdish::internal::map_value_compare::LessFunc
TLessFunc LessFunc
Definition: map.h:36
momo::internal::ObjectManager
Definition: ObjectManager.h:196
momo::stdish::multimap::insert
momo::internal::EnableIf< std::is_constructible< key_type, const First & >::value &&std::is_constructible< mapped_type, const Second & >::value, iterator > insert(const std::pair< First, Second > &value)
Definition: map.h:1055
momo::TreeMap::ValueReferenceCKey
ValueReferencer::template ValueReference< const Key & > ValueReferenceCKey
Definition: TreeMap.h:272
momo::internal::InsertResult::position
Position position
Definition: IteratorUtility.h:183
momo::stdish::internal::map_base::operator==
bool operator==(const map_base &right) const
Definition: map.h:653
momo::stdish::internal::map_base::rbegin
reverse_iterator rbegin() noexcept
Definition: map.h:262
momo::stdish::internal::map_base::map_base
map_base()
Definition: map.h:130
momo::stdish::internal::map_base::count
size_type count(const key_type &key) const
Definition: map.h:363
momo::stdish::internal::map_value_compare::operator()
bool operator()(const Value &value1, const Value &value2) const
Definition: map.h:40
momo::stdish::internal::map_base::operator=
map_base & operator=(map_base &&right) noexcept(std::is_empty< allocator_type >::value||std::allocator_traits< allocator_type >::propagate_on_container_move_assignment::value)
Definition: map.h:194
momo::stdish::internal::map_base::reference
iterator::Reference reference
Definition: map.h:87
momo::stdish::map::size_type
size_t size_type
Definition: map.h:76
momo::stdish::internal::map_base::upper_bound
iterator upper_bound(const key_type &key)
Definition: map.h:416
momo::stdish::map::insert_or_assign
iterator insert_or_assign(const_iterator hint, key_type &&key, MappedArg &&mappedArg)
Definition: map.h:958
momo::stdish::map
momo::stdish::map is similar to std::map, but much more efficient in memory usage....
Definition: map.h:869
momo::stdish::internal::map_value_compare::map_value_compare
map_value_compare(const LessFunc &lessFunc)
Definition: map.h:48
momo::stdish::map::erase_if
friend size_type erase_if(map &cont, const ValueFilter &valueFilter)
Definition: map.h:976
momo::stdish::map::insert_or_assign
std::pair< iterator, bool > insert_or_assign(key_type &&key, MappedArg &&mappedArg)
Definition: map.h:952
momo::stdish::internal::map_base::map_base
map_base(Iterator first, Iterator last, const key_compare &lessFunc, const allocator_type &alloc=allocator_type())
Definition: map.h:152
momo::TreeTraits::IsLess
bool IsLess(const KeyArg1 &key1, const KeyArg2 &key2) const
Definition: TreeTraits.h:107
MOMO_STATIC_ASSERT
#define MOMO_STATIC_ASSERT(expr)
Definition: Utility.h:74
momo::stdish::internal::map_base::contains
bool contains(const key_type &key) const
Definition: map.h:375
momo::stdish::internal::map_base::value_compare
map_value_compare< key_type, key_compare > value_compare
Definition: map.h:81
momo::stdish::internal::map_base::find
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, const_iterator > find(const KeyArg &key) const
Definition: map.h:351
momo::stdish::internal::map_base::crend
const_reverse_iterator crend() const noexcept
Definition: map.h:292
momo::stdish::internal::map_base::map_base
map_base(const key_compare &lessFunc, const allocator_type &alloc=allocator_type())
Definition: map.h:139
momo::internal::IsMapArgIteratorStd
Definition: MapUtility.h:1004
momo::stdish::internal::map_base::key_type
TKey key_type
Definition: map.h:69
momo::stdish::multimap::emplace
iterator emplace(ValueArgs &&... valueArgs)
Definition: map.h:1106
momo::stdish::internal::map_base::map_base
map_base(const allocator_type &alloc)
Definition: map.h:134
momo::stdish::internal::map_base::upper_bound
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, iterator > upper_bound(const KeyArg &key)
Definition: map.h:430
momo::stdish::internal::map_base::get_nested_container
nested_container_type & get_nested_container() noexcept
Definition: map.h:232
momo::stdish::internal::map_base::difference_type
ptrdiff_t difference_type
Definition: map.h:77
momo::stdish::multimap::insert_return_type
iterator insert_return_type
Definition: map.h:1024
momo::stdish::internal::map_base::ptAssign
void ptAssign(std::initializer_list< value_type > values)
Definition: map.h:693
momo::stdish::internal::map_base::insert
iterator insert(const_iterator hint, node_type &&node)
Definition: map.h:543
momo::stdish::internal::insert_return_type
Definition: node_handle.h:190
momo::stdish::internal::map_base::count
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, size_type > count(const KeyArg &key) const
Definition: map.h:370
momo::stdish::internal::map_base::emplace_hint
iterator emplace_hint(const_iterator hint, ValueArg &&valueArg)
Definition: map.h:582
momo::stdish::internal::map_base::nested_container_type
TreeMap nested_container_type
Definition: map.h:74
momo::stdish::internal::map_base::merge
void merge(Map &&map)
Definition: map.h:648
momo::stdish::internal::map_base::lower_bound
iterator lower_bound(const key_type &key)
Definition: map.h:392
momo::stdish::internal::map_base::insert
std::pair< iterator, bool > insert(std::pair< key_type, mapped_type > &&value)
Definition: map.h:485
momo::stdish::internal::map_base::map_base
map_base(const map_base &right, const momo::internal::Identity< allocator_type > &alloc)
Definition: map.h:187
momo::TreeMap::MemManager
TMemManager MemManager
Definition: TreeMap.h:243
momo::stdish::internal::map_base::iterator
momo::internal::TreeDerivedIterator< TreeMapIterator, momo::internal::MapReferenceStd > iterator
Definition: map.h:84
momo::stdish::internal::map_base::ptEmplace
std::pair< iterator, bool > ptEmplace(Hint hint, std::tuple< KeyArgs... > &&keyArgs, std::tuple< MappedArgs... > &&mappedArgs)
Definition: map.h:701
momo::stdish::internal::map_base::rbegin
const_reverse_iterator rbegin() const noexcept
Definition: map.h:257
momo::internal::TreeDerivedIterator::BaseIterator
TBaseIterator BaseIterator
Definition: IteratorUtility.h:462
momo::internal::TreeMapIterator
Definition: TreeMap.h:33
momo::stdish::internal::map_base::max_size
size_type max_size() const noexcept
Definition: map.h:319
momo::stdish::internal::map_base::map_base
map_base(std::initializer_list< value_type > values, const key_compare &lessFunc, const allocator_type &alloc=allocator_type())
Definition: map.h:165
momo::TreeTraits
Definition: TreeTraits.h:82
momo::stdish::map::operator[]
TreeMap::ValueReferenceRKey operator[](key_type &&key)
Definition: map.h:897
momo::stdish::internal::map_base::insert
void insert(Iterator first, Iterator last)
Definition: map.h:555
momo::stdish::internal::map_base::find
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, iterator > find(const KeyArg &key)
Definition: map.h:358
momo::stdish::multimap::insert
void insert(std::initializer_list< value_type > values)
Definition: map.h:1100
momo::internal::InsertResult
Definition: IteratorUtility.h:151
momo::stdish::internal::map_node_handle::MapExtractedPair
TMapExtractedPair MapExtractedPair
Definition: node_handle.h:101
momo::stdish::map::operator[]
TreeMap::ValueReferenceCKey operator[](const key_type &key)
Definition: map.h:902
momo::stdish::internal::map_base::rend
const_reverse_iterator rend() const noexcept
Definition: map.h:267
momo::stdish::internal::map_base::find
const_iterator find(const key_type &key) const
Definition: map.h:339
momo::TreeMap::ValueReferenceRKey
ValueReferencer::template ValueReference< Key && > ValueReferenceRKey
Definition: TreeMap.h:271
momo::stdish::internal::map_base::operator<=
bool operator<=(const map_base &right) const
Definition: map.h:681
momo::stdish::internal::map_node_handle
Definition: node_handle.h:99
momo::stdish::internal::map_base::emplace
std::pair< iterator, bool > emplace()
Definition: map.h:565
momo::stdish::internal::map_base::operator>=
bool operator>=(const map_base &right) const
Definition: map.h:686
momo::stdish::internal::map_base::extract
node_type extract(const_iterator where)
Definition: map.h:636
momo::stdish::multimap
momo::stdish::multimap is similar to std::multimap, but much more efficient in memory usage....
Definition: map.h:1010
momo::stdish::multimap::size_type
size_t size_type
Definition: map.h:76
momo::internal::EnableIf
typename std::enable_if< value, Type >::type EnableIf
Definition: Utility.h:174
momo::stdish::map::key_type
TKey key_type
Definition: map.h:69
momo::stdish::internal::map_base::emplace_hint
iterator emplace_hint(const_iterator hint, KeyArg &&keyArg, MappedArg &&mappedArg)
Definition: map.h:595
momo::stdish::internal::map_base::upper_bound
const_iterator upper_bound(const key_type &key) const
Definition: map.h:411
momo
Definition: Array.h:26
momo::stdish::internal::map_base::rend
reverse_iterator rend() noexcept
Definition: map.h:272
momo::stdish::internal::map_value_compare::Key
TKey Key
Definition: map.h:35
momo::stdish::internal::map_base::equal_range
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, std::pair< const_iterator, const_iterator > > equal_range(const KeyArg &key) const
Definition: map.h:457
momo::stdish::internal::map_base::value_type
std::pair< const key_type, mapped_type > value_type
Definition: map.h:79
momo::stdish::internal::map_base::map_base
map_base(map_base &&right) noexcept
Definition: map.h:171
momo::stdish::internal::map_base::key_comp
key_compare key_comp() const
Definition: map.h:297
momo::stdish::multimap::insert
void insert(Iterator first, Iterator last)
Definition: map.h:1095
momo::stdish::internal::map_base::map_base
map_base(map_base &&right, const momo::internal::Identity< allocator_type > &alloc) noexcept(std::is_empty< allocator_type >::value)
Definition: map.h:176
momo::internal::IteratorPointer
Definition: IteratorUtility.h:279
momo::stdish::internal::map_base::allocator_type
TAllocator allocator_type
Definition: map.h:72
momo::internal::InsertResult::inserted
bool inserted
Definition: IteratorUtility.h:186
momo::internal::Identity
EnableIf< true, Type > Identity
Definition: Utility.h:177
momo::stdish::multimap::insert
iterator insert(const_iterator hint, std::pair< key_type, mapped_type > &&value)
Definition: map.h:1047
momo::stdish::internal::map_base::const_reverse_iterator
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: map.h:96
momo::stdish::internal::map_base
Definition: map.h:60
momo::stdish::internal::map_base::operator=
map_base & operator=(const map_base &right)
Definition: map.h:208
momo::stdish::internal::map_base::operator>
bool operator>(const map_base &right) const
Definition: map.h:676
momo::stdish::internal::map_base::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: map.h:527
momo::stdish::internal::map_base::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: map.h:509
momo::stdish::map::try_emplace
std::pair< iterator, bool > try_emplace(const key_type &key, MappedArgs &&... mappedArgs)
Definition: map.h:938
momo::stdish::internal::map_base::emplace_hint
iterator emplace_hint(const_iterator hint, std::piecewise_construct_t, std::tuple< KeyArgs... > keyArgs, std::tuple< MappedArgs... > mappedArgs)
Definition: map.h:609
momo::stdish::multimap::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: map.h:1079
momo::stdish::map::try_emplace
iterator try_emplace(const_iterator hint, const key_type &key, MappedArgs &&... mappedArgs)
Definition: map.h:945
momo::stdish::internal::map_base::emplace
std::pair< iterator, bool > emplace(ValueArg &&valueArg)
Definition: map.h:576
momo::stdish::multimap::mapped_type
TMapped mapped_type
Definition: map.h:70
momo::stdish::internal::map_base::erase
iterator erase(const_iterator where)
Definition: map.h:615
momo::stdish::internal::map_base::end
const_iterator end() const noexcept
Definition: map.h:247
momo::stdish::internal::map_base::get_nested_container
const nested_container_type & get_nested_container() const noexcept
Definition: map.h:227
MOMO_DECLARE_PROXY_CONSTRUCTOR
#define MOMO_DECLARE_PROXY_CONSTRUCTOR(Object)
Definition: Utility.h:85
momo::stdish::multimap::operator=
multimap & operator=(std::initializer_list< value_type > values)
Definition: map.h:1029
momo::stdish::internal::map_base::lower_bound
const_iterator lower_bound(const key_type &key) const
Definition: map.h:387
momo::stdish::internal::map_base::~map_base
~map_base()=default
momo::stdish::internal::map_base::map_base
map_base(const map_base &right)
Definition: map.h:182
momo::stdish::multimap::insert
iterator insert(node_type &&node)
Definition: map.h:1084
momo::stdish::internal::map_base::equal_range
std::pair< const_iterator, const_iterator > equal_range(const key_type &key) const
Definition: map.h:435
momo::stdish::internal::map_base::node_type
internal::map_node_handle< typename TreeMap::ExtractedPair > node_type
Definition: map.h:98
momo::stdish::multimap::insert
iterator insert(std::pair< key_type, mapped_type > &&value)
Definition: map.h:1042
momo::stdish::multimap::insert
iterator insert(const_iterator hint, node_type &&node)
Definition: map.h:1089
momo::stdish::internal::map_base::const_iterator
iterator::ConstIterator const_iterator
Definition: map.h:85
momo::stdish::multimap::erase_if
friend size_type erase_if(multimap &cont, const ValueFilter &valueFilter)
Definition: map.h:1112
momo::stdish::map::at
const mapped_type & at(const key_type &key) const
Definition: map.h:907
momo::stdish::internal::map_base::upper_bound
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, const_iterator > upper_bound(const KeyArg &key) const
Definition: map.h:423
momo::stdish::internal::map_base::emplace_hint
iterator emplace_hint(const_iterator hint)
Definition: map.h:570
momo::stdish::internal::map_base::insert_return_type
internal::insert_return_type< iterator, node_type > insert_return_type
Definition: map.h:99
momo::stdish::internal::map_base::get_allocator
allocator_type get_allocator() const noexcept
Definition: map.h:314
momo::internal::TreeDerivedIterator
Definition: IteratorUtility.h:460
momo::stdish::internal::map_base::key_compare
TLessFunc key_compare
Definition: map.h:71
momo::stdish::internal::map_base::map_base
map_base(Iterator first, Iterator last, const allocator_type &alloc=allocator_type())
Definition: map.h:145
momo::internal::ObjectBuffer
Definition: ObjectManager.h:161
std
Definition: ArrayUtility.h:299
momo::stdish::internal::map_base::insert
void insert(std::initializer_list< value_type > values)
Definition: map.h:560
momo::stdish::internal::map_base::clear
void clear() noexcept
Definition: map.h:334
momo::stdish::internal::map_base::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: map.h:518
momo::stdish::internal::map_base::emplace
std::pair< iterator, bool > emplace(std::piecewise_construct_t, std::tuple< KeyArgs... > keyArgs, std::tuple< MappedArgs... > mappedArgs)
Definition: map.h:602
momo::stdish::internal::map_base::value_comp
value_compare value_comp() const
Definition: map.h:302
momo::stdish::internal::map_base::cend
const_iterator cend() const noexcept
Definition: map.h:282
momo::stdish::map::insert_or_assign
std::pair< iterator, bool > insert_or_assign(const key_type &key, MappedArg &&mappedArg)
Definition: map.h:964
momo::stdish::map::operator=
map & operator=(std::initializer_list< value_type > values)
Definition: map.h:886
momo::stdish::internal::map_value_compare::comp
LessFunc comp
Definition: map.h:54
momo::stdish::map::try_emplace
iterator try_emplace(const_iterator hint, key_type &&key, MappedArgs &&... mappedArgs)
Definition: map.h:931
momo::stdish::internal::map_base::equal_range
std::pair< iterator, iterator > equal_range(const key_type &key)
Definition: map.h:445
momo::stdish::internal::map_base::empty
MOMO_NODISCARD bool empty() const noexcept
Definition: map.h:329
momo::TreeMap
Definition: TreeMap.h:238
momo::stdish::internal::map_base::const_pointer
const_iterator::Pointer const_pointer
Definition: map.h:91
momo::stdish::internal::map_base::size
size_type size() const noexcept
Definition: map.h:324
momo::stdish::internal::map_base::erase
iterator erase(iterator where)
Definition: map.h:620
momo::stdish::internal::map_base::begin
iterator begin() noexcept
Definition: map.h:242
momo::stdish::internal::map_base::erase
iterator erase(const_iterator first, const_iterator last)
Definition: map.h:625
momo::stdish::internal::map_base::operator!=
bool operator!=(const map_base &right) const
Definition: map.h:658
momo::stdish::map::swap
friend void swap(map &left, map &right) noexcept
Definition: map.h:892
momo::stdish::internal::map_base::operator<
bool operator<(const map_base &right) const
Definition: map.h:671
momo::internal::TreeDerivedIterator::Reference
TReference< typename BaseIterator::Reference > Reference
Definition: IteratorUtility.h:465
momo::stdish::internal::map_value_compare
Definition: map.h:33
momo::stdish::internal::map_base::swap
void swap(map_base &right) noexcept
Definition: map.h:220
momo::stdish::multimap::insert
momo::internal::EnableIf< std::is_constructible< key_type, First && >::value &&std::is_constructible< mapped_type, Second && >::value, iterator > insert(std::pair< First, Second > &&value)
Definition: map.h:1071
momo::stdish::multimap::swap
friend void swap(multimap &left, multimap &right) noexcept
Definition: map.h:1035
momo::stdish::internal::map_base::insert
iterator insert(const_iterator hint, std::pair< key_type, mapped_type > &&value)
Definition: map.h:491
momo::stdish::map::insert_or_assign
iterator insert_or_assign(const_iterator hint, const key_type &key, MappedArg &&mappedArg)
Definition: map.h:970
momo::stdish::internal::map_base::extract
node_type extract(const key_type &key)
Definition: map.h:641
momo::stdish::multimap::const_reference
const_iterator::Reference const_reference
Definition: map.h:88
momo::stdish::internal::map_base::reverse_iterator
std::reverse_iterator< iterator > reverse_iterator
Definition: map.h:95
momo::stdish::internal::map_base::mapped_type
TMapped mapped_type
Definition: map.h:70
momo::stdish::internal::map_base::const_reference
const_iterator::Reference const_reference
Definition: map.h:88
momo::stdish::internal::map_base::pointer
iterator::Pointer pointer
Definition: map.h:90
momo::stdish::internal::map_base::lower_bound
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, const_iterator > lower_bound(const KeyArg &key) const
Definition: map.h:399
momo::stdish::internal::map_base::crbegin
const_reverse_iterator crbegin() const noexcept
Definition: map.h:287
momo::stdish::internal::map_base::emplace
std::pair< iterator, bool > emplace(KeyArg &&keyArg, MappedArg &&mappedArg)
Definition: map.h:588
momo::stdish::internal::map_base::map_base
map_base(std::initializer_list< value_type > values, const allocator_type &alloc=allocator_type())
Definition: map.h:159
momo::stdish::internal::map_base::begin
const_iterator begin() const noexcept
Definition: map.h:237
momo::TreeMap::TreeTraits
TTreeTraits TreeTraits
Definition: TreeMap.h:242
momo::stdish::map::at
mapped_type & at(const key_type &key)
Definition: map.h:915
momo::TreeTraits::multiKey
static const bool multiKey
Definition: TreeTraits.h:87
node_handle.h
MOMO_ASSERT
#define MOMO_ASSERT(expr)
Definition: UserSettings.h:162
momo::stdish::internal::map_base::lower_bound
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, iterator > lower_bound(const KeyArg &key)
Definition: map.h:406
MOMO_DECLARE_PROXY_FUNCTION
#define MOMO_DECLARE_PROXY_FUNCTION(Object, Func, Result)
Definition: Utility.h:94
momo::stdish::internal::map_base::end
iterator end() noexcept
Definition: map.h:252
momo::stdish::multimap::key_type
TKey key_type
Definition: map.h:69
momo::stdish::internal::map_base::erase
size_type erase(const key_type &key)
Definition: map.h:631
momo::stdish::internal::map_base::equal_range
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, std::pair< iterator, iterator > > equal_range(const KeyArg &key)
Definition: map.h:464
momo::stdish::internal::map_base::size_type
size_t size_type
Definition: map.h:76
momo::stdish::map::try_emplace
std::pair< iterator, bool > try_emplace(key_type &&key, MappedArgs &&... mappedArgs)
Definition: map.h:924
momo::stdish::internal::map_base::insert
insert_return_type insert(node_type &&node)
Definition: map.h:533
MOMO_NODISCARD
#define MOMO_NODISCARD
Definition: UserSettings.h:192
momo::stdish::map::const_reference
const_iterator::Reference const_reference
Definition: map.h:88
momo::stdish::internal::map_base::contains
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, bool > contains(const KeyArg &key) const
Definition: map.h:382
momo::stdish::multimap::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: map.h:1063
momo::stdish::map::mapped_type
TMapped mapped_type
Definition: map.h:70
momo::stdish::internal::map_base::find
iterator find(const key_type &key)
Definition: map.h:344
momo::internal::MapReferenceStd
Definition: MapUtility.h:68
momo::stdish::internal::map_base::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: map.h:500
momo::stdish::internal::map_base::cbegin
const_iterator cbegin() const noexcept
Definition: map.h:277