momo  3.9
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
13  class multiset
14 
15 \**********************************************************/
16 
17 #ifndef MOMO_INCLUDE_GUARD_STDISH_SET
18 #define MOMO_INCLUDE_GUARD_STDISH_SET
19 
20 #include "../TreeSet.h"
21 #include "node_handle.h"
22 
23 namespace momo
24 {
25 
26 namespace stdish
27 {
28 
53 template<typename TKey,
54  typename TLessFunc = std::less<TKey>,
55  typename TAllocator = std::allocator<TKey>,
56  typename TTreeSet = TreeSet<TKey, TreeTraitsStd<TKey, TLessFunc>, MemManagerStd<TAllocator>>>
57 class set
58 {
59 private:
60  typedef TTreeSet TreeSet;
61  typedef typename TreeSet::TreeTraits TreeTraits;
62  typedef typename TreeSet::MemManager MemManager;
63 
64 public:
65  typedef TKey key_type;
66  typedef TLessFunc key_compare;
67  typedef TAllocator allocator_type;
68 
69  typedef TreeSet nested_container_type;
70 
71  typedef size_t size_type;
72  typedef ptrdiff_t difference_type;
73 
76 
78  typedef typename TreeSet::Iterator iterator;
79 
80  //typedef typename iterator::Reference reference;
83 
84  //typedef typename iterator::Pointer pointer;
85  typedef value_type* pointer;
87  //typedef typename std::allocator_traits<allocator_type>::pointer pointer;
88  //typedef typename std::allocator_traits<allocator_type>::const_pointer const_pointer;
89 
90  typedef std::reverse_iterator<iterator> reverse_iterator;
91  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
92 
95 
96 private:
97  template<typename KeyArg>
98  struct IsValidKeyArg : public TreeTraits::template IsValidKeyArg<KeyArg>
99  {
100  };
101 
102  struct NodeTypeProxy : private node_type
103  {
104  typedef node_type NodeType;
105  MOMO_DECLARE_PROXY_FUNCTION(NodeType, GetExtractedItem,
106  typename NodeType::SetExtractedItem&)
107  };
108 
109 public:
110  set()
111  {
112  }
113 
114  explicit set(const allocator_type& alloc)
115  : mTreeSet(TreeTraits(), MemManager(alloc))
116  {
117  }
118 
119  explicit set(const key_compare& lessFunc, const allocator_type& alloc = allocator_type())
120  : mTreeSet(TreeTraits(lessFunc), MemManager(alloc))
121  {
122  }
123 
124  template<typename Iterator>
125  set(Iterator first, Iterator last, const allocator_type& alloc = allocator_type())
126  : set(alloc)
127  {
128  insert(first, last);
129  }
130 
131  template<typename Iterator>
132  set(Iterator first, Iterator last, const key_compare& lessFunc,
133  const allocator_type& alloc = allocator_type())
134  : set(lessFunc, alloc)
135  {
136  insert(first, last);
137  }
138 
139  set(std::initializer_list<value_type> values, const allocator_type& alloc = allocator_type())
140  : mTreeSet(values, TreeTraits(), MemManager(alloc))
141  {
142  }
143 
144  set(std::initializer_list<value_type> values, const key_compare& lessFunc,
145  const allocator_type& alloc = allocator_type())
146  : mTreeSet(values, TreeTraits(lessFunc), MemManager(alloc))
147  {
148  }
149 
150  set(set&& right) noexcept
151  : mTreeSet(std::move(right.mTreeSet))
152  {
153  }
154 
156  noexcept(std::is_empty<allocator_type>::value)
157  : mTreeSet(pvCreateSet(std::move(right), alloc))
158  {
159  }
160 
161  set(const set& right)
162  : mTreeSet(right.mTreeSet)
163  {
164  }
165 
167  : mTreeSet(right.mTreeSet, MemManager(alloc))
168  {
169  }
170 
171  ~set() = default;
172 
173  set& operator=(set&& right)
174  noexcept(std::is_empty<allocator_type>::value ||
175  std::allocator_traits<allocator_type>::propagate_on_container_move_assignment::value)
176  {
177  if (this != &right)
178  {
179  bool propagate = std::is_empty<allocator_type>::value ||
180  std::allocator_traits<allocator_type>::propagate_on_container_move_assignment::value;
181  allocator_type alloc = (propagate ? &right : this)->get_allocator();
182  mTreeSet = pvCreateSet(std::move(right), alloc);
183  }
184  return *this;
185  }
186 
187  set& operator=(const set& right)
188  {
189  if (this != &right)
190  {
191  bool propagate = std::is_empty<allocator_type>::value ||
192  std::allocator_traits<allocator_type>::propagate_on_container_copy_assignment::value;
193  allocator_type alloc = (propagate ? &right : this)->get_allocator();
194  mTreeSet = TreeSet(right.mTreeSet, MemManager(alloc));
195  }
196  return *this;
197  }
198 
199  set& operator=(std::initializer_list<value_type> values)
200  {
201  mTreeSet = TreeSet(values, mTreeSet.GetTreeTraits(), MemManager(get_allocator()));
202  return *this;
203  }
204 
205  void swap(set& right) noexcept
206  {
207  MOMO_ASSERT(std::allocator_traits<allocator_type>::propagate_on_container_swap::value
208  || get_allocator() == right.get_allocator());
209  mTreeSet.Swap(right.mTreeSet);
210  }
211 
212  friend void swap(set& left, set& right) noexcept
213  {
214  left.swap(right);
215  }
216 
218  {
219  return mTreeSet;
220  }
221 
223  {
224  return mTreeSet;
225  }
226 
227  const_iterator begin() const noexcept
228  {
229  return mTreeSet.GetBegin();
230  }
231 
232  //iterator begin() noexcept
233 
234  const_iterator end() const noexcept
235  {
236  return mTreeSet.GetEnd();
237  }
238 
239  //iterator end() noexcept
240 
242  {
243  return const_reverse_iterator(end());
244  }
245 
246  //reverse_iterator rbegin() noexcept
247 
248  const_reverse_iterator rend() const noexcept
249  {
250  return const_reverse_iterator(begin());
251  }
252 
253  //reverse_iterator rend() noexcept
254 
255  const_iterator cbegin() const noexcept
256  {
257  return begin();
258  }
259 
260  const_iterator cend() const noexcept
261  {
262  return end();
263  }
264 
266  {
267  return rbegin();
268  }
269 
270  const_reverse_iterator crend() const noexcept
271  {
272  return rend();
273  }
274 
276  {
277  return mTreeSet.GetTreeTraits().GetLessFunc();
278  }
279 
281  {
282  return key_comp();
283  }
284 
285  allocator_type get_allocator() const noexcept
286  {
287  return allocator_type(mTreeSet.GetMemManager().GetByteAllocator());
288  }
289 
290  size_type max_size() const noexcept
291  {
292  return std::allocator_traits<allocator_type>::max_size(get_allocator());
293  }
294 
295  size_type size() const noexcept
296  {
297  return mTreeSet.GetCount();
298  }
299 
300  MOMO_NODISCARD bool empty() const noexcept
301  {
302  return mTreeSet.IsEmpty();
303  }
304 
305  void clear() noexcept
306  {
307  mTreeSet.Clear();
308  }
309 
310  const_iterator find(const key_type& key) const
311  {
312  return mTreeSet.Find(key);
313  }
314 
315  //iterator find(const key_type& key)
316 
317  template<typename KeyArg>
319  const_iterator> find(const KeyArg& key) const
320  {
321  return mTreeSet.Find(key);
322  }
323 
324  //template<typename KeyArg>
325  //momo::internal::EnableIf<IsValidKeyArg<KeyArg>::value,
326  //iterator> find(const KeyArg& key)
327 
328  size_type count(const key_type& key) const
329  {
330  return mTreeSet.GetKeyCount(key);
331  }
332 
333  template<typename KeyArg>
335  size_type> count(const KeyArg& key) const
336  {
337  return mTreeSet.GetKeyCount(key);
338  }
339 
340  bool contains(const key_type& key) const
341  {
342  return mTreeSet.ContainsKey(key);
343  }
344 
345  template<typename KeyArg>
347  bool> contains(const KeyArg& key) const
348  {
349  return mTreeSet.ContainsKey(key);
350  }
351 
353  {
354  return mTreeSet.GetLowerBound(key);
355  }
356 
357  //iterator lower_bound(const key_type& key)
358 
359  template<typename KeyArg>
361  const_iterator> lower_bound(const KeyArg& key) const
362  {
363  return mTreeSet.GetLowerBound(key);
364  }
365 
366  //template<typename KeyArg>
367  //momo::internal::EnableIf<IsValidKeyArg<KeyArg>::value,
368  //iterator> lower_bound(const KeyArg& key)
369 
371  {
372  return mTreeSet.GetUpperBound(key);
373  }
374 
375  //iterator upper_bound(const key_type& key)
376 
377  template<typename KeyArg>
379  const_iterator> upper_bound(const KeyArg& key) const
380  {
381  return mTreeSet.GetUpperBound(key);
382  }
383 
384  //template<typename KeyArg>
385  //momo::internal::EnableIf<IsValidKeyArg<KeyArg>::value,
386  //iterator> upper_bound(const KeyArg& key)
387 
388  std::pair<const_iterator, const_iterator> equal_range(const key_type& key) const
389  {
390  const_iterator iter = lower_bound(key);
392  return { iter, upper_bound(key) };
393  if (iter == end() || mTreeSet.GetTreeTraits().IsLess(key, *iter))
394  return { iter, iter };
395  return { iter, std::next(iter) };
396  }
397 
398  //std::pair<iterator, iterator> equal_range(const key_type& key)
399 
400  template<typename KeyArg>
402  std::pair<const_iterator, const_iterator>> equal_range(const KeyArg& key) const
403  {
404  return { lower_bound(key), upper_bound(key) };
405  }
406 
407  //template<typename KeyArg>
408  //momo::internal::EnableIf<IsValidKeyArg<KeyArg>::value,
409  //std::pair<iterator, iterator>> equal_range(const KeyArg& key)
410 
411  std::pair<iterator, bool> insert(value_type&& value)
412  {
413  typename TreeSet::InsertResult res = mTreeSet.Insert(std::move(value));
414  return { res.position, res.inserted };
415  }
416 
418  {
419  if (!pvCheckHint(hint, static_cast<const key_type&>(value)))
420  return insert(std::move(value)).first;
421  return mTreeSet.Add(hint, std::move(value));
422  }
423 
424  std::pair<iterator, bool> insert(const value_type& value)
425  {
426  typename TreeSet::InsertResult res = mTreeSet.Insert(value);
427  return { res.position, res.inserted };
428  }
429 
431  {
432  if (!pvCheckHint(hint, value))
433  return insert(value).first;
434  return mTreeSet.Add(hint, value);
435  }
436 
438  {
439  if (node.empty())
440  return { end(), false, node_type() };
441  typename TreeSet::InsertResult res = mTreeSet.Insert(
442  std::move(NodeTypeProxy::GetExtractedItem(node)));
443  return { res.position, res.inserted, res.inserted ? node_type() : std::move(node) };
444  }
445 
447  {
448  if (node.empty())
449  return end();
450  if (!pvCheckHint(hint, node.value()))
451  return insert(std::move(node)).position;
452  return mTreeSet.Add(hint, std::move(NodeTypeProxy::GetExtractedItem(node)));
453  }
454 
455  template<typename Iterator>
456  void insert(Iterator first, Iterator last)
457  {
459  }
460 
461  void insert(std::initializer_list<value_type> values)
462  {
463  mTreeSet.Insert(values);
464  }
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& 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)
543  {
544  mTreeSet.MergeFrom(set.get_nested_container());
545  }
546 
547  bool operator==(const set& right) const
548  {
549  return size() == right.size() && std::equal(begin(), end(), right.begin());
550  }
551 
552  bool operator!=(const set& right) const
553  {
554  return !(*this == right);
555  }
556 
557 #ifdef MOMO_HAS_THREE_WAY_COMPARISON
558  auto operator<=>(const set& right) const
559  requires requires (const_reference ref) { std::tie(ref) <=> std::tie(ref); }
560  {
561  auto comp = [] (const value_type& value1, const value_type& value2)
562  { return std::tie(value1) <=> std::tie(value2); };
563  return std::lexicographical_compare_three_way(begin(), end(),
564  right.begin(), right.end(), comp);
565  }
566 #else
567  bool operator<(const set& right) const
568  {
569  return std::lexicographical_compare(begin(), end(), right.begin(), right.end());
570  }
571 
572  bool operator>(const set& right) const
573  {
574  return right < *this;
575  }
576 
577  bool operator<=(const set& right) const
578  {
579  return !(right < *this);
580  }
581 
582  bool operator>=(const set& right) const
583  {
584  return right <= *this;
585  }
586 #endif
587 
588 private:
589  static TreeSet pvCreateSet(set&& right, const allocator_type& alloc)
590  {
591  if (right.get_allocator() == alloc)
592  return std::move(right.mTreeSet);
593  TreeSet treeSet(right.mTreeSet.GetTreeTraits(), MemManager(alloc));
594  treeSet.MergeFrom(right.mTreeSet);
595  return treeSet;
596  }
597 
598  bool pvIsOrdered(const key_type& key1, const key_type& key2) const
599  {
600  const TreeTraits& treeTraits = mTreeSet.GetTreeTraits();
601  return TreeTraits::multiKey ? !treeTraits.IsLess(key2, key1)
602  : treeTraits.IsLess(key1, key2);
603  }
604 
605  bool pvCheckHint(const_iterator& hint, const key_type& key) const
606  {
607  if (hint != begin() && !pvIsOrdered(*std::prev(hint), key))
608  return false;
609  if (hint != end() && !pvIsOrdered(key, *hint))
610  {
612  hint = lower_bound(key);
613  return TreeTraits::multiKey;
614  }
615  return true;
616  }
617 
618  template<typename Iterator>
619  void pvInsert(Iterator first, Iterator last, std::true_type /*isSetArgIterator*/)
620  {
621  mTreeSet.Insert(first, last);
622  }
623 
624  template<typename Iterator>
625  void pvInsert(Iterator first, Iterator last, std::false_type /*isSetArgIterator*/)
626  {
627  for (Iterator iter = first; iter != last; ++iter)
628  emplace(*iter);
629  }
630 
631 private:
632  TreeSet mTreeSet;
633 };
634 
643 template<typename TKey,
644  typename TLessFunc = std::less<TKey>,
645  typename TAllocator = std::allocator<TKey>,
646  typename TTreeSet = TreeSet<TKey, TreeTraitsStd<TKey, TLessFunc, true>,
647  MemManagerStd<TAllocator>>>
648 class multiset : public set<TKey, TLessFunc, TAllocator, TTreeSet>
649 {
650 private:
652 
653 public:
654  using typename Set::size_type;
655  using typename Set::value_type;
656  using typename Set::iterator;
657  using typename Set::node_type;
658 
660 
661 public:
662  using Set::Set;
663 
664  multiset& operator=(std::initializer_list<value_type> values)
665  {
666  Set::operator=(values);
667  return *this;
668  }
669 
670  friend void swap(multiset& left, multiset& right) noexcept
671  {
672  left.swap(right);
673  }
674 
675  using Set::insert;
676 
678  {
679  return Set::insert(std::move(value)).first;
680  }
681 
682  iterator insert(const value_type& value)
683  {
684  return Set::insert(value).first;
685  }
686 
688  {
689  return Set::insert(std::move(node)).position;
690  }
691 
692  template<typename... ValueArgs>
693  iterator emplace(ValueArgs&&... valueArgs)
694  {
695  return Set::emplace(std::forward<ValueArgs>(valueArgs)...).first;
696  }
697 
698  template<typename ValueFilter>
699  friend size_type erase_if(multiset& cont, const ValueFilter& valueFilter)
700  {
701  return cont.get_nested_container().Remove(valueFilter);
702  }
703 };
704 
705 #ifdef MOMO_HAS_DEDUCTION_GUIDES
706 
707 #define MOMO_DECLARE_DEDUCTION_GUIDES(set) \
708 template<typename Iterator, \
709  typename Key = typename std::iterator_traits<Iterator>::value_type, \
710  typename Allocator = std::allocator<Key>, \
711  typename = decltype(std::declval<Allocator&>().allocate(size_t{}))> \
712 set(Iterator, Iterator, Allocator = Allocator()) \
713  -> set<Key, std::less<Key>, Allocator>; \
714 template<typename Iterator, typename LessFunc, \
715  typename Key = typename std::iterator_traits<Iterator>::value_type, \
716  typename Allocator = std::allocator<Key>, \
717  typename = decltype(std::declval<LessFunc&>()(std::declval<const Key&>(), std::declval<const Key&>()))> \
718 set(Iterator, Iterator, LessFunc, Allocator = Allocator()) \
719  -> set<Key, LessFunc, Allocator>; \
720 template<typename Key, \
721  typename Allocator = std::allocator<Key>, \
722  typename = decltype(std::declval<Allocator&>().allocate(size_t{}))> \
723 set(std::initializer_list<Key>, Allocator = Allocator()) \
724  -> set<Key, std::less<Key>, Allocator>; \
725 template<typename Key, typename LessFunc, \
726  typename Allocator = std::allocator<Key>, \
727  typename = decltype(std::declval<LessFunc&>()(std::declval<const Key&>(), std::declval<const Key&>()))> \
728 set(std::initializer_list<Key>, LessFunc, Allocator = Allocator()) \
729  -> set<Key, LessFunc, Allocator>;
730 
731 MOMO_DECLARE_DEDUCTION_GUIDES(set)
732 MOMO_DECLARE_DEDUCTION_GUIDES(multiset)
733 
734 #undef MOMO_DECLARE_DEDUCTION_GUIDES
735 
736 #endif // MOMO_HAS_DEDUCTION_GUIDES
737 
738 } // namespace stdish
739 
740 } // namespace momo
741 
742 #endif // MOMO_INCLUDE_GUARD_STDISH_SET
momo::stdish::set::crbegin
const_reverse_iterator crbegin() const noexcept
Definition: set.h:265
momo::internal::InsertResult::position
Position position
Definition: IteratorUtility.h:183
momo::stdish::set::get_allocator
allocator_type get_allocator() const noexcept
Definition: set.h:285
momo::internal::TreeSetConstIterator::Pointer
const Item * Pointer
Definition: TreeSet.h:41
momo::stdish::set::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::TreeTraits::IsLess
bool IsLess(const KeyArg1 &key1, const KeyArg2 &key2) const
Definition: TreeTraits.h:107
momo::stdish::set::contains
bool contains(const key_type &key) const
Definition: set.h:340
momo::stdish::set::find
const_iterator find(const key_type &key) const
Definition: set.h:310
momo::stdish::set::difference_type
ptrdiff_t difference_type
Definition: set.h:72
momo::internal::TreeSetConstIterator::Reference
const Item & Reference
Definition: TreeSet.h:40
momo::stdish::set::crend
const_reverse_iterator crend() const noexcept
Definition: set.h:270
momo::stdish::multiset::operator=
multiset & operator=(std::initializer_list< value_type > values)
Definition: set.h:664
momo::stdish::set::upper_bound
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, const_iterator > upper_bound(const KeyArg &key) const
Definition: set.h:379
momo::stdish::set::empty
MOMO_NODISCARD bool empty() const noexcept
Definition: set.h:300
momo::stdish::set::equal_range
std::pair< const_iterator, const_iterator > equal_range(const key_type &key) const
Definition: set.h:388
momo::stdish::multiset::insert
iterator insert(node_type &&node)
Definition: set.h:687
momo::stdish::set::extract
node_type extract(const_iterator where)
Definition: set.h:530
momo::stdish::set::emplace_hint
iterator emplace_hint(const_iterator hint, ValueArgs &&... valueArgs)
Definition: set.h:487
momo::stdish::internal::insert_return_type
Definition: node_handle.h:190
momo::stdish::set::value_compare
key_compare value_compare
Definition: set.h:75
momo::stdish::set::clear
void clear() noexcept
Definition: set.h:305
momo::stdish::set::pointer
value_type * pointer
Definition: set.h:85
momo::stdish::set::size_type
size_t size_type
Definition: set.h:71
momo::stdish::set::value_type
key_type value_type
Definition: set.h:74
momo::stdish::set::reference
value_type & reference
Definition: set.h:81
momo::stdish::set::begin
const_iterator begin() const noexcept
Definition: set.h:227
momo::stdish::set
momo::stdish::set is similar to std::set, but much more efficient in memory usage....
Definition: set.h:58
momo::stdish::set::merge
void merge(Set &&set)
Definition: set.h:542
momo::TreeTraits
Definition: TreeTraits.h:82
momo::stdish::set::set
set(std::initializer_list< value_type > values, const key_compare &lessFunc, const allocator_type &alloc=allocator_type())
Definition: set.h:144
momo::internal::SetExtractedItem::GetItem
const Item & GetItem() const
Definition: SetUtility.h:307
momo::stdish::set::operator=
set & operator=(std::initializer_list< value_type > values)
Definition: set.h:199
momo::stdish::set::count
size_type count(const key_type &key) const
Definition: set.h:328
momo::internal::InsertResult
Definition: IteratorUtility.h:151
momo::stdish::set::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::set
set(Iterator first, Iterator last, const allocator_type &alloc=allocator_type())
Definition: set.h:125
momo::stdish::set::operator<=
bool operator<=(const set &right) const
Definition: set.h:577
momo::stdish::multiset::emplace
iterator emplace(ValueArgs &&... valueArgs)
Definition: set.h:693
momo::stdish::multiset
momo::stdish::multiset is similar to std::multiset, but much more efficient in memory usage....
Definition: set.h:649
momo::stdish::set::get_nested_container
nested_container_type & get_nested_container() noexcept
Definition: set.h:222
momo::stdish::set::set
set(const set &right, const momo::internal::Identity< allocator_type > &alloc)
Definition: set.h:166
momo::stdish::multiset::erase_if
friend size_type erase_if(multiset &cont, const ValueFilter &valueFilter)
Definition: set.h:699
momo::stdish::set::set
set(const set &right)
Definition: set.h:161
momo::internal::EnableIf
typename std::enable_if< value, Type >::type EnableIf
Definition: Utility.h:174
momo::stdish::set::set
set(std::initializer_list< value_type > values, const allocator_type &alloc=allocator_type())
Definition: set.h:139
momo::stdish::set::set
set(const key_compare &lessFunc, const allocator_type &alloc=allocator_type())
Definition: set.h:119
momo::stdish::multiset::insert_return_type
iterator insert_return_type
Definition: set.h:659
momo
Definition: Array.h:26
momo::stdish::set::key_comp
key_compare key_comp() const
Definition: set.h:275
momo::stdish::multiset::swap
friend void swap(multiset &left, multiset &right) noexcept
Definition: set.h:670
momo::stdish::set::key_type
TKey key_type
Definition: set.h:65
momo::stdish::set::allocator_type
TAllocator allocator_type
Definition: set.h:67
momo::stdish::set::const_reference
const_iterator::Reference const_reference
Definition: set.h:82
momo::stdish::set::get_nested_container
const nested_container_type & get_nested_container() const noexcept
Definition: set.h:217
momo::internal::InsertResult::inserted
bool inserted
Definition: IteratorUtility.h:186
momo::internal::Identity
EnableIf< true, Type > Identity
Definition: Utility.h:177
momo::stdish::set::size
size_type size() const noexcept
Definition: set.h:295
momo::stdish::set::nested_container_type
TreeSet nested_container_type
Definition: set.h:69
momo::stdish::set::operator=
set & operator=(set &&right) noexcept(std::is_empty< allocator_type >::value||std::allocator_traits< allocator_type >::propagate_on_container_move_assignment::value)
Definition: set.h:173
momo::stdish::set::lower_bound
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, const_iterator > lower_bound(const KeyArg &key) const
Definition: set.h:361
momo::stdish::set::cend
const_iterator cend() const noexcept
Definition: set.h:260
momo::stdish::set::set
set(const allocator_type &alloc)
Definition: set.h:114
momo::stdish::set::upper_bound
const_iterator upper_bound(const key_type &key) const
Definition: set.h:370
momo::stdish::set::count
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, size_type > count(const KeyArg &key) const
Definition: set.h:335
momo::stdish::set::value_comp
value_compare value_comp() const
Definition: set.h:280
momo::stdish::set::extract
node_type extract(const key_type &key)
Definition: set.h:535
momo::stdish::internal::set_node_handle::SetExtractedItem
TSetExtractedItem SetExtractedItem
Definition: node_handle.h:31
momo::stdish::set::emplace
std::pair< iterator, bool > emplace(ValueArgs &&... valueArgs)
Definition: set.h:467
momo::stdish::set::operator>=
bool operator>=(const set &right) const
Definition: set.h:582
momo::stdish::set::operator=
set & operator=(const set &right)
Definition: set.h:187
momo::stdish::set::cbegin
const_iterator cbegin() const noexcept
Definition: set.h:255
momo::stdish::set::operator<
bool operator<(const set &right) const
Definition: set.h:567
momo::stdish::set::rbegin
const_reverse_iterator rbegin() const noexcept
Definition: set.h:241
momo::stdish::set::node_type
internal::set_node_handle< typename TreeSet::ExtractedItem > node_type
Definition: set.h:93
momo::stdish::set::set
set(set &&right, const momo::internal::Identity< allocator_type > &alloc) noexcept(std::is_empty< allocator_type >::value)
Definition: set.h:155
momo::stdish::set::erase
size_type erase(const key_type &key)
Definition: set.h:519
momo::stdish::set::key_compare
TLessFunc key_compare
Definition: set.h:66
momo::stdish::set::operator>
bool operator>(const set &right) const
Definition: set.h:572
std
Definition: ArrayUtility.h:299
momo::stdish::set::const_pointer
const_iterator::Pointer const_pointer
Definition: set.h:86
momo::stdish::multiset::value_type
key_type value_type
Definition: set.h:74
momo::stdish::multiset::insert
iterator insert(const value_type &value)
Definition: set.h:682
momo::internal::SetExtractedItem::Create
void Create(ItemCreator &&itemCreator)
Definition: SetUtility.h:320
momo::stdish::set::erase
iterator erase(const_iterator where)
Definition: set.h:507
momo::stdish::set::equal_range
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, std::pair< const_iterator, const_iterator > > equal_range(const KeyArg &key) const
Definition: set.h:402
momo::stdish::set::iterator
TreeSet::Iterator iterator
Definition: set.h:78
momo::stdish::multiset::size_type
size_t size_type
Definition: set.h:71
momo::stdish::multiset::insert
iterator insert(value_type &&value)
Definition: set.h:677
momo::TreeSet
Definition: TreeSet.h:296
momo::stdish::set::const_iterator
TreeSet::ConstIterator const_iterator
Definition: set.h:77
momo::stdish::set::swap
friend void swap(set &left, set &right) noexcept
Definition: set.h:212
momo::stdish::set::operator==
bool operator==(const set &right) const
Definition: set.h:547
momo::stdish::internal::set_node_handle
Definition: node_handle.h:29
momo::TreeSet::MemManager
TMemManager MemManager
Definition: TreeSet.h:300
momo::stdish::set::operator!=
bool operator!=(const set &right) const
Definition: set.h:552
momo::internal::TreeSetConstIterator
Definition: TreeSet.h:33
momo::stdish::set::~set
~set()=default
momo::stdish::set::lower_bound
const_iterator lower_bound(const key_type &key) const
Definition: set.h:352
momo::stdish::set::max_size
size_type max_size() const noexcept
Definition: set.h:290
momo::stdish::set::contains
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, bool > contains(const KeyArg &key) const
Definition: set.h:347
momo::stdish::set::erase_if
friend size_type erase_if(set &cont, const ValueFilter &valueFilter)
Definition: set.h:525
momo::stdish::set::set
set(set &&right) noexcept
Definition: set.h:150
momo::TreeTraits::multiKey
static const bool multiKey
Definition: TreeTraits.h:87
momo::stdish::set::insert_return_type
internal::insert_return_type< iterator, node_type > insert_return_type
Definition: set.h:94
node_handle.h
MOMO_ASSERT
#define MOMO_ASSERT(expr)
Definition: UserSettings.h:162
MOMO_DECLARE_PROXY_FUNCTION
#define MOMO_DECLARE_PROXY_FUNCTION(Object, Func, Result)
Definition: Utility.h:94
momo::stdish::set::insert
std::pair< iterator, bool > insert(value_type &&value)
Definition: set.h:411
momo::internal::SetExtractedItem
Definition: SetUtility.h:255
momo::stdish::set::set
set(Iterator first, Iterator last, const key_compare &lessFunc, const allocator_type &alloc=allocator_type())
Definition: set.h:132
momo::stdish::set::find
momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, const_iterator > find(const KeyArg &key) const
Definition: set.h:319
momo::stdish::set::reverse_iterator
std::reverse_iterator< iterator > reverse_iterator
Definition: set.h:90
momo::stdish::set::swap
void swap(set &right) noexcept
Definition: set.h:205
momo::internal::IsSetArgIterator
Definition: SetUtility.h:344
momo::stdish::set::end
const_iterator end() const noexcept
Definition: set.h:234
momo::stdish::set::rend
const_reverse_iterator rend() const noexcept
Definition: set.h:248
momo::stdish::set::const_reverse_iterator
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: set.h:91
MOMO_NODISCARD
#define MOMO_NODISCARD
Definition: UserSettings.h:192
momo::stdish::set::set
set()
Definition: set.h:110
momo::TreeSet::TreeTraits
TTreeTraits TreeTraits
Definition: TreeSet.h:299
momo::stdish::set::erase
iterator erase(const_iterator first, const_iterator last)
Definition: set.h:514