momo  3.12
set.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/set.h
10 
11  namespace momo::stdish:
12  class set_adaptor
13  class multiset_adaptor
14  class set
15  class multiset
16 
17 \**********************************************************/
18 
19 #ifndef MOMO_INCLUDE_GUARD_STDISH_SET
20 #define MOMO_INCLUDE_GUARD_STDISH_SET
21 
22 #include "set_map_utility.h"
23 #include MOMO_PARENT_HEADER(TreeSet)
24 
25 namespace momo
26 {
27 
28 namespace stdish
29 {
30 
31 template<typename TTreeSet>
33 {
34 private:
35  typedef TTreeSet TreeSet;
36  typedef typename TreeSet::TreeTraits TreeTraits;
37  typedef typename TreeSet::MemManager MemManager;
38 
39 public:
40  typedef typename TreeSet::Key key_type;
41  typedef typename TreeTraits::LessComparer key_compare;
42 
43  typedef TreeSet nested_container_type;
44 
45  typedef size_t size_type;
46  typedef ptrdiff_t difference_type;
47 
50  typedef typename std::allocator_traits<typename MemManager::ByteAllocator>
51  ::template rebind_alloc<value_type> allocator_type;
52 
54  typedef typename TreeSet::Iterator iterator;
55 
56  //typedef typename iterator::Reference reference;
59 
60  //typedef typename iterator::Pointer pointer;
61  typedef value_type* pointer;
63  //typedef typename std::allocator_traits<allocator_type>::pointer pointer;
64  //typedef typename std::allocator_traits<allocator_type>::const_pointer const_pointer;
65 
66  typedef std::reverse_iterator<iterator> reverse_iterator;
67  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
68 
71 
72 private:
73  template<typename KeyArg>
74  struct IsValidKeyArg : public TreeTraits::template IsValidKeyArg<KeyArg>
75  {
76  };
77 
78  struct NodeTypeProxy : private node_type
79  {
80  typedef node_type NodeType;
81  MOMO_DECLARE_PROXY_FUNCTION(NodeType, GetExtractedItem)
82  };
83 
84 public:
86  {
87  }
88 
89  explicit set_adaptor(const allocator_type& alloc)
90  : mTreeSet(TreeTraits(), MemManager(alloc))
91  {
92  }
93 
94  explicit set_adaptor(const key_compare& lessComp, const allocator_type& alloc = allocator_type())
95  : mTreeSet(TreeTraits(lessComp), MemManager(alloc))
96  {
97  }
98 
99  template<typename Iterator>
100  set_adaptor(Iterator first, Iterator last, const allocator_type& alloc = allocator_type())
101  : set_adaptor(alloc)
102  {
103  insert(first, last);
104  }
105 
106  template<typename Iterator>
107  set_adaptor(Iterator first, Iterator last, const key_compare& lessComp,
108  const allocator_type& alloc = allocator_type())
109  : set_adaptor(lessComp, alloc)
110  {
111  insert(first, last);
112  }
113 
114  set_adaptor(std::initializer_list<value_type> values,
115  const allocator_type& alloc = allocator_type())
116  : mTreeSet(values, TreeTraits(), MemManager(alloc))
117  {
118  }
119 
120  set_adaptor(std::initializer_list<value_type> values,
121  const key_compare& lessComp, const allocator_type& alloc = allocator_type())
122  : mTreeSet(values, TreeTraits(lessComp), MemManager(alloc))
123  {
124  }
125 
126 #ifdef MOMO_HAS_CONTAINERS_RANGES
127  template<std::ranges::input_range Range>
128  requires std::convertible_to<std::ranges::range_reference_t<Range>, value_type>
129  set_adaptor(std::from_range_t, Range&& values, const allocator_type& alloc = allocator_type())
130  : set_adaptor(alloc)
131  {
132  insert_range(std::forward<Range>(values));
133  }
134 
135  template<std::ranges::input_range Range>
136  requires std::convertible_to<std::ranges::range_reference_t<Range>, value_type>
137  set_adaptor(std::from_range_t, Range&& values, const key_compare& lessComp,
138  const allocator_type& alloc = allocator_type())
139  : set_adaptor(lessComp, alloc)
140  {
141  insert_range(std::forward<Range>(values));
142  }
143 #endif // MOMO_HAS_CONTAINERS_RANGES
144 
146  : set_adaptor(std::move(right), right.get_allocator())
147  {
148  }
149 
150  set_adaptor(set_adaptor&& right, const allocator_type& alloc)
151  : mTreeSet(right.mTreeSet.GetTreeTraits(), MemManager(alloc))
152  {
153  if (right.get_allocator() == alloc)
154  {
155  mTreeSet.Swap(right.mTreeSet);
156  }
157  else
158  {
159  mTreeSet.MergeFrom(right.mTreeSet);
160  right.clear();
161  }
162  }
163 
164  set_adaptor(const set_adaptor& right)
165  : mTreeSet(right.mTreeSet)
166  {
167  }
168 
169  set_adaptor(const set_adaptor& right, const allocator_type& alloc)
170  : mTreeSet(right.mTreeSet, MemManager(alloc))
171  {
172  }
173 
174  ~set_adaptor() = default;
175 
178  {
179  return momo::internal::ContainerAssignerStd::Move(std::move(right), *this);
180  }
181 
183  {
184  return momo::internal::ContainerAssignerStd::Copy(right, *this);
185  }
186 
187  set_adaptor& operator=(std::initializer_list<value_type> values)
188  {
189  mTreeSet = TreeSet(values, mTreeSet.GetTreeTraits(), MemManager(get_allocator()));
190  return *this;
191  }
192 
193  void swap(set_adaptor& right) noexcept
194  {
196  }
197 
198  friend void swap(set_adaptor& left, set_adaptor& right) noexcept
199  {
200  left.swap(right);
201  }
202 
204  {
205  return mTreeSet;
206  }
207 
209  {
210  return mTreeSet;
211  }
212 
213  const_iterator begin() const noexcept
214  {
215  return mTreeSet.GetBegin();
216  }
217 
218  //iterator begin() noexcept
219 
220  const_iterator end() const noexcept
221  {
222  return mTreeSet.GetEnd();
223  }
224 
225  //iterator end() noexcept
226 
228  {
229  return const_reverse_iterator(end());
230  }
231 
232  //reverse_iterator rbegin() noexcept
233 
234  const_reverse_iterator rend() const noexcept
235  {
236  return const_reverse_iterator(begin());
237  }
238 
239  //reverse_iterator rend() noexcept
240 
241  const_iterator cbegin() const noexcept
242  {
243  return begin();
244  }
245 
246  const_iterator cend() const noexcept
247  {
248  return end();
249  }
250 
252  {
253  return rbegin();
254  }
255 
256  const_reverse_iterator crend() const noexcept
257  {
258  return rend();
259  }
260 
262  {
263  return mTreeSet.GetTreeTraits().GetLessComparer();
264  }
265 
267  {
268  return key_comp();
269  }
270 
271  allocator_type get_allocator() const noexcept
272  {
273  return allocator_type(mTreeSet.GetMemManager().GetByteAllocator());
274  }
275 
276  size_type max_size() const noexcept
277  {
278  return std::allocator_traits<allocator_type>::max_size(get_allocator());
279  }
280 
281  size_type size() const noexcept
282  {
283  return mTreeSet.GetCount();
284  }
285 
286  MOMO_NODISCARD bool empty() const noexcept
287  {
288  return mTreeSet.IsEmpty();
289  }
290 
291  void clear() noexcept
292  {
293  mTreeSet.Clear();
294  }
295 
296  const_iterator find(const key_type& key) const
297  {
298  return mTreeSet.Find(key);
299  }
300 
301  //iterator find(const key_type& key)
302 
303  template<typename KeyArg>
305  const_iterator> find(const KeyArg& key) const
306  {
307  return mTreeSet.Find(key);
308  }
309 
310  //template<typename KeyArg>
311  //momo::internal::EnableIf<IsValidKeyArg<KeyArg>::value,
312  //iterator> find(const KeyArg& key)
313 
314  size_type count(const key_type& key) const
315  {
316  return mTreeSet.GetKeyCount(key);
317  }
318 
319  template<typename KeyArg>
321  size_type> count(const KeyArg& key) const
322  {
323  return mTreeSet.GetKeyCount(key);
324  }
325 
326  bool contains(const key_type& key) const
327  {
328  return mTreeSet.ContainsKey(key);
329  }
330 
331  template<typename KeyArg>
333  bool> contains(const KeyArg& key) const
334  {
335  return mTreeSet.ContainsKey(key);
336  }
337 
339  {
340  return mTreeSet.GetLowerBound(key);
341  }
342 
343  //iterator lower_bound(const key_type& key)
344 
345  template<typename KeyArg>
347  const_iterator> lower_bound(const KeyArg& key) const
348  {
349  return mTreeSet.GetLowerBound(key);
350  }
351 
352  //template<typename KeyArg>
353  //momo::internal::EnableIf<IsValidKeyArg<KeyArg>::value,
354  //iterator> lower_bound(const KeyArg& key)
355 
357  {
358  return mTreeSet.GetUpperBound(key);
359  }
360 
361  //iterator upper_bound(const key_type& key)
362 
363  template<typename KeyArg>
365  const_iterator> upper_bound(const KeyArg& key) const
366  {
367  return mTreeSet.GetUpperBound(key);
368  }
369 
370  //template<typename KeyArg>
371  //momo::internal::EnableIf<IsValidKeyArg<KeyArg>::value,
372  //iterator> upper_bound(const KeyArg& key)
373 
374  std::pair<const_iterator, const_iterator> equal_range(const key_type& key) const
375  {
376  const_iterator iter = lower_bound(key);
378  {
379  return { iter, upper_bound(key) };
380  }
381  else
382  {
383  if (iter == end() || mTreeSet.GetTreeTraits().IsLess(key, *iter))
384  return { iter, iter };
385  return { iter, std::next(iter) };
386  }
387  }
388 
389  //std::pair<iterator, iterator> equal_range(const key_type& key)
390 
391  template<typename KeyArg>
393  std::pair<const_iterator, const_iterator>> equal_range(const KeyArg& key) const
394  {
395  return { lower_bound(key), upper_bound(key) };
396  }
397 
398  //template<typename KeyArg>
399  //momo::internal::EnableIf<IsValidKeyArg<KeyArg>::value,
400  //std::pair<iterator, iterator>> equal_range(const KeyArg& key)
401 
402  std::pair<iterator, bool> insert(value_type&& value)
403  {
404  typename TreeSet::InsertResult res = mTreeSet.Insert(std::move(value));
405  return { res.position, res.inserted };
406  }
407 
409  {
410  if (!pvCheckHint(hint, static_cast<const key_type&>(value)))
411  return insert(std::move(value)).first;
412  return mTreeSet.Add(hint, std::move(value));
413  }
414 
415  std::pair<iterator, bool> insert(const value_type& value)
416  {
417  typename TreeSet::InsertResult res = mTreeSet.Insert(value);
418  return { res.position, res.inserted };
419  }
420 
422  {
423  if (!pvCheckHint(hint, value))
424  return insert(value).first;
425  return mTreeSet.Add(hint, value);
426  }
427 
429  {
430  if (node.empty())
431  return { end(), false, node_type() };
432  typename TreeSet::InsertResult res = mTreeSet.Insert(
433  std::move(NodeTypeProxy::GetExtractedItem(node)));
434  return { res.position, res.inserted, res.inserted ? node_type() : std::move(node) };
435  }
436 
438  {
439  if (node.empty())
440  return end();
441  if (!pvCheckHint(hint, node.value()))
442  return insert(std::move(node)).position;
443  return mTreeSet.Add(hint, std::move(NodeTypeProxy::GetExtractedItem(node)));
444  }
445 
446  template<typename Iterator>
447  void insert(Iterator first, Iterator last)
448  {
449  pvInsertRange(first, last);
450  }
451 
452  void insert(std::initializer_list<value_type> values)
453  {
454  mTreeSet.Insert(values);
455  }
456 
457 #ifdef MOMO_HAS_CONTAINERS_RANGES
458  template<std::ranges::input_range Range>
459  requires std::convertible_to<std::ranges::range_reference_t<Range>, value_type>
460  void insert_range(Range&& values)
461  {
462  pvInsertRange(std::ranges::begin(values), std::ranges::end(values));
463  }
464 #endif // MOMO_HAS_CONTAINERS_RANGES
465 
466  template<typename... ValueArgs>
467  std::pair<iterator, bool> emplace(ValueArgs&&... valueArgs)
468  {
469  MemManager& memManager = mTreeSet.GetMemManager();
470  typename TreeSet::ExtractedItem extItem;
471  typedef typename TreeSet::ItemTraits::template Creator<ValueArgs...> ValueCreator;
472  extItem.Create(ValueCreator(memManager, std::forward<ValueArgs>(valueArgs)...));
473  typename TreeSet::InsertResult res = mTreeSet.Insert(std::move(extItem));
474  return { res.position, res.inserted };
475  }
476 
477  template<typename ValueArg>
479  std::pair<iterator, bool>> emplace(ValueArg&& valueArg)
480  {
481  typename TreeSet::InsertResult res = mTreeSet.InsertVar(
482  static_cast<const key_type&>(valueArg), std::forward<ValueArg>(valueArg));
483  return { res.position, res.inserted };
484  }
485 
486  template<typename... ValueArgs>
487  iterator emplace_hint(const_iterator hint, ValueArgs&&... valueArgs)
488  {
489  MemManager& memManager = mTreeSet.GetMemManager();
490  typename TreeSet::ExtractedItem extItem;
491  typedef typename TreeSet::ItemTraits::template Creator<ValueArgs...> ValueCreator;
492  extItem.Create(ValueCreator(memManager, std::forward<ValueArgs>(valueArgs)...));
493  if (!pvCheckHint(hint, extItem.GetItem()))
494  return mTreeSet.Insert(std::move(extItem)).position;
495  return mTreeSet.Add(hint, std::move(extItem));
496  }
497 
498  template<typename ValueArg>
500  iterator> emplace_hint(const_iterator hint, ValueArg&& valueArg)
501  {
502  if (!pvCheckHint(hint, static_cast<const key_type&>(valueArg)))
503  return emplace(std::forward<ValueArg>(valueArg)).first;
504  return mTreeSet.AddVar(hint, std::forward<ValueArg>(valueArg));
505  }
506 
508  {
509  return mTreeSet.Remove(where);
510  }
511 
512  //iterator erase(iterator where)
513 
515  {
516  return mTreeSet.Remove(first, last);
517  }
518 
520  {
521  return mTreeSet.Remove(key);
522  }
523 
524  template<typename ValueFilter>
525  friend size_type erase_if(set_adaptor& cont, const ValueFilter& valueFilter)
526  {
527  return cont.mTreeSet.Remove(valueFilter);
528  }
529 
531  {
532  return node_type(*this, where); // need RVO for exception safety
533  }
534 
536  {
537  const_iterator iter = find(key);
538  return (iter != end()) ? extract(iter) : node_type();
539  }
540 
541  template<typename Set>
542  void merge(Set&& set_adaptor)
543  {
544  mTreeSet.MergeFrom(set_adaptor.get_nested_container());
545  }
546 
547  friend bool operator==(const set_adaptor& left, const set_adaptor& right)
548  {
549  return left.size() == right.size() && std::equal(left.begin(), left.end(), right.begin());
550  }
551 
552 #ifdef MOMO_HAS_THREE_WAY_COMPARISON
553  friend auto operator<=>(const set_adaptor& left, const set_adaptor& right)
554  requires requires (const_reference ref) { std::tie(ref) <=> std::tie(ref); }
555  {
556  auto valueThreeComp = [] (const value_type& value1, const value_type& value2)
557  { return std::tie(value1) <=> std::tie(value2); };
558  return std::lexicographical_compare_three_way(left.begin(), left.end(),
559  right.begin(), right.end(), valueThreeComp);
560  }
561 #else
562  friend bool operator<(const set_adaptor& left, const set_adaptor& right)
563  {
564  return std::lexicographical_compare(left.begin(), left.end(), right.begin(), right.end());
565  }
566 #endif
567 
569 
570 private:
571  bool pvIsOrdered(const key_type& key1, const key_type& key2) const
572  {
573  const TreeTraits& treeTraits = mTreeSet.GetTreeTraits();
574  return TreeTraits::multiKey ? !treeTraits.IsLess(key2, key1)
575  : treeTraits.IsLess(key1, key2);
576  }
577 
578  bool pvCheckHint(const_iterator& hint, const key_type& key) const
579  {
580  if (hint != begin() && !pvIsOrdered(*std::prev(hint), key))
581  return false;
582  if (hint != end() && !pvIsOrdered(key, *hint))
583  {
585  hint = lower_bound(key);
586  return TreeTraits::multiKey;
587  }
588  return true;
589  }
590 
591  template<typename Iterator, typename Sentinel>
593  void> pvInsertRange(Iterator begin, Sentinel end)
594  {
595  mTreeSet.Insert(std::move(begin), std::move(end));
596  }
597 
598  template<typename Iterator, typename Sentinel>
600  void> pvInsertRange(Iterator begin, Sentinel end)
601  {
602  for (Iterator iter = std::move(begin); iter != end; ++iter)
603  emplace(*iter);
604  }
605 
606 private:
607  TreeSet mTreeSet;
608 };
609 
610 template<typename TTreeSet>
611 class multiset_adaptor : public set_adaptor<TTreeSet>
612 {
613 private:
615 
616 public:
617  using typename SetAdaptor::value_type;
618  using typename SetAdaptor::iterator;
619  using typename SetAdaptor::node_type;
620 
622 
623 public:
624  using SetAdaptor::SetAdaptor;
625 
626  multiset_adaptor& operator=(std::initializer_list<value_type> values)
627  {
628  SetAdaptor::operator=(values);
629  return *this;
630  }
631 
632  friend void swap(multiset_adaptor& left, multiset_adaptor& right) noexcept
633  {
634  left.swap(right);
635  }
636 
638 
640  {
641  return SetAdaptor::insert(std::move(value)).first;
642  }
643 
644  iterator insert(const value_type& value)
645  {
646  return SetAdaptor::insert(value).first;
647  }
648 
650  {
651  return SetAdaptor::insert(std::move(node)).position;
652  }
653 
654  template<typename... ValueArgs>
655  iterator emplace(ValueArgs&&... valueArgs)
656  {
657  return SetAdaptor::emplace(std::forward<ValueArgs>(valueArgs)...).first;
658  }
659 };
660 
685 template<typename TKey,
686  typename TLessComparer = std::less<TKey>,
687  typename TAllocator = std::allocator<TKey>>
688 class set : public set_adaptor<TreeSet<TKey,
689  TreeTraitsStd<TKey, TLessComparer>, MemManagerStd<TAllocator>>>
690 {
691 private:
692  typedef set_adaptor<momo::TreeSet<TKey,
694 
695 public:
696  using SetAdaptor::SetAdaptor;
697 
698  set& operator=(std::initializer_list<typename SetAdaptor::value_type> values)
699  {
700  SetAdaptor::operator=(values);
701  return *this;
702  }
703 
704  friend void swap(set& left, set& right) noexcept
705  {
706  left.swap(right);
707  }
708 };
709 
718 template<typename TKey,
719  typename TLessComparer = std::less<TKey>,
720  typename TAllocator = std::allocator<TKey>>
721 class multiset : public multiset_adaptor<TreeSet<TKey,
722  TreeTraitsStd<TKey, TLessComparer, true>, MemManagerStd<TAllocator>>>
723 {
724 private:
725  typedef multiset_adaptor<momo::TreeSet<TKey,
727 
728 public:
729  using MultiSetAdaptor::MultiSetAdaptor;
730 
731  multiset& operator=(std::initializer_list<typename MultiSetAdaptor::value_type> values)
732  {
734  return *this;
735  }
736 
737  friend void swap(multiset& left, multiset& right) noexcept
738  {
739  left.swap(right);
740  }
741 };
742 
743 #ifdef MOMO_HAS_DEDUCTION_GUIDES
744 
745 #define MOMO_DECLARE_DEDUCTION_GUIDES(set) \
746 template<typename Iterator, \
747  typename Key = typename std::iterator_traits<Iterator>::value_type, \
748  typename Allocator = std::allocator<Key>, \
749  typename = internal::tree_checker<Key, Allocator>> \
750 set(Iterator, Iterator, Allocator = Allocator()) \
751  -> set<Key, std::less<Key>, Allocator>; \
752 template<typename Iterator, typename LessComparer, \
753  typename Key = typename std::iterator_traits<Iterator>::value_type, \
754  typename Allocator = std::allocator<Key>, \
755  typename = internal::tree_checker<Key, Allocator, LessComparer>> \
756 set(Iterator, Iterator, LessComparer, Allocator = Allocator()) \
757  -> set<Key, LessComparer, Allocator>; \
758 template<typename Key, \
759  typename Allocator = std::allocator<Key>, \
760  typename = internal::tree_checker<Key, Allocator>> \
761 set(std::initializer_list<Key>, Allocator = Allocator()) \
762  -> set<Key, std::less<Key>, Allocator>; \
763 template<typename Key, typename LessComparer, \
764  typename Allocator = std::allocator<Key>, \
765  typename = internal::tree_checker<Key, Allocator, LessComparer>> \
766 set(std::initializer_list<Key>, LessComparer, Allocator = Allocator()) \
767  -> set<Key, LessComparer, Allocator>; \
768 template<typename Key, typename LessComparer, typename Allocator> \
769 set(set<Key, LessComparer, Allocator>, momo::internal::Identity<Allocator>) \
770  -> set<Key, LessComparer, Allocator>;
771 
772 MOMO_DECLARE_DEDUCTION_GUIDES(set)
773 MOMO_DECLARE_DEDUCTION_GUIDES(multiset)
774 
775 #undef MOMO_DECLARE_DEDUCTION_GUIDES
776 
777 #ifdef MOMO_HAS_CONTAINERS_RANGES
778 
779 #define MOMO_DECLARE_DEDUCTION_GUIDES_RANGES(set) \
780 template<std::ranges::input_range Range, \
781  typename Key = std::ranges::range_value_t<Range>, \
782  typename Allocator = std::allocator<Key>, \
783  typename = internal::tree_checker<Key, Allocator>> \
784 set(std::from_range_t, Range&&, Allocator = Allocator()) \
785  -> set<Key, std::less<Key>, Allocator>; \
786 template<std::ranges::input_range Range, typename LessComparer, \
787  typename Key = std::ranges::range_value_t<Range>, \
788  typename Allocator = std::allocator<Key>, \
789  typename = internal::tree_checker<Key, Allocator, LessComparer>> \
790 set(std::from_range_t, Range&&, LessComparer, Allocator = Allocator()) \
791  -> set<Key, LessComparer, Allocator>;
792 
793 MOMO_DECLARE_DEDUCTION_GUIDES_RANGES(set)
794 MOMO_DECLARE_DEDUCTION_GUIDES_RANGES(multiset)
795 
796 #undef MOMO_DECLARE_DEDUCTION_GUIDES_RANGES
797 
798 #endif // MOMO_HAS_CONTAINERS_RANGES
799 
800 #endif // MOMO_HAS_DEDUCTION_GUIDES
801 
802 } // namespace stdish
803 
804 } // namespace momo
805 
806 #endif // MOMO_INCLUDE_GUARD_STDISH_SET
momo::stdish::set_adaptor::const_reference
const_iterator::Reference const_reference
Definition: set.h:58
momo::internal::InsertResult::position
Position position
Definition: IteratorUtility.h:132
momo::stdish::set_adaptor::crend
const_reverse_iterator crend() const noexcept
Definition: set.h:256
MOMO_MORE_COMPARISON_OPERATORS
#define MOMO_MORE_COMPARISON_OPERATORS(RClass)
Definition: Utility.h:86
momo::stdish::multiset_adaptor::insert
iterator insert(const value_type &value)
Definition: set.h:644
momo::stdish::multiset_adaptor::insert
iterator insert(node_type &&node)
Definition: set.h:649
momo::stdish::set_adaptor::pointer
value_type * pointer
Definition: set.h:61
momo::stdish::set_adaptor::set_adaptor
set_adaptor(const allocator_type &alloc)
Definition: set.h:89
MOMO_DECLARE_PROXY_FUNCTION
#define MOMO_DECLARE_PROXY_FUNCTION(Class, Func)
Definition: Utility.h:116
momo::stdish::set_adaptor::count
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, size_type > count(const KeyArg &key) const
Definition: set.h:321
momo::internal::TreeSetConstIterator::Pointer
const Item * Pointer
Definition: TreeSet.h:42
momo::TreeTraits::IsLess
bool IsLess(const KeyArg1 &key1, const KeyArg2 &key2) const
Definition: TreeTraits.h:107
momo::stdish::set_adaptor::emplace_hint
momo::internal::EnableIf< std::is_same< key_type, typename std::decay< ValueArg >::type >::value, iterator > emplace_hint(const_iterator hint, ValueArg &&valueArg)
Definition: set.h:500
momo::stdish::set_adaptor::contains
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, bool > contains(const KeyArg &key) const
Definition: set.h:333
momo::stdish::set_adaptor::get_nested_container
nested_container_type & get_nested_container() noexcept
Definition: set.h:208
momo::stdish::set_adaptor::extract
node_type extract(const key_type &key)
Definition: set.h:535
momo::stdish::set_adaptor::equal_range
std::pair< const_iterator, const_iterator > equal_range(const key_type &key) const
Definition: set.h:374
momo::internal::TreeSetConstIterator::Reference
const Item & Reference
Definition: TreeSet.h:41
momo::stdish::set_adaptor::lower_bound
const_iterator lower_bound(const key_type &key) const
Definition: set.h:338
momo::stdish::set_adaptor::clear
void clear() noexcept
Definition: set.h:291
momo::stdish::set_adaptor::set_adaptor
set_adaptor(set_adaptor &&right, const allocator_type &alloc)
Definition: set.h:150
momo::stdish::set_adaptor::count
size_type count(const key_type &key) const
Definition: set.h:314
set_map_utility.h
momo::stdish::set_adaptor::size
size_type size() const noexcept
Definition: set.h:281
momo::stdish::multiset_adaptor::insert
iterator insert(value_type &&value)
Definition: set.h:639
momo::stdish::set_adaptor::emplace
std::pair< iterator, bool > emplace(ValueArgs &&... valueArgs)
Definition: set.h:467
momo::stdish::set_adaptor::reference
value_type & reference
Definition: set.h:57
momo::stdish::internal::insert_return_type
Definition: set_map_utility.h:202
momo::stdish::set_adaptor::reverse_iterator
std::reverse_iterator< iterator > reverse_iterator
Definition: set.h:66
momo::stdish::set_adaptor::operator==
friend bool operator==(const set_adaptor &left, const set_adaptor &right)
Definition: set.h:547
momo::stdish::set_adaptor::node_type
internal::set_node_handle< typename TreeSet::ExtractedItem > node_type
Definition: set.h:69
momo::stdish::set_adaptor::cend
const_iterator cend() const noexcept
Definition: set.h:246
momo::stdish::set_adaptor::equal_range
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, std::pair< const_iterator, const_iterator > > equal_range(const KeyArg &key) const
Definition: set.h:393
momo::stdish::set_adaptor::emplace_hint
iterator emplace_hint(const_iterator hint, ValueArgs &&... valueArgs)
Definition: set.h:487
momo::stdish::set
momo::stdish::set is similar to std::set, but much more efficient in memory usage....
Definition: set.h:690
momo::stdish::set_adaptor::set_adaptor
set_adaptor(std::initializer_list< value_type > values, const key_compare &lessComp, const allocator_type &alloc=allocator_type())
Definition: set.h:120
momo::MemManagerStd
MemManagerStd uses allocator<unsigned char>::allocate and deallocate
Definition: MemManager.h:179
momo::TreeTraits
Definition: TreeTraits.h:82
momo::internal::SetExtractedItem::GetItem
const Item & GetItem() const
Definition: SetUtility.h:309
momo::stdish::multiset_adaptor::insert_return_type
iterator insert_return_type
Definition: set.h:621
momo::stdish::set_adaptor::set_adaptor
set_adaptor(std::initializer_list< value_type > values, const allocator_type &alloc=allocator_type())
Definition: set.h:114
momo::internal::ContainerAssignerStd::Move
static Container & Move(Container &&srcCont, Container &dstCont) noexcept(IsNothrowMoveAssignable< Container >::value)
Definition: Utility.h:515
momo::stdish::multiset_adaptor::swap
friend void swap(multiset_adaptor &left, multiset_adaptor &right) noexcept
Definition: set.h:632
momo::internal::InsertResult
Definition: IteratorUtility.h:100
momo::stdish::multiset_adaptor::emplace
iterator emplace(ValueArgs &&... valueArgs)
Definition: set.h:655
momo::stdish::multiset
momo::stdish::multiset is similar to std::multiset, but much more efficient in memory usage....
Definition: set.h:723
momo::TreeSetCore::TreeTraits
TTreeTraits TreeTraits
Definition: TreeSet.h:300
momo::stdish::set_adaptor::find
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, const_iterator > find(const KeyArg &key) const
Definition: set.h:305
momo::stdish::multiset::operator=
multiset & operator=(std::initializer_list< typename MultiSetAdaptor::value_type > values)
Definition: set.h:731
momo::stdish::set_adaptor::erase
iterator erase(const_iterator where)
Definition: set.h:507
momo::stdish::set_adaptor::size_type
size_t size_type
Definition: set.h:45
momo::internal::EnableIf
typename std::enable_if< value, Type >::type EnableIf
Definition: Utility.h:199
momo::stdish::set_adaptor::value_compare
key_compare value_compare
Definition: set.h:49
momo::stdish::set_adaptor::swap
void swap(set_adaptor &right) noexcept
Definition: set.h:193
momo
Definition: Array.h:27
momo::stdish::set_adaptor::get_allocator
allocator_type get_allocator() const noexcept
Definition: set.h:271
momo::stdish::multiset::swap
friend void swap(multiset &left, multiset &right) noexcept
Definition: set.h:737
momo::internal::ContainerAssignerStd::IsNothrowMoveAssignable
BoolConstant< std::is_empty< Allocator >::value||std::allocator_traits< Allocator >::propagate_on_container_move_assignment::value > IsNothrowMoveAssignable
Definition: Utility.h:511
momo::stdish::set_adaptor::crbegin
const_reverse_iterator crbegin() const noexcept
Definition: set.h:251
momo::stdish::set_adaptor::key_compare
TreeTraits::LessComparer key_compare
Definition: set.h:41
momo::internal::InsertResult::inserted
bool inserted
Definition: IteratorUtility.h:135
momo::TreeTraitsStd
Definition: TreeTraits.h:124
momo::stdish::set_adaptor::insert
insert_return_type insert(node_type &&node)
Definition: set.h:428
momo::stdish::set_adaptor::find
const_iterator find(const key_type &key) const
Definition: set.h:296
momo::stdish::set_adaptor::cbegin
const_iterator cbegin() const noexcept
Definition: set.h:241
momo::stdish::set_adaptor::insert
iterator insert(const_iterator hint, value_type &&value)
Definition: set.h:408
momo::stdish::set_adaptor::insert_return_type
internal::insert_return_type< iterator, node_type > insert_return_type
Definition: set.h:70
momo::stdish::set_adaptor::erase_if
friend size_type erase_if(set_adaptor &cont, const ValueFilter &valueFilter)
Definition: set.h:525
momo::stdish::set_adaptor::operator<
friend bool operator<(const set_adaptor &left, const set_adaptor &right)
Definition: set.h:562
momo::stdish::set_adaptor::swap
friend void swap(set_adaptor &left, set_adaptor &right) noexcept
Definition: set.h:198
momo::stdish::set_adaptor::const_iterator
TreeSet::ConstIterator const_iterator
Definition: set.h:53
momo::stdish::set_adaptor::value_type
key_type value_type
Definition: set.h:48
momo::stdish::set_adaptor::insert
void insert(Iterator first, Iterator last)
Definition: set.h:447
momo::stdish::set_adaptor::contains
bool contains(const key_type &key) const
Definition: set.h:326
momo::stdish::set_adaptor::key_comp
key_compare key_comp() const
Definition: set.h:261
momo::stdish::set_adaptor::~set_adaptor
~set_adaptor()=default
momo::stdish::set_adaptor::erase
size_type erase(const key_type &key)
Definition: set.h:519
momo::stdish::set_adaptor::iterator
TreeSet::Iterator iterator
Definition: set.h:54
momo::stdish::multiset_adaptor::operator=
multiset_adaptor & operator=(std::initializer_list< value_type > values)
Definition: set.h:626
MOMO_CONSTEXPR_IF
#define MOMO_CONSTEXPR_IF
Definition: UserSettings.h:228
momo::stdish::set_adaptor::insert
std::pair< iterator, bool > insert(const value_type &value)
Definition: set.h:415
std
Definition: Array.h:1178
momo::stdish::set_adaptor::set_adaptor
set_adaptor(Iterator first, Iterator last, const key_compare &lessComp, const allocator_type &alloc=allocator_type())
Definition: set.h:107
momo::stdish::set_adaptor::rend
const_reverse_iterator rend() const noexcept
Definition: set.h:234
momo::stdish::set_adaptor::difference_type
ptrdiff_t difference_type
Definition: set.h:46
momo::internal::SetExtractedItem::Create
void Create(ItemCreator &&itemCreator)
Definition: SetUtility.h:322
momo::stdish::set_adaptor::insert
iterator insert(const_iterator hint, const value_type &value)
Definition: set.h:421
momo::stdish::multiset_adaptor
Definition: set.h:612
momo::stdish::set_adaptor::rbegin
const_reverse_iterator rbegin() const noexcept
Definition: set.h:227
momo::stdish::set_adaptor::upper_bound
const_iterator upper_bound(const key_type &key) const
Definition: set.h:356
momo::stdish::set_adaptor::set_adaptor
set_adaptor(const key_compare &lessComp, const allocator_type &alloc=allocator_type())
Definition: set.h:94
momo::stdish::set_adaptor::insert
iterator insert(const_iterator hint, node_type &&node)
Definition: set.h:437
momo::stdish::set_adaptor::set_adaptor
set_adaptor(Iterator first, Iterator last, const allocator_type &alloc=allocator_type())
Definition: set.h:100
momo::stdish::set_adaptor::lower_bound
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, const_iterator > lower_bound(const KeyArg &key) const
Definition: set.h:347
momo::stdish::set_adaptor::empty
MOMO_NODISCARD bool empty() const noexcept
Definition: set.h:286
momo::TreeSetCore::MemManager
ItemTraits::MemManager MemManager
Definition: TreeSet.h:304
momo::stdish::set_adaptor::set_adaptor
set_adaptor(const set_adaptor &right, const allocator_type &alloc)
Definition: set.h:169
momo::stdish::set_adaptor::emplace
momo::internal::EnableIf< std::is_same< key_type, typename std::decay< ValueArg >::type >::value, std::pair< iterator, bool > > emplace(ValueArg &&valueArg)
Definition: set.h:479
momo::stdish::set_adaptor::merge
void merge(Set &&set_adaptor)
Definition: set.h:542
momo::stdish::set_adaptor::allocator_type
std::allocator_traits< typename MemManager::ByteAllocator >::template rebind_alloc< value_type > allocator_type
Definition: set.h:51
momo::stdish::set::swap
friend void swap(set &left, set &right) noexcept
Definition: set.h:704
momo::stdish::set_adaptor::const_reverse_iterator
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: set.h:67
momo::stdish::set_adaptor::insert
std::pair< iterator, bool > insert(value_type &&value)
Definition: set.h:402
momo::stdish::set_adaptor::upper_bound
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, const_iterator > upper_bound(const KeyArg &key) const
Definition: set.h:365
momo::stdish::internal::set_node_handle
Definition: set_map_utility.h:42
momo::stdish::set_adaptor::set_adaptor
set_adaptor(const set_adaptor &right)
Definition: set.h:164
momo::stdish::set_adaptor::set_adaptor
set_adaptor(set_adaptor &&right)
Definition: set.h:145
momo::stdish::set::operator=
set & operator=(std::initializer_list< typename SetAdaptor::value_type > values)
Definition: set.h:698
momo::stdish::set_adaptor::operator=
set_adaptor & operator=(const set_adaptor &right)
Definition: set.h:182
momo::TreeSetCore::Key
ItemTraits::Key Key
Definition: TreeSet.h:302
momo::stdish::set_adaptor::nested_container_type
TreeSet nested_container_type
Definition: set.h:43
momo::internal::TreeSetConstIterator
Definition: TreeSet.h:34
momo::stdish::set_adaptor::set_adaptor
set_adaptor()
Definition: set.h:85
momo::stdish::set_adaptor::operator=
set_adaptor & operator=(set_adaptor &&right) noexcept(momo::internal::ContainerAssignerStd::IsNothrowMoveAssignable< set_adaptor >::value)
Definition: set.h:176
momo::internal::ContainerAssignerStd::Copy
static Container & Copy(const Container &srcCont, Container &dstCont)
Definition: Utility.h:531
momo::TreeTraits::multiKey
static const bool multiKey
Definition: TreeTraits.h:87
momo::stdish::set_adaptor::operator=
set_adaptor & operator=(std::initializer_list< value_type > values)
Definition: set.h:187
momo::stdish::set_adaptor
Definition: set.h:33
momo::stdish::set_adaptor::key_type
TreeSet::Key key_type
Definition: set.h:40
momo::stdish::set_adaptor::max_size
size_type max_size() const noexcept
Definition: set.h:276
momo::TreeSetCore
Definition: TreeSet.h:297
momo::stdish::set_adaptor::get_nested_container
const nested_container_type & get_nested_container() const noexcept
Definition: set.h:203
momo::internal::SetExtractedItem
Definition: SetUtility.h:257
momo::internal::ContainerAssignerStd::Swap
static void Swap(Container &cont1, Container &cont2) noexcept
Definition: Utility.h:546
momo::stdish::set_adaptor::const_pointer
const_iterator::Pointer const_pointer
Definition: set.h:62
momo::stdish::set_adaptor::erase
iterator erase(const_iterator first, const_iterator last)
Definition: set.h:514
momo::TreeSet
TreeSetCore< TreeSetItemTraits< TKey, TMemManager >, TTreeTraits > TreeSet
Definition: TreeSet.h:1726
MOMO_NODISCARD
#define MOMO_NODISCARD
Definition: UserSettings.h:262
momo::stdish::set_adaptor::insert
void insert(std::initializer_list< value_type > values)
Definition: set.h:452
momo::stdish::set_adaptor::value_comp
value_compare value_comp() const
Definition: set.h:266
momo::stdish::set_adaptor::end
const_iterator end() const noexcept
Definition: set.h:220
momo::stdish::set_adaptor::begin
const_iterator begin() const noexcept
Definition: set.h:213
momo::stdish::set_adaptor::extract
node_type extract(const_iterator where)
Definition: set.h:530