momo  3.9
unordered_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/unordered_set.h
10 
11  namespace momo::stdish:
12  class unordered_set
13  class unordered_set_open
14 
15 \**********************************************************/
16 
17 #ifndef MOMO_INCLUDE_GUARD_STDISH_UNORDERED_SET
18 #define MOMO_INCLUDE_GUARD_STDISH_UNORDERED_SET
19 
20 #include "../HashSet.h"
21 #include "node_handle.h"
22 
23 namespace momo
24 {
25 
26 namespace stdish
27 {
28 
51 template<typename TKey,
52  typename THashFunc = HashCoder<TKey>,
53  typename TEqualFunc = std::equal_to<TKey>,
54  typename TAllocator = std::allocator<TKey>,
55  typename THashSet = HashSet<TKey, HashTraitsStd<TKey, THashFunc, TEqualFunc>,
56  MemManagerStd<TAllocator>>>
58 {
59 private:
60  typedef THashSet HashSet;
61  typedef typename HashSet::HashTraits HashTraits;
62  typedef typename HashSet::MemManager MemManager;
63 
64 public:
65  typedef TKey key_type;
66  typedef THashFunc hasher;
67  typedef TEqualFunc key_equal;
68  typedef TAllocator allocator_type;
69 
71 
72  typedef size_t size_type;
73  typedef ptrdiff_t difference_type;
74 
76 
78  typedef typename HashSet::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 
92 
95 
96 private:
97  template<typename KeyArg>
98  struct IsValidKeyArg : public HashTraits::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:
111  {
112  }
113 
114  explicit unordered_set(const allocator_type& alloc)
115  : mHashSet(HashTraits(), MemManager(alloc))
116  {
117  }
118 
119  explicit unordered_set(size_type bucketCount, const allocator_type& alloc = allocator_type())
120  : mHashSet(HashTraits(bucketCount), MemManager(alloc))
121  {
122  }
123 
124  unordered_set(size_type bucketCount, const hasher& hashFunc,
125  const allocator_type& alloc = allocator_type())
126  : mHashSet(HashTraits(bucketCount, hashFunc), MemManager(alloc))
127  {
128  }
129 
130  unordered_set(size_type bucketCount, const hasher& hashFunc, const key_equal& equalFunc,
131  const allocator_type& alloc = allocator_type())
132  : mHashSet(HashTraits(bucketCount, hashFunc, equalFunc), MemManager(alloc))
133  {
134  }
135 
136  template<typename Iterator>
137  unordered_set(Iterator first, Iterator last)
138  {
139  insert(first, last);
140  }
141 
142  template<typename Iterator>
143  unordered_set(Iterator first, Iterator last, size_type bucketCount,
144  const allocator_type& alloc = allocator_type())
145  : unordered_set(bucketCount, alloc)
146  {
147  insert(first, last);
148  }
149 
150  template<typename Iterator>
151  unordered_set(Iterator first, Iterator last, size_type bucketCount, const hasher& hashFunc,
152  const allocator_type& alloc = allocator_type())
153  : unordered_set(bucketCount, hashFunc, alloc)
154  {
155  insert(first, last);
156  }
157 
158  template<typename Iterator>
159  unordered_set(Iterator first, Iterator last, size_type bucketCount, const hasher& hashFunc,
160  const key_equal& equalFunc, const allocator_type& alloc = allocator_type())
161  : unordered_set(bucketCount, hashFunc, equalFunc, alloc)
162  {
163  insert(first, last);
164  }
165 
166  unordered_set(std::initializer_list<value_type> values)
167  : mHashSet(values)
168  {
169  }
170 
171  unordered_set(std::initializer_list<value_type> values, size_type bucketCount,
172  const allocator_type& alloc = allocator_type())
173  : mHashSet(values, HashTraits(bucketCount), MemManager(alloc))
174  {
175  }
176 
177  unordered_set(std::initializer_list<value_type> values, size_type bucketCount,
178  const hasher& hashFunc, const allocator_type& alloc = allocator_type())
179  : mHashSet(values, HashTraits(bucketCount, hashFunc), MemManager(alloc))
180  {
181  }
182 
183  unordered_set(std::initializer_list<value_type> values, size_type bucketCount,
184  const hasher& hashFunc, const key_equal& equalFunc,
185  const allocator_type& alloc = allocator_type())
186  : mHashSet(values, HashTraits(bucketCount, hashFunc, equalFunc), MemManager(alloc))
187  {
188  }
189 
190  unordered_set(unordered_set&& right) noexcept
191  : mHashSet(std::move(right.mHashSet))
192  {
193  }
194 
196  noexcept(std::is_empty<allocator_type>::value)
197  : mHashSet(pvCreateSet(std::move(right), alloc))
198  {
199  }
200 
202  : mHashSet(right.mHashSet)
203  {
204  }
205 
207  : mHashSet(right.mHashSet, MemManager(alloc))
208  {
209  }
210 
211  ~unordered_set() = 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  mHashSet = pvCreateSet(std::move(right), alloc);
223  }
224  return *this;
225  }
226 
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  mHashSet = HashSet(right.mHashSet, MemManager(alloc));
235  }
236  return *this;
237  }
238 
239  unordered_set& operator=(std::initializer_list<value_type> values)
240  {
241  mHashSet = HashSet(values, mHashSet.GetHashTraits(), MemManager(get_allocator()));
242  return *this;
243  }
244 
245  void swap(unordered_set& right) noexcept
246  {
247  MOMO_ASSERT(std::allocator_traits<allocator_type>::propagate_on_container_swap::value
248  || get_allocator() == right.get_allocator());
249  mHashSet.Swap(right.mHashSet);
250  }
251 
252  friend void swap(unordered_set& left, unordered_set& right) noexcept
253  {
254  left.swap(right);
255  }
256 
258  {
259  return mHashSet;
260  }
261 
263  {
264  return mHashSet;
265  }
266 
267  const_iterator begin() const noexcept
268  {
269  return mHashSet.GetBegin();
270  }
271 
272  //iterator begin() noexcept
273 
274  const_iterator end() const noexcept
275  {
276  return mHashSet.GetEnd();
277  }
278 
279  //iterator end() noexcept
280 
281  const_iterator cbegin() const noexcept
282  {
283  return begin();
284  }
285 
286  const_iterator cend() const noexcept
287  {
288  return end();
289  }
290 
291  float max_load_factor() const noexcept
292  {
293  return mHashSet.GetHashTraits().GetMaxLoadFactor(HashSet::bucketMaxItemCount);
294  }
295 
296  void max_load_factor(float maxLoadFactor)
297  {
298  if (maxLoadFactor == max_load_factor())
299  return;
300  if (maxLoadFactor <= 0.0 || maxLoadFactor > static_cast<float>(HashSet::bucketMaxItemCount))
301  throw std::out_of_range("invalid load factor");
302  HashTraits hashTraits(mHashSet.GetHashTraits(), maxLoadFactor);
303  HashSet hashSet(hashTraits, MemManager(get_allocator()));
304  hashSet.Reserve(size());
305  hashSet.Insert(begin(), end());
306  mHashSet = std::move(hashSet);
307  }
308 
310  {
311  return mHashSet.GetHashTraits().GetHashFunc();
312  }
313 
315  {
316  return mHashSet.GetHashTraits().GetEqualFunc();
317  }
318 
319  allocator_type get_allocator() const noexcept
320  {
321  return allocator_type(mHashSet.GetMemManager().GetByteAllocator());
322  }
323 
324  size_type max_size() const noexcept
325  {
326  return std::allocator_traits<allocator_type>::max_size(get_allocator());
327  }
328 
329  size_type size() const noexcept
330  {
331  return mHashSet.GetCount();
332  }
333 
334  MOMO_NODISCARD bool empty() const noexcept
335  {
336  return mHashSet.IsEmpty();
337  }
338 
339  void clear() noexcept
340  {
341  mHashSet.Clear();
342  }
343 
344  void rehash(size_type bucketCount)
345  {
346  bucketCount = std::minmax(bucketCount, size_t{2}).second;
347  size_t logBucketCount = momo::internal::UIntMath<>::Log2(bucketCount - 1) + 1;
348  bucketCount = size_t{1} << logBucketCount;
349  reserve(mHashSet.GetHashTraits().CalcCapacity(bucketCount, HashSet::bucketMaxItemCount));
350  }
351 
353  {
354  mHashSet.Reserve(count);
355  }
356 
358  {
359  return mHashSet.Find(key);
360  }
361 
362  //iterator find(const key_type& key)
363 
364  template<typename KeyArg>
366  const_iterator> find(const KeyArg& key) const
367  {
368  return mHashSet.Find(key);
369  }
370 
371  //template<typename KeyArg>
372  //momo::internal::EnableIf<IsValidKeyArg<KeyArg>::value,
373  //iterator> find(const KeyArg& key)
374 
376  {
377  return contains(key) ? 1 : 0;
378  }
379 
380  template<typename KeyArg>
382  size_type> count(const KeyArg& key) const
383  {
384  return contains(key) ? 1 : 0;
385  }
386 
387  MOMO_FORCEINLINE bool contains(const key_type& key) const
388  {
389  return mHashSet.ContainsKey(key);
390  }
391 
392  template<typename KeyArg>
394  bool> contains(const KeyArg& key) const
395  {
396  return mHashSet.ContainsKey(key);
397  }
398 
399  MOMO_FORCEINLINE std::pair<const_iterator, const_iterator> equal_range(
400  const key_type& key) const
401  {
402  return { find(key), end() };
403  }
404 
405  //std::pair<iterator, iterator> equal_range(const key_type& key)
406 
407  template<typename KeyArg>
409  std::pair<const_iterator, const_iterator>> equal_range(const KeyArg& key) const
410  {
411  return { find(key), end() };
412  }
413 
414  //template<typename KeyArg>
415  //momo::internal::EnableIf<IsValidKeyArg<KeyArg>::value,
416  //std::pair<iterator, iterator>> equal_range(const KeyArg& key)
417 
418  std::pair<iterator, bool> insert(value_type&& value)
419  {
420  typename HashSet::InsertResult res = mHashSet.Insert(std::move(value));
421  return { res.position, res.inserted };
422  }
423 
425  {
426 #ifdef MOMO_USE_UNORDERED_HINT_ITERATORS
427  return mHashSet.Add(hint, std::move(value));
428 #else
429  (void)hint;
430  return insert(std::move(value)).first;
431 #endif
432  }
433 
434  std::pair<iterator, bool> insert(const value_type& value)
435  {
436  typename HashSet::InsertResult res = mHashSet.Insert(value);
437  return { res.position, res.inserted };
438  }
439 
441  {
442 #ifdef MOMO_USE_UNORDERED_HINT_ITERATORS
443  return mHashSet.Add(hint, value);
444 #else
445  (void)hint;
446  return insert(value).first;
447 #endif
448  }
449 
451  {
452  if (node.empty())
453  return { end(), false, node_type() };
454  typename HashSet::InsertResult res = mHashSet.Insert(
455  std::move(NodeTypeProxy::GetExtractedItem(node)));
456  return { res.position, res.inserted, res.inserted ? node_type() : std::move(node) };
457  }
458 
460  {
461 #ifdef MOMO_USE_UNORDERED_HINT_ITERATORS
462  if (node.empty())
463  return end();
464  return mHashSet.Add(hint, std::move(NodeTypeProxy::GetExtractedItem(node)));
465 #else
466  (void)hint;
467  return insert(std::move(node)).position;
468 #endif
469  }
470 
471  template<typename Iterator>
472  void insert(Iterator first, Iterator last)
473  {
475  }
476 
477  void insert(std::initializer_list<value_type> values)
478  {
479  mHashSet.Insert(values);
480  }
481 
482  template<typename... ValueArgs>
483  std::pair<iterator, bool> emplace(ValueArgs&&... valueArgs)
484  {
485  MemManager& memManager = mHashSet.GetMemManager();
486  typename HashSet::ExtractedItem extItem;
487  typedef typename HashSet::ItemTraits::template Creator<ValueArgs...> ValueCreator;
488  extItem.Create(ValueCreator(memManager, std::forward<ValueArgs>(valueArgs)...));
489  typename HashSet::InsertResult res = mHashSet.Insert(std::move(extItem));
490  return { res.position, res.inserted };
491  }
492 
493  template<typename ValueArg>
495  std::pair<iterator, bool>> emplace(ValueArg&& valueArg)
496  {
497  typename HashSet::InsertResult res = mHashSet.InsertVar(
498  static_cast<const key_type&>(valueArg), std::forward<ValueArg>(valueArg));
499  return { res.position, res.inserted };
500  }
501 
502  template<typename... ValueArgs>
503  iterator emplace_hint(const_iterator hint, ValueArgs&&... valueArgs)
504  {
505 #ifdef MOMO_USE_UNORDERED_HINT_ITERATORS
506  return mHashSet.AddVar(hint, std::forward<ValueArgs>(valueArgs)...);
507 #else
508  (void)hint;
509  return emplace(std::forward<ValueArgs>(valueArgs)...).first;
510 #endif
511  }
512 
514  {
515  return mHashSet.Remove(where);
516  }
517 
518  //iterator erase(iterator where)
519 
521  {
522  if (first == begin() && last == end())
523  {
524  clear();
525  return end();
526  }
527  if (first == last)
528  return first;
529  if (first != end() && std::next(first) == last)
530  return erase(first);
531  throw std::invalid_argument("invalid unordered_set erase arguments");
532  }
533 
535  {
536  return mHashSet.Remove(key) ? 1 : 0;
537  }
538 
539  template<typename ValueFilter>
540  friend size_type erase_if(unordered_set& cont, const ValueFilter& valueFilter)
541  {
542  return cont.mHashSet.Remove(valueFilter);
543  }
544 
546  {
547  return node_type(*this, where); // need RVO for exception safety
548  }
549 
551  {
552  const_iterator iter = find(key);
553  return (iter != end()) ? extract(iter) : node_type();
554  }
555 
556  template<typename Set>
557  void merge(Set&& set)
558  {
559  mHashSet.MergeFrom(set.get_nested_container());
560  }
561 
562  size_type max_bucket_count() const noexcept
563  {
565  //return momo::internal::HashSetBuckets<Bucket>::maxBucketCount;
566  }
567 
568  size_type bucket_count() const noexcept
569  {
570  return mHashSet.GetBucketCount();
571  }
572 
573  size_type bucket_size(size_type bucketIndex) const
574  {
575  return mHashSet.GetBucketBounds(bucketIndex).GetCount();
576  }
577 
579  {
580  return mHashSet.GetBucketBounds(bucketIndex).GetBegin();
581  }
582 
584  {
585  return mHashSet.GetBucketBounds(bucketIndex).GetBegin();
586  }
587 
589  {
590  return mHashSet.GetBucketBounds(bucketIndex).GetEnd();
591  }
592 
593  const_local_iterator end(size_type bucketIndex) const
594  {
595  return mHashSet.GetBucketBounds(bucketIndex).GetEnd();
596  }
597 
599  {
600  return begin(bucketIndex);
601  }
602 
604  {
605  return end(bucketIndex);
606  }
607 
608  size_type bucket(const key_type& key) const
609  {
610  return mHashSet.GetBucketIndex(key);
611  }
612 
613  float load_factor() const noexcept
614  {
615  size_t count = size();
616  size_t bucketCount = bucket_count();
617  if (count == 0 && bucketCount == 0)
618  return 0.0;
619  return static_cast<float>(count) / static_cast<float>(bucketCount);
620  }
621 
622  bool operator==(const unordered_set& right) const
623  {
624  if (size() != right.size())
625  return false;
626  for (const_reference ref : *this)
627  {
628  if (right.find(ref) == right.end())
629  return false;
630  }
631  return true;
632  }
633 
634  bool operator!=(const unordered_set& right) const
635  {
636  return !(*this == right);
637  }
638 
639 private:
640  static HashSet pvCreateSet(unordered_set&& right, const allocator_type& alloc)
641  {
642  if (right.get_allocator() == alloc)
643  return std::move(right.mHashSet);
644  HashSet hashSet(right.mHashSet.GetHashTraits(), MemManager(alloc));
645  hashSet.MergeFrom(right.mHashSet);
646  return hashSet;
647  }
648 
649  template<typename Iterator>
650  void pvInsert(Iterator first, Iterator last, std::true_type /*isSetArgIterator*/)
651  {
652  mHashSet.Insert(first, last);
653  }
654 
655  template<typename Iterator>
656  void pvInsert(Iterator first, Iterator last, std::false_type /*isSetArgIterator*/)
657  {
658  for (Iterator iter = first; iter != last; ++iter)
659  emplace(*iter);
660  }
661 
662 private:
663  HashSet mHashSet;
664 };
665 
675 template<typename TKey,
676  typename THashFunc = HashCoder<TKey>,
677  typename TEqualFunc = std::equal_to<TKey>,
678  typename TAllocator = std::allocator<TKey>>
679 class unordered_set_open : public unordered_set<TKey, THashFunc, TEqualFunc, TAllocator,
680  HashSet<TKey, HashTraitsStd<TKey, THashFunc, TEqualFunc, HashBucketOpenDefault>,
681  MemManagerStd<TAllocator>>>
682 {
683 private:
684  typedef unordered_set<TKey, THashFunc, TEqualFunc, TAllocator,
687 
688 public:
689  using typename UnorderedSet::size_type;
690  using typename UnorderedSet::value_type;
691 
692 public:
693  using UnorderedSet::UnorderedSet;
694 
695  unordered_set_open() {} // clang 3.6
696 
697  unordered_set_open& operator=(std::initializer_list<value_type> values)
698  {
699  UnorderedSet::operator=(values);
700  return *this;
701  }
702 
703  friend void swap(unordered_set_open& left, unordered_set_open& right) noexcept
704  {
705  left.swap(right);
706  }
707 
708  template<typename ValueFilter>
709  friend size_type erase_if(unordered_set_open& cont, const ValueFilter& valueFilter)
710  {
711  return cont.get_nested_container().Remove(valueFilter);
712  }
713 };
714 
715 #ifdef MOMO_HAS_DEDUCTION_GUIDES
716 
717 #define MOMO_DECLARE_DEDUCTION_GUIDES(unordered_set) \
718 template<typename Iterator, \
719  typename Key = typename std::iterator_traits<Iterator>::value_type> \
720 unordered_set(Iterator, Iterator) \
721  -> unordered_set<Key>; \
722 template<typename Iterator, \
723  typename Key = typename std::iterator_traits<Iterator>::value_type, \
724  typename Allocator = std::allocator<Key>, \
725  typename = decltype(std::declval<Allocator&>().allocate(size_t{}))> \
726 unordered_set(Iterator, Iterator, size_t, Allocator = Allocator()) \
727  -> unordered_set<Key, HashCoder<Key>, std::equal_to<Key>, Allocator>; \
728 template<typename Iterator, typename HashFunc, \
729  typename Key = typename std::iterator_traits<Iterator>::value_type, \
730  typename Allocator = std::allocator<Key>, \
731  typename = decltype(std::declval<HashFunc&>()(std::declval<const Key&>())), \
732  typename = decltype(std::declval<Allocator&>().allocate(size_t{}))> \
733 unordered_set(Iterator, Iterator, size_t, HashFunc, Allocator = Allocator()) \
734  -> unordered_set<Key, HashFunc, std::equal_to<Key>, Allocator>; \
735 template<typename Iterator, typename HashFunc, typename EqualFunc, \
736  typename Key = typename std::iterator_traits<Iterator>::value_type, \
737  typename Allocator = std::allocator<Key>, \
738  typename = decltype(std::declval<HashFunc&>()(std::declval<const Key&>())), \
739  typename = decltype(std::declval<EqualFunc&>()(std::declval<const Key&>(), std::declval<const Key&>()))> \
740 unordered_set(Iterator, Iterator, size_t, HashFunc, EqualFunc, Allocator = Allocator()) \
741  -> unordered_set<Key, HashFunc, EqualFunc, Allocator>; \
742 template<typename Key> \
743 unordered_set(std::initializer_list<Key>) \
744  -> unordered_set<Key>; \
745 template<typename Key, \
746  typename Allocator = std::allocator<Key>, \
747  typename = decltype(std::declval<Allocator&>().allocate(size_t{}))> \
748 unordered_set(std::initializer_list<Key>, size_t, Allocator = Allocator()) \
749  -> unordered_set<Key, HashCoder<Key>, std::equal_to<Key>, Allocator>; \
750 template<typename Key, typename HashFunc, \
751  typename Allocator = std::allocator<Key>, \
752  typename = decltype(std::declval<HashFunc&>()(std::declval<const Key&>())), \
753  typename = decltype(std::declval<Allocator&>().allocate(size_t{}))> \
754 unordered_set(std::initializer_list<Key>, size_t, HashFunc, Allocator = Allocator()) \
755  -> unordered_set<Key, HashFunc, std::equal_to<Key>, Allocator>; \
756 template<typename Key, typename HashFunc, typename EqualFunc, \
757  typename Allocator = std::allocator<Key>, \
758  typename = decltype(std::declval<HashFunc&>()(std::declval<const Key&>())), \
759  typename = decltype(std::declval<EqualFunc&>()(std::declval<const Key&>(), std::declval<const Key&>()))> \
760 unordered_set(std::initializer_list<Key>, size_t, HashFunc, EqualFunc, Allocator = Allocator()) \
761  -> unordered_set<Key, HashFunc, EqualFunc, Allocator>;
762 
763 MOMO_DECLARE_DEDUCTION_GUIDES(unordered_set)
764 MOMO_DECLARE_DEDUCTION_GUIDES(unordered_set_open)
765 
766 #undef MOMO_DECLARE_DEDUCTION_GUIDES
767 
768 #endif // MOMO_HAS_DEDUCTION_GUIDES
769 
770 } // namespace stdish
771 
772 } // namespace momo
773 
774 #endif // MOMO_INCLUDE_GUARD_STDISH_UNORDERED_SET
momo::stdish::unordered_set::unordered_set
unordered_set(size_type bucketCount, const allocator_type &alloc=allocator_type())
Definition: unordered_set.h:119
momo::stdish::unordered_set::unordered_set
unordered_set(Iterator first, Iterator last, size_type bucketCount, const hasher &hashFunc, const key_equal &equalFunc, const allocator_type &alloc=allocator_type())
Definition: unordered_set.h:159
momo::stdish::unordered_set::bucket_count
size_type bucket_count() const noexcept
Definition: unordered_set.h:568
momo::internal::InsertResult::position
Position position
Definition: IteratorUtility.h:183
momo::internal::UIntConst::maxSize
static const size_t maxSize
Definition: Utility.h:384
momo::HashSet::MemManager
TMemManager MemManager
Definition: HashSet.h:468
momo::stdish::unordered_set::erase
iterator erase(const_iterator first, const_iterator last)
Definition: unordered_set.h:520
momo::stdish::unordered_set::difference_type
ptrdiff_t difference_type
Definition: unordered_set.h:73
momo::stdish::unordered_set::insert
iterator insert(const_iterator hint, value_type &&value)
Definition: unordered_set.h:424
momo::stdish::unordered_set::count
MOMO_FORCEINLINE momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, size_type > count(const KeyArg &key) const
Definition: unordered_set.h:382
momo::stdish::unordered_set::get_nested_container
const nested_container_type & get_nested_container() const noexcept
Definition: unordered_set.h:257
momo::stdish::unordered_set_open::size_type
size_t size_type
Definition: unordered_set.h:72
momo::stdish::unordered_set::operator=
unordered_set & operator=(unordered_set &&right) noexcept(std::is_empty< allocator_type >::value||std::allocator_traits< allocator_type >::propagate_on_container_move_assignment::value)
Definition: unordered_set.h:213
momo::stdish::unordered_set::begin
const_local_iterator begin(size_type bucketIndex) const
Definition: unordered_set.h:583
momo::stdish::unordered_set::begin
const_iterator begin() const noexcept
Definition: unordered_set.h:267
momo::stdish::unordered_set::insert
insert_return_type insert(node_type &&node)
Definition: unordered_set.h:450
momo::stdish::unordered_set::unordered_set
unordered_set(const unordered_set &right, const momo::internal::Identity< allocator_type > &alloc)
Definition: unordered_set.h:206
momo::stdish::unordered_set::max_size
size_type max_size() const noexcept
Definition: unordered_set.h:324
momo::stdish::unordered_set::unordered_set
unordered_set(std::initializer_list< value_type > values, size_type bucketCount, const hasher &hashFunc, const allocator_type &alloc=allocator_type())
Definition: unordered_set.h:177
momo::stdish::unordered_set::equal_range
MOMO_FORCEINLINE std::pair< const_iterator, const_iterator > equal_range(const key_type &key) const
Definition: unordered_set.h:399
momo::stdish::unordered_set::unordered_set
unordered_set(unordered_set &&right) noexcept
Definition: unordered_set.h:190
momo::stdish::unordered_set::operator!=
bool operator!=(const unordered_set &right) const
Definition: unordered_set.h:634
momo::stdish::unordered_set::insert
iterator insert(const_iterator hint, node_type &&node)
Definition: unordered_set.h:459
momo::stdish::unordered_set::end
const_iterator end() const noexcept
Definition: unordered_set.h:274
momo::stdish::internal::insert_return_type
Definition: node_handle.h:190
momo::internal::HashSetConstIterator::Pointer
const Item * Pointer
Definition: HashSet.h:204
momo::stdish::unordered_set::clear
void clear() noexcept
Definition: unordered_set.h:339
momo::internal::UIntMath::Log2
static UInt Log2(UInt value) noexcept
Definition: Utility.h:322
momo::stdish::unordered_set::extract
node_type extract(const_iterator where)
Definition: unordered_set.h:545
momo::stdish::unordered_set::max_bucket_count
size_type max_bucket_count() const noexcept
Definition: unordered_set.h:562
momo::stdish::unordered_set::size_type
size_t size_type
Definition: unordered_set.h:72
momo::stdish::unordered_set::insert
void insert(std::initializer_list< value_type > values)
Definition: unordered_set.h:477
momo::stdish::unordered_set::end
local_iterator end(size_type bucketIndex)
Definition: unordered_set.h:588
momo::stdish::unordered_set::unordered_set
unordered_set(size_type bucketCount, const hasher &hashFunc, const key_equal &equalFunc, const allocator_type &alloc=allocator_type())
Definition: unordered_set.h:130
momo::internal::HashSetConstIterator::Reference
const Item & Reference
Definition: HashSet.h:203
momo::stdish::unordered_set::unordered_set
unordered_set(const allocator_type &alloc)
Definition: unordered_set.h:114
momo::HashSet::Reserve
void Reserve(size_t capacity)
Definition: HashSet.h:707
momo::stdish::unordered_set::load_factor
float load_factor() const noexcept
Definition: unordered_set.h:613
momo::stdish::unordered_set::insert
std::pair< iterator, bool > insert(const value_type &value)
Definition: unordered_set.h:434
momo::stdish::set
momo::stdish::set is similar to std::set, but much more efficient in memory usage....
Definition: set.h:58
momo::stdish::unordered_set::unordered_set
unordered_set(std::initializer_list< value_type > values, size_type bucketCount, const hasher &hashFunc, const key_equal &equalFunc, const allocator_type &alloc=allocator_type())
Definition: unordered_set.h:183
momo::MemManagerStd
MemManagerStd uses allocator<unsigned char>::allocate and deallocate
Definition: MemManager.h:176
momo::stdish::unordered_set::erase_if
friend size_type erase_if(unordered_set &cont, const ValueFilter &valueFilter)
Definition: unordered_set.h:540
momo::stdish::unordered_set_open::unordered_set_open
unordered_set_open()
Definition: unordered_set.h:695
momo::stdish::unordered_set::equal_range
MOMO_FORCEINLINE momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, std::pair< const_iterator, const_iterator > > equal_range(const KeyArg &key) const
Definition: unordered_set.h:409
momo::HashSet::Remove
ConstIterator Remove(ConstIterator iter)
Definition: HashSet.h:847
momo::stdish::unordered_set::insert
void insert(Iterator first, Iterator last)
Definition: unordered_set.h:472
momo::internal::InsertResult
Definition: IteratorUtility.h:151
momo::stdish::unordered_set::unordered_set
unordered_set(Iterator first, Iterator last, size_type bucketCount, const allocator_type &alloc=allocator_type())
Definition: unordered_set.h:143
momo::internal::HashSetConstIterator
Definition: HashSet.h:277
momo::stdish::unordered_set::value_type
key_type value_type
Definition: unordered_set.h:75
momo::stdish::unordered_set::empty
MOMO_NODISCARD bool empty() const noexcept
Definition: unordered_set.h:334
momo::stdish::unordered_set::unordered_set
unordered_set()
Definition: unordered_set.h:110
momo::HashSet::Insert
InsertResult Insert(Item &&item)
Definition: HashSet.h:769
momo::stdish::unordered_set::max_load_factor
void max_load_factor(float maxLoadFactor)
Definition: unordered_set.h:296
momo::stdish::unordered_set::~unordered_set
~unordered_set()=default
momo::stdish::unordered_set::unordered_set
unordered_set(const unordered_set &right)
Definition: unordered_set.h:201
momo::HashSet::HashTraits
THashTraits HashTraits
Definition: HashSet.h:467
momo::internal::EnableIf
typename std::enable_if< value, Type >::type EnableIf
Definition: Utility.h:174
momo::stdish::unordered_set::operator==
bool operator==(const unordered_set &right) const
Definition: unordered_set.h:622
momo::stdish::unordered_set::emplace_hint
iterator emplace_hint(const_iterator hint, ValueArgs &&... valueArgs)
Definition: unordered_set.h:503
momo::stdish::unordered_set::operator=
unordered_set & operator=(std::initializer_list< value_type > values)
Definition: unordered_set.h:239
momo::stdish::unordered_set::allocator_type
TAllocator allocator_type
Definition: unordered_set.h:68
momo::stdish::unordered_set::bucket_size
size_type bucket_size(size_type bucketIndex) const
Definition: unordered_set.h:573
momo::stdish::unordered_set::count
MOMO_FORCEINLINE size_type count(const key_type &key) const
Definition: unordered_set.h:375
momo
Definition: Array.h:26
momo::stdish::unordered_set::key_type
TKey key_type
Definition: unordered_set.h:65
momo::HashCoder< TKey >
momo::stdish::unordered_set::hash_function
hasher hash_function() const
Definition: unordered_set.h:309
momo::stdish::set::get_nested_container
const nested_container_type & get_nested_container() const noexcept
Definition: set.h:217
momo::HashSet::bucketMaxItemCount
static const size_t bucketMaxItemCount
Definition: HashSet.h:502
momo::stdish::unordered_set::end
const_local_iterator end(size_type bucketIndex) const
Definition: unordered_set.h:593
momo::internal::InsertResult::inserted
bool inserted
Definition: IteratorUtility.h:186
momo::internal::Identity
EnableIf< true, Type > Identity
Definition: Utility.h:177
momo::stdish::unordered_set::iterator
HashSet::Iterator iterator
Definition: unordered_set.h:78
momo::stdish::unordered_set::reserve
void reserve(size_type count)
Definition: unordered_set.h:352
momo::stdish::unordered_set::get_allocator
allocator_type get_allocator() const noexcept
Definition: unordered_set.h:319
momo::stdish::unordered_set::reference
value_type & reference
Definition: unordered_set.h:81
momo::stdish::unordered_set::contains
MOMO_FORCEINLINE momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, bool > contains(const KeyArg &key) const
Definition: unordered_set.h:394
momo::stdish::unordered_set::key_eq
key_equal key_eq() const
Definition: unordered_set.h:314
momo::stdish::unordered_set_open
momo::stdish::unordered_set_open is similar to std::unordered_set, but much more efficient in operati...
Definition: unordered_set.h:682
momo::stdish::internal::set_node_handle::SetExtractedItem
TSetExtractedItem SetExtractedItem
Definition: node_handle.h:31
momo::stdish::unordered_set::cbegin
const_local_iterator cbegin(size_type bucketIndex) const
Definition: unordered_set.h:598
momo::HashTraitsStd
Definition: HashTraits.h:196
momo::stdish::unordered_set::const_iterator
HashSet::ConstIterator const_iterator
Definition: unordered_set.h:77
momo::stdish::unordered_set::const_reference
const_iterator::Reference const_reference
Definition: unordered_set.h:82
momo::stdish::unordered_set::unordered_set
unordered_set(std::initializer_list< value_type > values, size_type bucketCount, const allocator_type &alloc=allocator_type())
Definition: unordered_set.h:171
momo::stdish::unordered_set::emplace
momo::internal::EnableIf< std::is_same< key_type, typename std::decay< ValueArg >::type >::value, std::pair< iterator, bool > > emplace(ValueArg &&valueArg)
Definition: unordered_set.h:495
momo::HashSet< TKey, HashTraitsStd< TKey, HashCoder< TKey >, std::equal_to< TKey >, HashBucketOpenDefault >, MemManagerStd< std::allocator< TKey > > >
momo::stdish::unordered_set::bucket
size_type bucket(const key_type &key) const
Definition: unordered_set.h:608
momo::stdish::unordered_set_open::erase_if
friend size_type erase_if(unordered_set_open &cont, const ValueFilter &valueFilter)
Definition: unordered_set.h:709
momo::stdish::unordered_set::hasher
THashFunc hasher
Definition: unordered_set.h:66
momo::stdish::unordered_set::operator=
unordered_set & operator=(const unordered_set &right)
Definition: unordered_set.h:227
momo::stdish::unordered_set::insert
iterator insert(const_iterator hint, const value_type &value)
Definition: unordered_set.h:440
momo::stdish::unordered_set::merge
void merge(Set &&set)
Definition: unordered_set.h:557
std
Definition: ArrayUtility.h:299
MOMO_FORCEINLINE
#define MOMO_FORCEINLINE
Definition: UserSettings.h:114
momo::stdish::unordered_set::find
MOMO_FORCEINLINE momo::internal::EnableIf< IsValidKeyArg< KeyArg >::value, const_iterator > find(const KeyArg &key) const
Definition: unordered_set.h:366
momo::stdish::unordered_set::key_equal
TEqualFunc key_equal
Definition: unordered_set.h:67
momo::stdish::unordered_set::nested_container_type
HashSet nested_container_type
Definition: unordered_set.h:70
momo::stdish::unordered_set::swap
void swap(unordered_set &right) noexcept
Definition: unordered_set.h:245
momo::internal::SetExtractedItem::Create
void Create(ItemCreator &&itemCreator)
Definition: SetUtility.h:320
momo::stdish::unordered_set::unordered_set
unordered_set(Iterator first, Iterator last, size_type bucketCount, const hasher &hashFunc, const allocator_type &alloc=allocator_type())
Definition: unordered_set.h:151
momo::stdish::unordered_set::extract
node_type extract(const key_type &key)
Definition: unordered_set.h:550
momo::stdish::unordered_set::local_iterator
const_local_iterator local_iterator
Definition: unordered_set.h:94
momo::stdish::unordered_set::const_pointer
const_iterator::Pointer const_pointer
Definition: unordered_set.h:86
momo::stdish::unordered_set::unordered_set
unordered_set(size_type bucketCount, const hasher &hashFunc, const allocator_type &alloc=allocator_type())
Definition: unordered_set.h:124
momo::stdish::unordered_set::cbegin
const_iterator cbegin() const noexcept
Definition: unordered_set.h:281
momo::stdish::unordered_set::size
size_type size() const noexcept
Definition: unordered_set.h:329
momo::stdish::internal::set_node_handle
Definition: node_handle.h:29
momo::stdish::unordered_set::insert
std::pair< iterator, bool > insert(value_type &&value)
Definition: unordered_set.h:418
momo::stdish::unordered_set::const_local_iterator
HashSet::ConstBucketBounds::Iterator const_local_iterator
Definition: unordered_set.h:93
momo::stdish::unordered_set::cend
const_iterator cend() const noexcept
Definition: unordered_set.h:286
momo::stdish::unordered_set::emplace
std::pair< iterator, bool > emplace(ValueArgs &&... valueArgs)
Definition: unordered_set.h:483
momo::stdish::unordered_set::unordered_set
unordered_set(Iterator first, Iterator last)
Definition: unordered_set.h:137
momo::stdish::unordered_set::rehash
void rehash(size_type bucketCount)
Definition: unordered_set.h:344
momo::stdish::unordered_set::contains
MOMO_FORCEINLINE bool contains(const key_type &key) const
Definition: unordered_set.h:387
momo::stdish::unordered_set::unordered_set
unordered_set(std::initializer_list< value_type > values)
Definition: unordered_set.h:166
momo::stdish::unordered_set
momo::stdish::unordered_set is similar to std::unordered_set, but much more efficient in memory usage...
Definition: unordered_set.h:58
momo::stdish::unordered_set_open::operator=
unordered_set_open & operator=(std::initializer_list< value_type > values)
Definition: unordered_set.h:697
momo::stdish::unordered_set::find
MOMO_FORCEINLINE const_iterator find(const key_type &key) const
Definition: unordered_set.h:357
momo::stdish::unordered_set::erase
size_type erase(const key_type &key)
Definition: unordered_set.h:534
momo::stdish::unordered_set::get_nested_container
nested_container_type & get_nested_container() noexcept
Definition: unordered_set.h:262
node_handle.h
momo::stdish::unordered_set::node_type
internal::set_node_handle< typename HashSet::ExtractedItem > node_type
Definition: unordered_set.h:90
momo::stdish::unordered_set::unordered_set
unordered_set(unordered_set &&right, const momo::internal::Identity< allocator_type > &alloc) noexcept(std::is_empty< allocator_type >::value)
Definition: unordered_set.h:195
MOMO_ASSERT
#define MOMO_ASSERT(expr)
Definition: UserSettings.h:162
momo::stdish::unordered_set::swap
friend void swap(unordered_set &left, unordered_set &right) noexcept
Definition: unordered_set.h:252
MOMO_DECLARE_PROXY_FUNCTION
#define MOMO_DECLARE_PROXY_FUNCTION(Object, Func, Result)
Definition: Utility.h:94
momo::internal::SetExtractedItem
Definition: SetUtility.h:255
momo::internal::IsSetArgIterator
Definition: SetUtility.h:344
momo::stdish::unordered_set::pointer
value_type * pointer
Definition: unordered_set.h:85
momo::stdish::unordered_set::erase
iterator erase(const_iterator where)
Definition: unordered_set.h:513
momo::stdish::unordered_set::insert_return_type
internal::insert_return_type< iterator, node_type > insert_return_type
Definition: unordered_set.h:91
MOMO_NODISCARD
#define MOMO_NODISCARD
Definition: UserSettings.h:192
momo::stdish::unordered_set_open::swap
friend void swap(unordered_set_open &left, unordered_set_open &right) noexcept
Definition: unordered_set.h:703
momo::stdish::unordered_set::max_load_factor
float max_load_factor() const noexcept
Definition: unordered_set.h:291
momo::stdish::unordered_set::begin
local_iterator begin(size_type bucketIndex)
Definition: unordered_set.h:578
momo::stdish::unordered_set::cend
const_local_iterator cend(size_type bucketIndex) const
Definition: unordered_set.h:603