momo  3.10
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 "set_map_utility.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<momo::internal::Identity<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<momo::internal::Identity<value_type>> values,
166  const key_compare& lessFunc, const allocator_type& alloc = allocator_type())
167  : map_base(values.begin(), values.end(), lessFunc, alloc)
168  {
169  }
170 
171 #ifdef MOMO_HAS_CONTAINERS_RANGES
172  template<std::ranges::input_range Range>
173  requires std::convertible_to<std::ranges::range_reference_t<Range>, value_type>
174  map_base(std::from_range_t, Range&& values, const allocator_type& alloc = allocator_type())
175  : map_base(alloc)
176  {
177  insert_range(std::forward<Range>(values));
178  }
179 
180  template<std::ranges::input_range Range>
181  requires std::convertible_to<std::ranges::range_reference_t<Range>, value_type>
182  map_base(std::from_range_t, Range&& values, const key_compare& lessFunc,
183  const allocator_type& alloc = allocator_type())
184  : map_base(lessFunc, alloc)
185  {
186  insert_range(std::forward<Range>(values));
187  }
188 #endif // MOMO_HAS_CONTAINERS_RANGES
189 
190  map_base(map_base&& right) noexcept
191  : mTreeMap(std::move(right.mTreeMap))
192  {
193  }
194 
196  noexcept(std::is_empty<allocator_type>::value)
197  : mTreeMap(pvCreateMap(std::move(right), alloc))
198  {
199  }
200 
201  map_base(const map_base& right)
202  : mTreeMap(right.mTreeMap)
203  {
204  }
205 
207  : mTreeMap(right.mTreeMap, MemManager(alloc))
208  {
209  }
210 
211  ~map_base() = default;
212 
214  noexcept(std::is_empty<allocator_type>::value ||
215  std::allocator_traits<allocator_type>::propagate_on_container_move_assignment::value)
216  {
217  if (this != &right)
218  {
219  bool propagate = std::is_empty<allocator_type>::value ||
220  std::allocator_traits<allocator_type>::propagate_on_container_move_assignment::value;
221  allocator_type alloc = (propagate ? &right : this)->get_allocator();
222  mTreeMap = pvCreateMap(std::move(right), alloc);
223  }
224  return *this;
225  }
226 
227  map_base& operator=(const map_base& right)
228  {
229  if (this != &right)
230  {
231  bool propagate = std::is_empty<allocator_type>::value ||
232  std::allocator_traits<allocator_type>::propagate_on_container_copy_assignment::value;
233  allocator_type alloc = (propagate ? &right : this)->get_allocator();
234  mTreeMap = TreeMap(right.mTreeMap, MemManager(alloc));
235  }
236  return *this;
237  }
238 
239  void swap(map_base& right) noexcept
240  {
241  MOMO_ASSERT(std::allocator_traits<allocator_type>::propagate_on_container_swap::value
242  || get_allocator() == right.get_allocator());
243  mTreeMap.Swap(right.mTreeMap);
244  }
245 
247  {
248  return mTreeMap;
249  }
250 
252  {
253  return mTreeMap;
254  }
255 
256  const_iterator begin() const noexcept
257  {
258  return ConstIteratorProxy(mTreeMap.GetBegin());
259  }
260 
261  iterator begin() noexcept
262  {
263  return IteratorProxy(mTreeMap.GetBegin());
264  }
265 
266  const_iterator end() const noexcept
267  {
268  return ConstIteratorProxy(mTreeMap.GetEnd());
269  }
270 
271  iterator end() noexcept
272  {
273  return IteratorProxy(mTreeMap.GetEnd());
274  }
275 
277  {
278  return const_reverse_iterator(end());
279  }
280 
282  {
283  return reverse_iterator(end());
284  }
285 
286  const_reverse_iterator rend() const noexcept
287  {
288  return const_reverse_iterator(begin());
289  }
290 
292  {
293  return reverse_iterator(begin());
294  }
295 
296  const_iterator cbegin() const noexcept
297  {
298  return begin();
299  }
300 
301  const_iterator cend() const noexcept
302  {
303  return end();
304  }
305 
307  {
308  return rbegin();
309  }
310 
311  const_reverse_iterator crend() const noexcept
312  {
313  return rend();
314  }
315 
317  {
318  return mTreeMap.GetTreeTraits().GetLessFunc();
319  }
320 
322  {
323  struct ValueCompareProxy : public value_compare
324  {
325  explicit ValueCompareProxy(const key_compare& keyComp)
326  : value_compare(keyComp)
327  {
328  }
329  };
330  return ValueCompareProxy(key_comp());
331  }
332 
333  allocator_type get_allocator() const noexcept
334  {
335  return allocator_type(mTreeMap.GetMemManager().GetByteAllocator());
336  }
337 
338  size_type max_size() const noexcept
339  {
340  return std::allocator_traits<allocator_type>::max_size(get_allocator());
341  }
342 
343  size_type size() const noexcept
344  {
345  return mTreeMap.GetCount();
346  }
347 
348  MOMO_NODISCARD bool empty() const noexcept
349  {
350  return mTreeMap.IsEmpty();
351  }
352 
353  void clear() noexcept
354  {
355  mTreeMap.Clear();
356  }
357 
358  const_iterator find(const key_type& key) const
359  {
360  return ConstIteratorProxy(mTreeMap.Find(key));
361  }
362 
363  iterator find(const key_type& key)
364  {
365  return IteratorProxy(mTreeMap.Find(key));
366  }
367 
368  template<typename KeyArg>
370  const_iterator> find(const KeyArg& key) const
371  {
372  return ConstIteratorProxy(mTreeMap.Find(key));
373  }
374 
375  template<typename KeyArg>
377  iterator> find(const KeyArg& key)
378  {
379  return IteratorProxy(mTreeMap.Find(key));
380  }
381 
382  size_type count(const key_type& key) const
383  {
384  return mTreeMap.GetKeyCount(key);
385  }
386 
387  template<typename KeyArg>
389  size_type> count(const KeyArg& key) const
390  {
391  return mTreeMap.GetKeyCount(key);
392  }
393 
394  bool contains(const key_type& key) const
395  {
396  return mTreeMap.ContainsKey(key);
397  }
398 
399  template<typename KeyArg>
401  bool> contains(const KeyArg& key) const
402  {
403  return mTreeMap.ContainsKey(key);
404  }
405 
407  {
408  return ConstIteratorProxy(mTreeMap.GetLowerBound(key));
409  }
410 
412  {
413  return IteratorProxy(mTreeMap.GetLowerBound(key));
414  }
415 
416  template<typename KeyArg>
418  const_iterator> lower_bound(const KeyArg& key) const
419  {
420  return ConstIteratorProxy(mTreeMap.GetLowerBound(key));
421  }
422 
423  template<typename KeyArg>
425  iterator> lower_bound(const KeyArg& key)
426  {
427  return IteratorProxy(mTreeMap.GetLowerBound(key));
428  }
429 
431  {
432  return ConstIteratorProxy(mTreeMap.GetUpperBound(key));
433  }
434 
436  {
437  return IteratorProxy(mTreeMap.GetUpperBound(key));
438  }
439 
440  template<typename KeyArg>
442  const_iterator> upper_bound(const KeyArg& key) const
443  {
444  return ConstIteratorProxy(mTreeMap.GetUpperBound(key));
445  }
446 
447  template<typename KeyArg>
449  iterator> upper_bound(const KeyArg& key)
450  {
451  return IteratorProxy(mTreeMap.GetUpperBound(key));
452  }
453 
454  std::pair<const_iterator, const_iterator> equal_range(const key_type& key) const
455  {
456  const_iterator iter = lower_bound(key);
458  return { iter, upper_bound(key) };
459  if (iter == end() || mTreeMap.GetTreeTraits().IsLess(key, iter->first))
460  return { iter, iter };
461  return { iter, std::next(iter) };
462  }
463 
464  std::pair<iterator, iterator> equal_range(const key_type& key)
465  {
466  iterator iter = lower_bound(key);
468  return { iter, upper_bound(key) };
469  if (iter == end() || mTreeMap.GetTreeTraits().IsLess(key, iter->first))
470  return { iter, iter };
471  return { iter, std::next(iter) };
472  }
473 
474  template<typename KeyArg>
476  std::pair<const_iterator, const_iterator>> equal_range(const KeyArg& key) const
477  {
478  return { lower_bound(key), upper_bound(key) };
479  }
480 
481  template<typename KeyArg>
483  std::pair<iterator, iterator>> equal_range(const KeyArg& key)
484  {
485  return { lower_bound(key), upper_bound(key) };
486  }
487 
488  template<typename ValueArg = std::pair<key_type, mapped_type>>
490  std::pair<iterator, bool>> insert(ValueArg&& valueArg)
491  {
492  return emplace(std::forward<ValueArg>(valueArg));
493  }
494 
495  template<typename ValueArg = std::pair<key_type, mapped_type>>
497  iterator> insert(const_iterator hint, ValueArg&& valueArg)
498  {
499  return emplace_hint(hint, std::forward<ValueArg>(valueArg));
500  }
501 
503  {
504  if (node.empty())
505  return { end(), false, node_type() };
506  typename TreeMap::InsertResult res = mTreeMap.Insert(
507  std::move(NodeTypeProxy::GetExtractedPair(node)));
508  return { IteratorProxy(res.position), res.inserted,
509  res.inserted ? node_type() : std::move(node) };
510  }
511 
513  {
514  if (node.empty())
515  return end();
516  std::pair<iterator, bool> res = pvFind(hint, node.key());
517  if (!res.second)
518  return res.first;
519  return IteratorProxy(mTreeMap.Add(IteratorProxy::GetBaseIterator(res.first),
520  std::move(NodeTypeProxy::GetExtractedPair(node))));
521  }
522 
523  template<typename Iterator>
524  void insert(Iterator first, Iterator last)
525  {
526  pvInsertRange(first, last);
527  }
528 
529  void insert(std::initializer_list<value_type> values)
530  {
531  mTreeMap.Insert(values.begin(), values.end());
532  }
533 
534 #ifdef MOMO_HAS_CONTAINERS_RANGES
535  template<std::ranges::input_range Range>
536  requires std::convertible_to<std::ranges::range_reference_t<Range>, value_type>
537  void insert_range(Range&& values)
538  {
539  pvInsertRange(std::ranges::begin(values), std::ranges::end(values));
540  }
541 #endif // MOMO_HAS_CONTAINERS_RANGES
542 
543  std::pair<iterator, bool> emplace()
544  {
545  return ptEmplace(nullptr, std::tuple<>(), std::tuple<>());
546  }
547 
549  {
550  return ptEmplace(hint, std::tuple<>(), std::tuple<>()).first;
551  }
552 
553  template<typename ValueArg>
554  std::pair<iterator, bool> emplace(ValueArg&& valueArg)
555  {
556  return ptEmplace(nullptr,
557  std::forward_as_tuple(std::get<0>(std::forward<ValueArg>(valueArg))),
558  std::forward_as_tuple(std::get<1>(std::forward<ValueArg>(valueArg))));
559  }
560 
561  template<typename ValueArg>
562  iterator emplace_hint(const_iterator hint, ValueArg&& valueArg)
563  {
564  return ptEmplace(hint,
565  std::forward_as_tuple(std::get<0>(std::forward<ValueArg>(valueArg))),
566  std::forward_as_tuple(std::get<1>(std::forward<ValueArg>(valueArg)))).first;
567  }
568 
569  template<typename KeyArg, typename MappedArg>
570  std::pair<iterator, bool> emplace(KeyArg&& keyArg, MappedArg&& mappedArg)
571  {
572  return ptEmplace(nullptr, std::forward_as_tuple(std::forward<KeyArg>(keyArg)),
573  std::forward_as_tuple(std::forward<MappedArg>(mappedArg)));
574  }
575 
576  template<typename KeyArg, typename MappedArg>
577  iterator emplace_hint(const_iterator hint, KeyArg&& keyArg, MappedArg&& mappedArg)
578  {
579  return ptEmplace(hint, std::forward_as_tuple(std::forward<KeyArg>(keyArg)),
580  std::forward_as_tuple(std::forward<MappedArg>(mappedArg))).first;
581  }
582 
583  template<typename... KeyArgs, typename... MappedArgs>
584  std::pair<iterator, bool> emplace(std::piecewise_construct_t,
585  std::tuple<KeyArgs...> keyArgs, std::tuple<MappedArgs...> mappedArgs)
586  {
587  return ptEmplace(nullptr, std::move(keyArgs), std::move(mappedArgs));
588  }
589 
590  template<typename... KeyArgs, typename... MappedArgs>
591  iterator emplace_hint(const_iterator hint, std::piecewise_construct_t,
592  std::tuple<KeyArgs...> keyArgs, std::tuple<MappedArgs...> mappedArgs)
593  {
594  return ptEmplace(hint, std::move(keyArgs), std::move(mappedArgs)).first;
595  }
596 
598  {
599  return IteratorProxy(mTreeMap.Remove(ConstIteratorProxy::GetBaseIterator(where)));
600  }
601 
603  {
604  return erase(static_cast<const_iterator>(where));
605  }
606 
608  {
609  return IteratorProxy(mTreeMap.Remove(ConstIteratorProxy::GetBaseIterator(first),
610  ConstIteratorProxy::GetBaseIterator(last)));
611  }
612 
614  {
615  return mTreeMap.Remove(key);
616  }
617 
619  {
620  return node_type(*this, where); // need RVO for exception safety
621  }
622 
624  {
625  const_iterator iter = find(key);
626  return (iter != end()) ? extract(iter) : node_type();
627  }
628 
629  template<typename Map>
630  void merge(Map&& map)
631  {
632  mTreeMap.MergeFrom(map.get_nested_container());
633  }
634 
635  friend bool operator==(const map_base& left, const map_base& right)
636  {
637  return left.size() == right.size()
638  && std::equal(left.begin(), left.end(), right.begin());
639  }
640 
641 #ifdef MOMO_HAS_THREE_WAY_COMPARISON
642  friend auto operator<=>(const map_base& left, const map_base& right)
643  requires requires (const_reference ref) { ref <=> ref; }
644  {
645  return std::lexicographical_compare_three_way(left.begin(), left.end(),
646  right.begin(), right.end());
647  }
648 #else
649  friend bool operator<(const map_base& left, const map_base& right)
650  {
651  return std::lexicographical_compare(left.begin(), left.end(),
652  right.begin(), right.end());
653  }
654 #endif
655 
657 
658  protected: //?
659  void ptAssign(std::initializer_list<value_type> values)
660  {
661  TreeMap treeMap(mTreeMap.GetTreeTraits(), MemManager(get_allocator()));
662  treeMap.Insert(values.begin(), values.end());
663  mTreeMap = std::move(treeMap);
664  }
665 
666  template<typename Hint, typename... KeyArgs, typename... MappedArgs>
667  std::pair<iterator, bool> ptEmplace(Hint hint, std::tuple<KeyArgs...>&& keyArgs,
668  std::tuple<MappedArgs...>&& mappedArgs)
669  {
670  typedef typename TreeMap::KeyValueTraits
671  ::template ValueCreator<MappedArgs...> MappedCreator;
672  return pvInsert(hint, std::move(keyArgs),
673  MappedCreator(mTreeMap.GetMemManager(), std::move(mappedArgs)));
674  }
675 
676  private:
677  static TreeMap pvCreateMap(map_base&& right, const allocator_type& alloc)
678  {
679  if (right.get_allocator() == alloc)
680  return std::move(right.mTreeMap);
681  TreeMap treeMap(right.mTreeMap.GetTreeTraits(), MemManager(alloc));
682  treeMap.MergeFrom(right.mTreeMap);
683  return treeMap;
684  }
685 
686  bool pvIsOrdered(const key_type& key1, const key_type& key2) const
687  {
688  const TreeTraits& treeTraits = mTreeMap.GetTreeTraits();
689  return TreeTraits::multiKey ? !treeTraits.IsLess(key2, key1)
690  : treeTraits.IsLess(key1, key2);
691  }
692 
693  std::pair<iterator, bool> pvFind(std::nullptr_t /*hint*/, const key_type& key)
694  {
695  iterator iter = upper_bound(key);
696  if (!TreeTraits::multiKey && iter != begin())
697  {
698  iterator prevIter = std::prev(iter);
699  if (!mTreeMap.GetTreeTraits().IsLess(prevIter->first, key))
700  return { prevIter, false };
701  }
702  return { iter, true };
703  }
704 
705  std::pair<iterator, bool> pvFind(const_iterator hint, const key_type& key)
706  {
707  if (hint != begin() && !pvIsOrdered(std::prev(hint)->first, key))
708  return pvFind(nullptr, key);
709  if (hint != end() && !pvIsOrdered(key, hint->first))
710  {
712  return { lower_bound(key), true };
713  else
714  return pvFind(nullptr, key);
715  }
716  return { IteratorProxy(mTreeMap.MakeMutableIterator(
717  ConstIteratorProxy::GetBaseIterator(hint))), true };
718  }
719 
720  template<typename Hint, typename... KeyArgs, typename MappedCreator>
721  std::pair<iterator, bool> pvInsert(Hint hint, std::tuple<KeyArgs...>&& keyArgs,
722  MappedCreator&& mappedCreator)
723  {
724  MemManager& memManager = mTreeMap.GetMemManager();
726  TreeMap::KeyValueTraits::keyAlignment> KeyBuffer;
728  typedef typename KeyManager::template Creator<KeyArgs...> KeyCreator;
729  KeyBuffer keyBuffer;
730  KeyCreator(memManager, std::move(keyArgs))(keyBuffer.GetPtr());
731  key_type* keyPtr = keyBuffer.template GetPtr<true>();
732  try
733  {
734  std::pair<iterator, bool> res = pvFind(hint, *keyPtr);
735  if (!res.second)
736  {
737  KeyManager::Destroy(memManager, *keyPtr);
738  keyPtr = nullptr;
739  return res;
740  }
741  auto valueCreator = [&memManager, &keyPtr, &mappedCreator]
742  (key_type* newKey, mapped_type* newMapped)
743  {
744  KeyManager::Relocate(memManager, *keyPtr, newKey);
745  keyPtr = nullptr;
746  try
747  {
748  std::forward<MappedCreator>(mappedCreator)(newMapped);
749  }
750  catch (...)
751  {
752  KeyManager::Destroy(memManager, *newKey);
753  throw;
754  }
755  };
756  TreeMapIterator resIter = mTreeMap.AddCrt(
757  IteratorProxy::GetBaseIterator(res.first), valueCreator);
758  return { IteratorProxy(resIter), true };
759  }
760  catch (...)
761  {
762  if (keyPtr != nullptr)
763  KeyManager::Destroy(memManager, *keyPtr);
764  throw;
765  }
766  }
767 
768  template<typename Hint, typename RKey, typename MappedCreator,
769  typename Key = typename std::decay<RKey>::type>
771  std::pair<iterator, bool>> pvInsert(Hint hint, std::tuple<RKey>&& key,
772  MappedCreator&& mappedCreator)
773  {
774  std::pair<iterator, bool> res = pvFind(hint,
775  static_cast<const key_type&>(std::get<0>(key)));
776  if (!res.second)
777  return res;
778  TreeMapIterator resIter = mTreeMap.AddCrt(IteratorProxy::GetBaseIterator(res.first),
779  std::forward<RKey>(std::get<0>(key)), std::forward<MappedCreator>(mappedCreator));
780  return { IteratorProxy(resIter), true };
781  }
782 
783  template<typename Iterator, typename Sentinel>
785  void> pvInsertRange(Iterator begin, Sentinel end)
786  {
787  mTreeMap.Insert(std::move(begin), std::move(end));
788  }
789 
790  template<typename Iterator, typename Sentinel>
792  void> pvInsertRange(Iterator begin, Sentinel end)
793  {
794  for (Iterator iter = std::move(begin); iter != end; ++iter)
795  insert(*iter);
796  }
797 
798  private:
799  TreeMap mTreeMap;
800  };
801 }
802 
831 template<typename TKey, typename TMapped,
832  typename TLessFunc = std::less<TKey>,
833  typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>,
834  typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>,
835  MemManagerStd<TAllocator>>>
836 class map : public internal::map_base<TKey, TMapped, TLessFunc, TAllocator, TTreeMap>
837 {
838 private:
840  typedef TTreeMap TreeMap;
841 
842 public:
843  using typename BaseMap::key_type;
844  using typename BaseMap::mapped_type;
845  using typename BaseMap::size_type;
846  using typename BaseMap::value_type;
847  using typename BaseMap::const_reference;
848  using typename BaseMap::const_iterator;
849  using typename BaseMap::iterator;
850 
851 public:
852  using BaseMap::BaseMap;
853 
854  map& operator=(std::initializer_list<value_type> values)
855  {
856  BaseMap::ptAssign(values);
857  return *this;
858  }
859 
860  friend void swap(map& left, map& right) noexcept
861  {
862  left.swap(right);
863  }
864 
866  {
867  return BaseMap::get_nested_container()[std::move(key)];
868  }
869 
871  {
872  return BaseMap::get_nested_container()[key];
873  }
874 
875  const mapped_type& at(const key_type& key) const
876  {
877  const_iterator iter = BaseMap::find(key);
878  if (iter == BaseMap::end())
879  throw std::out_of_range("invalid map key");
880  return iter->second;
881  }
882 
883  mapped_type& at(const key_type& key)
884  {
885  iterator iter = BaseMap::find(key);
886  if (iter == BaseMap::end())
887  throw std::out_of_range("invalid map key");
888  return iter->second;
889  }
890 
891  template<typename... MappedArgs>
892  std::pair<iterator, bool> try_emplace(key_type&& key, MappedArgs&&... mappedArgs)
893  {
894  return BaseMap::ptEmplace(nullptr, std::forward_as_tuple(std::move(key)),
895  std::forward_as_tuple(std::forward<MappedArgs>(mappedArgs)...));
896  }
897 
898  template<typename... MappedArgs>
899  iterator try_emplace(const_iterator hint, key_type&& key, MappedArgs&&... mappedArgs)
900  {
901  return BaseMap::ptEmplace(hint, std::forward_as_tuple(std::move(key)),
902  std::forward_as_tuple(std::forward<MappedArgs>(mappedArgs)...)).first;
903  }
904 
905  template<typename... MappedArgs>
906  std::pair<iterator, bool> try_emplace(const key_type& key, MappedArgs&&... mappedArgs)
907  {
908  return BaseMap::ptEmplace(nullptr, std::forward_as_tuple(key),
909  std::forward_as_tuple(std::forward<MappedArgs>(mappedArgs)...));
910  }
911 
912  template<typename... MappedArgs>
913  iterator try_emplace(const_iterator hint, const key_type& key, MappedArgs&&... mappedArgs)
914  {
915  return BaseMap::ptEmplace(hint, std::forward_as_tuple(key),
916  std::forward_as_tuple(std::forward<MappedArgs>(mappedArgs)...)).first;
917  }
918 
919  template<typename MappedArg>
920  std::pair<iterator, bool> insert_or_assign(key_type&& key, MappedArg&& mappedArg)
921  {
922  return pvInsertOrAssign(nullptr, std::move(key), std::forward<MappedArg>(mappedArg));
923  }
924 
925  template<typename MappedArg>
926  iterator insert_or_assign(const_iterator hint, key_type&& key, MappedArg&& mappedArg)
927  {
928  return pvInsertOrAssign(hint, std::move(key), std::forward<MappedArg>(mappedArg)).first;
929  }
930 
931  template<typename MappedArg>
932  std::pair<iterator, bool> insert_or_assign(const key_type& key, MappedArg&& mappedArg)
933  {
934  return pvInsertOrAssign(nullptr, key, std::forward<MappedArg>(mappedArg));
935  }
936 
937  template<typename MappedArg>
938  iterator insert_or_assign(const_iterator hint, const key_type& key, MappedArg&& mappedArg)
939  {
940  return pvInsertOrAssign(hint, key, std::forward<MappedArg>(mappedArg)).first;
941  }
942 
943  template<typename ValueFilter>
944  friend size_type erase_if(map& cont, const ValueFilter& valueFilter)
945  {
946  auto pairFilter = [&valueFilter] (const key_type& key, const mapped_type& mapped)
947  { return valueFilter(const_reference(key, mapped)); };
948  return cont.get_nested_container().Remove(pairFilter);
949  }
950 
951 private:
952  template<typename Hint, typename RKey, typename MappedArg>
953  std::pair<iterator, bool> pvInsertOrAssign(Hint hint, RKey&& key, MappedArg&& mappedArg)
954  {
955  std::pair<iterator, bool> res = BaseMap::ptEmplace(hint,
956  std::forward_as_tuple(std::forward<RKey>(key)),
957  std::forward_as_tuple(std::forward<MappedArg>(mappedArg)));
958  if (!res.second)
959  res.first->second = std::forward<MappedArg>(mappedArg);
960  return res;
961  }
962 };
963 
972 template<typename TKey, typename TMapped,
973  typename TLessFunc = std::less<TKey>,
974  typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>,
975  typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc, true>,
976  MemManagerStd<TAllocator>>>
977 class multimap : public internal::map_base<TKey, TMapped, TLessFunc, TAllocator, TTreeMap>
978 {
979 private:
981 
982 public:
983  using typename BaseMap::key_type;
984  using typename BaseMap::mapped_type;
985  using typename BaseMap::size_type;
986  using typename BaseMap::value_type;
987  using typename BaseMap::iterator;
988  using typename BaseMap::const_reference;
989  using typename BaseMap::const_iterator;
990  using typename BaseMap::node_type;
991 
993 
994 public:
995  using BaseMap::BaseMap;
996 
997  multimap& operator=(std::initializer_list<value_type> values)
998  {
999  BaseMap::ptAssign(values);
1000  return *this;
1001  }
1002 
1003  friend void swap(multimap& left, multimap& right) noexcept
1004  {
1005  left.swap(right);
1006  }
1007 
1008  //using BaseMap::insert; // gcc 5 & 6
1009 
1010  template<typename ValueArg = std::pair<key_type, mapped_type>>
1012  iterator> insert(ValueArg&& valueArg)
1013  {
1014  return BaseMap::insert(std::forward<ValueArg>(valueArg)).first;
1015  }
1016 
1017  template<typename ValueArg = std::pair<key_type, mapped_type>>
1019  iterator> insert(const_iterator hint, ValueArg&& valueArg)
1020  {
1021  return BaseMap::insert(hint, std::forward<ValueArg>(valueArg));
1022  }
1023 
1025  {
1026  return BaseMap::insert(std::move(node)).position;
1027  }
1028 
1030  {
1031  return BaseMap::insert(hint, std::move(node));
1032  }
1033 
1034  template<typename Iterator>
1035  void insert(Iterator first, Iterator last)
1036  {
1037  BaseMap::insert(first, last);
1038  }
1039 
1040  void insert(std::initializer_list<value_type> values)
1041  {
1042  BaseMap::insert(values);
1043  }
1044 
1045  template<typename... ValueArgs>
1046  iterator emplace(ValueArgs&&... valueArgs)
1047  {
1048  return BaseMap::emplace(std::forward<ValueArgs>(valueArgs)...).first;
1049  }
1050 
1051  template<typename ValueFilter>
1052  friend size_type erase_if(multimap& cont, const ValueFilter& valueFilter)
1053  {
1054  auto pairFilter = [&valueFilter] (const key_type& key, const mapped_type& mapped)
1055  { return valueFilter(const_reference(key, mapped)); };
1056  return cont.get_nested_container().Remove(pairFilter);
1057  }
1058 };
1059 
1060 #ifdef MOMO_HAS_DEDUCTION_GUIDES
1061 
1062 #define MOMO_DECLARE_DEDUCTION_GUIDES(map) \
1063 template<typename Iterator, \
1064  typename Value = typename std::iterator_traits<Iterator>::value_type, \
1065  typename Key = std::decay_t<typename Value::first_type>, \
1066  typename Mapped = std::decay_t<typename Value::second_type>, \
1067  typename Allocator = std::allocator<std::pair<const Key, Mapped>>, \
1068  typename = internal::ordered_checker<Key, Allocator>> \
1069 map(Iterator, Iterator, Allocator = Allocator()) \
1070  -> map<Key, Mapped, std::less<Key>, Allocator>; \
1071 template<typename Iterator, typename LessFunc, \
1072  typename Value = typename std::iterator_traits<Iterator>::value_type, \
1073  typename Key = std::decay_t<typename Value::first_type>, \
1074  typename Mapped = std::decay_t<typename Value::second_type>, \
1075  typename Allocator = std::allocator<std::pair<const Key, Mapped>>, \
1076  typename = internal::ordered_checker<Key, Allocator, LessFunc>> \
1077 map(Iterator, Iterator, LessFunc, Allocator = Allocator()) \
1078  -> map<Key, Mapped, LessFunc, Allocator>; \
1079 template<typename CKey, typename Mapped, \
1080  typename Key = std::remove_const_t<CKey>, \
1081  typename Allocator = std::allocator<std::pair<const Key, Mapped>>, \
1082  typename = internal::ordered_checker<Key, Allocator>> \
1083 map(std::initializer_list<std::pair<CKey, Mapped>>, Allocator = Allocator()) \
1084  -> map<Key, Mapped, std::less<Key>, Allocator>; \
1085 template<typename CKey, typename Mapped, typename LessFunc, \
1086  typename Key = std::remove_const_t<CKey>, \
1087  typename Allocator = std::allocator<std::pair<const Key, Mapped>>, \
1088  typename = internal::ordered_checker<Key, Allocator, LessFunc>> \
1089 map(std::initializer_list<std::pair<CKey, Mapped>>, LessFunc, Allocator = Allocator()) \
1090  -> map<Key, Mapped, LessFunc, Allocator>;
1091 
1092 MOMO_DECLARE_DEDUCTION_GUIDES(map)
1093 MOMO_DECLARE_DEDUCTION_GUIDES(multimap)
1094 
1095 #undef MOMO_DECLARE_DEDUCTION_GUIDES
1096 
1097 #ifdef MOMO_HAS_CONTAINERS_RANGES
1098 
1099 #define MOMO_DECLARE_DEDUCTION_GUIDES_RANGES(map) \
1100 template<std::ranges::input_range Range, \
1101  typename Value = std::ranges::range_value_t<Range>, \
1102  typename Key = std::decay_t<typename Value::first_type>, \
1103  typename Mapped = std::decay_t<typename Value::second_type>, \
1104  typename Allocator = std::allocator<std::pair<const Key, Mapped>>, \
1105  typename = internal::ordered_checker<Key, Allocator>> \
1106 map(std::from_range_t, Range&&, Allocator = Allocator()) \
1107  -> map<Key, Mapped, std::less<Key>, Allocator>; \
1108 template<std::ranges::input_range Range, typename LessFunc, \
1109  typename Value = std::ranges::range_value_t<Range>, \
1110  typename Key = std::decay_t<typename Value::first_type>, \
1111  typename Mapped = std::decay_t<typename Value::second_type>, \
1112  typename Allocator = std::allocator<std::pair<const Key, Mapped>>, \
1113  typename = internal::ordered_checker<Key, Allocator, LessFunc>> \
1114 map(std::from_range_t, Range&&, LessFunc, Allocator = Allocator()) \
1115  -> map<Key, Mapped, LessFunc, Allocator>;
1116 
1117 MOMO_DECLARE_DEDUCTION_GUIDES_RANGES(map)
1118 MOMO_DECLARE_DEDUCTION_GUIDES_RANGES(multimap)
1119 
1120 #undef MOMO_DECLARE_DEDUCTION_GUIDES_RANGES
1121 
1122 #endif // MOMO_HAS_CONTAINERS_RANGES
1123 
1124 #endif // MOMO_HAS_DEDUCTION_GUIDES
1125 
1126 } // namespace stdish
1127 
1128 } // namespace momo
1129 
1130 #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:212
momo::TreeMap::ValueReferenceCKey
ValueReferencer::template ValueReference< const Key & > ValueReferenceCKey
Definition: TreeMap.h:272
momo::internal::InsertResult::position
Position position
Definition: IteratorUtility.h:168
momo::stdish::internal::map_base::rbegin
reverse_iterator rbegin() noexcept
Definition: map.h:281
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:382
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:213
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:435
momo::stdish::map::insert_or_assign
iterator insert_or_assign(const_iterator hint, key_type &&key, MappedArg &&mappedArg)
Definition: map.h:926
momo::stdish::map
momo::stdish::map is similar to std::map, but much more efficient in memory usage....
Definition: map.h:837
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:944
momo::stdish::map::insert_or_assign
std::pair< iterator, bool > insert_or_assign(key_type &&key, MappedArg &&mappedArg)
Definition: map.h:920
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::stdish::internal::map_base::contains
bool contains(const key_type &key) const
Definition: map.h:394
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:370
momo::stdish::internal::map_base::crend
const_reverse_iterator crend() const noexcept
Definition: map.h:311
momo::stdish::internal::map_base::map_base
map_base(const key_compare &lessFunc, const allocator_type &alloc=allocator_type())
Definition: map.h:139
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:1046
momo::stdish::multimap::insert
momo::internal::EnableIf< std::is_constructible< value_type, ValueArg && >::value, iterator > insert(ValueArg &&valueArg)
Definition: map.h:1012
momo::stdish::internal::map_base::map_base
map_base(const allocator_type &alloc)
Definition: map.h:134
set_map_utility.h
momo::stdish::internal::map_base::upper_bound
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, iterator > upper_bound(const KeyArg &key)
Definition: map.h:449
momo::stdish::internal::map_base::get_nested_container
nested_container_type & get_nested_container() noexcept
Definition: map.h:251
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:992
momo::stdish::internal::map_base::ptAssign
void ptAssign(std::initializer_list< value_type > values)
Definition: map.h:659
momo::stdish::internal::map_base::insert
iterator insert(const_iterator hint, node_type &&node)
Definition: map.h:512
momo::stdish::internal::insert_return_type
Definition: set_map_utility.h:194
momo::stdish::internal::map_base::count
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, size_type > count(const KeyArg &key) const
Definition: map.h:389
momo::stdish::internal::map_base::emplace_hint
iterator emplace_hint(const_iterator hint, ValueArg &&valueArg)
Definition: map.h:562
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:630
momo::stdish::internal::map_base::lower_bound
iterator lower_bound(const key_type &key)
Definition: map.h:411
momo::stdish::internal::map_base::map_base
map_base(std::initializer_list< momo::internal::Identity< value_type >> values, const key_compare &lessFunc, const allocator_type &alloc=allocator_type())
Definition: map.h:165
momo::stdish::internal::map_base::map_base
map_base(const map_base &right, const momo::internal::Identity< allocator_type > &alloc)
Definition: map.h:206
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:667
momo::stdish::internal::map_base::rbegin
const_reverse_iterator rbegin() const noexcept
Definition: map.h:276
momo::internal::TreeDerivedIterator::BaseIterator
TBaseIterator BaseIterator
Definition: IteratorUtility.h:447
momo::internal::TreeMapIterator
Definition: TreeMap.h:33
momo::stdish::internal::map_base::max_size
size_type max_size() const noexcept
Definition: map.h:338
momo::TreeTraits
Definition: TreeTraits.h:82
momo::stdish::map::operator[]
TreeMap::ValueReferenceRKey operator[](key_type &&key)
Definition: map.h:865
momo::stdish::internal::map_base::insert
void insert(Iterator first, Iterator last)
Definition: map.h:524
momo::stdish::internal::map_base::find
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, iterator > find(const KeyArg &key)
Definition: map.h:377
momo::stdish::multimap::insert
void insert(std::initializer_list< value_type > values)
Definition: map.h:1040
momo::internal::InsertResult
Definition: IteratorUtility.h:136
momo::stdish::internal::map_node_handle::MapExtractedPair
TMapExtractedPair MapExtractedPair
Definition: set_map_utility.h:105
momo::stdish::map::operator[]
TreeMap::ValueReferenceCKey operator[](const key_type &key)
Definition: map.h:870
momo::stdish::internal::map_base::operator<
friend bool operator<(const map_base &left, const map_base &right)
Definition: map.h:649
momo::stdish::internal::map_base::rend
const_reverse_iterator rend() const noexcept
Definition: map.h:286
momo::stdish::internal::map_base::find
const_iterator find(const key_type &key) const
Definition: map.h:358
momo::TreeMap::ValueReferenceRKey
ValueReferencer::template ValueReference< Key && > ValueReferenceRKey
Definition: TreeMap.h:271
momo::stdish::internal::map_node_handle
Definition: set_map_utility.h:103
momo::stdish::internal::map_base::emplace
std::pair< iterator, bool > emplace()
Definition: map.h:543
momo::stdish::internal::map_base::extract
node_type extract(const_iterator where)
Definition: map.h:618
momo::stdish::multimap
momo::stdish::multimap is similar to std::multimap, but much more efficient in memory usage....
Definition: map.h:978
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:198
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:577
momo::stdish::internal::map_base::upper_bound
const_iterator upper_bound(const key_type &key) const
Definition: map.h:430
momo
Definition: Array.h:26
momo::stdish::internal::map_base::rend
reverse_iterator rend() noexcept
Definition: map.h:291
momo::stdish::internal::map_value_compare::Key
TKey Key
Definition: map.h:35
momo::stdish::multimap::insert
momo::internal::EnableIf< std::is_constructible< value_type, ValueArg && >::value, iterator > insert(const_iterator hint, ValueArg &&valueArg)
Definition: map.h:1019
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:476
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:190
momo::stdish::internal::map_base::key_comp
key_compare key_comp() const
Definition: map.h:316
momo::stdish::multimap::insert
void insert(Iterator first, Iterator last)
Definition: map.h:1035
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:195
momo::internal::IteratorPointer
Definition: IteratorUtility.h:264
momo::stdish::internal::map_base::allocator_type
TAllocator allocator_type
Definition: map.h:72
momo::internal::InsertResult::inserted
bool inserted
Definition: IteratorUtility.h:171
momo::internal::Identity
EnableIf< true, Type > Identity
Definition: Utility.h:201
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:227
momo::stdish::internal::map_base::insert
momo::internal::EnableIf< std::is_constructible< value_type, ValueArg && >::value, std::pair< iterator, bool > > insert(ValueArg &&valueArg)
Definition: map.h:490
momo::stdish::map::try_emplace
std::pair< iterator, bool > try_emplace(const key_type &key, MappedArgs &&... mappedArgs)
Definition: map.h:906
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:591
momo::stdish::map::try_emplace
iterator try_emplace(const_iterator hint, const key_type &key, MappedArgs &&... mappedArgs)
Definition: map.h:913
momo::stdish::internal::map_base::emplace
std::pair< iterator, bool > emplace(ValueArg &&valueArg)
Definition: map.h:554
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:597
momo::stdish::internal::map_base::end
const_iterator end() const noexcept
Definition: map.h:266
momo::stdish::internal::map_base::get_nested_container
const nested_container_type & get_nested_container() const noexcept
Definition: map.h:246
MOMO_DECLARE_PROXY_CONSTRUCTOR
#define MOMO_DECLARE_PROXY_CONSTRUCTOR(Object)
Definition: Utility.h:107
momo::stdish::multimap::operator=
multimap & operator=(std::initializer_list< value_type > values)
Definition: map.h:997
momo::stdish::internal::map_base::operator==
friend bool operator==(const map_base &left, const map_base &right)
Definition: map.h:635
momo::stdish::internal::map_base::lower_bound
const_iterator lower_bound(const key_type &key) const
Definition: map.h:406
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:201
momo::stdish::multimap::insert
iterator insert(node_type &&node)
Definition: map.h:1024
momo::stdish::internal::map_base::equal_range
std::pair< const_iterator, const_iterator > equal_range(const key_type &key) const
Definition: map.h:454
momo::stdish::internal::map_base::insert
momo::internal::EnableIf< std::is_constructible< value_type, ValueArg && >::value, iterator > insert(const_iterator hint, ValueArg &&valueArg)
Definition: map.h:497
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(const_iterator hint, node_type &&node)
Definition: map.h:1029
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:1052
momo::stdish::map::at
const mapped_type & at(const key_type &key) const
Definition: map.h:875
momo::stdish::internal::map_base::upper_bound
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, const_iterator > upper_bound(const KeyArg &key) const
Definition: map.h:442
momo::stdish::internal::map_base::emplace_hint
iterator emplace_hint(const_iterator hint)
Definition: map.h:548
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:333
momo::internal::TreeDerivedIterator
Definition: IteratorUtility.h:445
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:308
momo::stdish::internal::map_base::insert
void insert(std::initializer_list< value_type > values)
Definition: map.h:529
momo::stdish::internal::map_base::clear
void clear() noexcept
Definition: map.h:353
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:584
momo::stdish::internal::map_base::value_comp
value_compare value_comp() const
Definition: map.h:321
momo::stdish::internal::map_base::cend
const_iterator cend() const noexcept
Definition: map.h:301
momo::stdish::map::insert_or_assign
std::pair< iterator, bool > insert_or_assign(const key_type &key, MappedArg &&mappedArg)
Definition: map.h:932
momo::stdish::map::operator=
map & operator=(std::initializer_list< value_type > values)
Definition: map.h:854
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:899
momo::stdish::internal::map_base::equal_range
std::pair< iterator, iterator > equal_range(const key_type &key)
Definition: map.h:464
momo::stdish::internal::map_base::empty
MOMO_NODISCARD bool empty() const noexcept
Definition: map.h:348
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:343
momo::stdish::internal::map_base::erase
iterator erase(iterator where)
Definition: map.h:602
momo::stdish::internal::map_base::begin
iterator begin() noexcept
Definition: map.h:261
momo::stdish::internal::map_base::erase
iterator erase(const_iterator first, const_iterator last)
Definition: map.h:607
MOMO_STATIC_ASSERT
#define MOMO_STATIC_ASSERT(...)
Definition: Utility.h:96
momo::stdish::map::swap
friend void swap(map &left, map &right) noexcept
Definition: map.h:860
momo::internal::TreeDerivedIterator::Reference
TReference< typename BaseIterator::Reference > Reference
Definition: IteratorUtility.h:450
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:239
momo::stdish::multimap::swap
friend void swap(multimap &left, multimap &right) noexcept
Definition: map.h:1003
momo::stdish::map::insert_or_assign
iterator insert_or_assign(const_iterator hint, const key_type &key, MappedArg &&mappedArg)
Definition: map.h:938
momo::stdish::internal::map_base::extract
node_type extract(const key_type &key)
Definition: map.h:623
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_MORE_COMPARISON_OPERATORS
#define MOMO_MORE_COMPARISON_OPERATORS(ObjectArg)
Definition: Utility.h:77
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:418
momo::stdish::internal::map_base::crbegin
const_reverse_iterator crbegin() const noexcept
Definition: map.h:306
momo::stdish::internal::map_base::emplace
std::pair< iterator, bool > emplace(KeyArg &&keyArg, MappedArg &&mappedArg)
Definition: map.h:570
momo::stdish::internal::map_base::begin
const_iterator begin() const noexcept
Definition: map.h:256
momo::TreeMap::TreeTraits
TTreeTraits TreeTraits
Definition: TreeMap.h:242
momo::stdish::map::at
mapped_type & at(const key_type &key)
Definition: map.h:883
momo::stdish::internal::map_base::map_base
map_base(std::initializer_list< momo::internal::Identity< value_type >> values, const allocator_type &alloc=allocator_type())
Definition: map.h:159
momo::TreeTraits::multiKey
static const bool multiKey
Definition: TreeTraits.h:87
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:425
MOMO_DECLARE_PROXY_FUNCTION
#define MOMO_DECLARE_PROXY_FUNCTION(Object, Func, Result)
Definition: Utility.h:116
momo::stdish::internal::map_base::end
iterator end() noexcept
Definition: map.h:271
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:613
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:483
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:892
momo::stdish::internal::map_base::insert
insert_return_type insert(node_type &&node)
Definition: map.h:502
MOMO_NODISCARD
#define MOMO_NODISCARD
Definition: UserSettings.h:203
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:401
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:363
momo::internal::MapReferenceStd
Definition: MapUtility.h:68
momo::stdish::internal::map_base::cbegin
const_iterator cbegin() const noexcept
Definition: map.h:296