#include <maxonstd.h>

maxonstd::unordered_set adapts a Maxon core HashSet to look like a std::unordered_set, so that it can be used as a substitute thereof. To change the settings of the underlying HashSet, you have to provide a HashSetSelector or BlockHashSetSelector via the SELECTOR template parameter.
FIND_RETURNS_ITERATOR controls the return type of the find functions. With the default of true, these functions return an iterator to be compatible with std::unordered_set. However, for an unordered set you almost never need the iterator capability of find's return value, because usually it makes no sense to proceed from there (an unordered set has unspecified order, neighboring elements have no relationship). You only need the iterator comparison function to detect if find was successful at all:
You can use false for FIND_RETURNS_ITERATOR which makes the find functions return a more lightweight wrapper around HashSet::Entry without iterator capabilities. It can still be compared to an iterator, so the above code remains valid if you adapt it to the new type:
But there's a conversion to Bool, so you can directly test for validity without the need of set.end():
Note that maxonstd::unordered_set doesn't support std::unordered_set's additional template parameters for hash, comparison and allocator directly. However, you can achieve the same effect with corresponding template parameters of the HashSetSelector.
| T | Type of values. |
| FIND_RETURNS_ITERATOR | By default (true), the find functions return an iterator compatible with std library. With false, a more efficient wrapper around HashSet::Entry is returned without iterator capabilities. |
| SELECTOR | To choose a HashSet with non-default template parameters, you have to provide a HashSetSelector with the desired configuration. |
Public Types | |
| using | Super = unordered_map_base< typename SELECTOR::template Type< T >, FIND_RETURNS_ITERATOR > |
| using | FindResult = std::conditional_t< FIND_RETURNS_ITERATOR, iterator, EntryWrapper< false > > |
| using | Super = container< MAP > |
Public Types inherited from unordered_map_base< SELECTOR::template Type< T >, true > | |
| using | Super = container< SELECTOR::template Type< T > > |
| using | value_type = Entry |
| using | FindResult = std::conditional_t< FIND_RETURNS_ITERATOR, iterator, EntryWrapper< false > > |
| using | ConstFindResult = std::conditional_t< FIND_RETURNS_ITERATOR, const_iterator, EntryWrapper< true > > |
Public Types inherited from container< SELECTOR::template Type< T > > | |
| using | iterator = typename COLLECTION::Iterator |
| using | const_iterator = typename COLLECTION::ConstIterator |
| using | reverse_iterator = maxon::ReverseIterator< iterator > |
| using | const_reverse_iterator = maxon::ReverseIterator< const_iterator > |
Public Member Functions | |
| std::pair< FindResult, bool > | insert (const T &value) |
| std::pair< FindResult, bool > | insert (T &&value) |
| size_t | erase (const T &key) |
| iterator | erase (const iterator &it) |
| void | erase (const EntryWrapper< false > &e) |
Public Member Functions inherited from unordered_map_base< SELECTOR::template Type< T >, true > | |
| ConstFindResult | find (const KeyType &key) const |
| FindResult | find (const KeyType &key) |
| iterator | erase (const iterator &it) |
| void | erase (const EntryWrapper< false > &e) |
Public Member Functions inherited from container< SELECTOR::template Type< T > > | |
| container ()=default | |
| container (container &&)=default | |
| container (const container &src) | |
| container & | operator= (container &&)=default |
| container & | operator= (const container &src) |
| maxon::Result< void > | CopyFrom (const container &)=delete |
| auto | begin () |
| auto | begin () const |
| auto | end () |
| auto | end () const |
| auto | cbegin () const |
| auto | cend () const |
| reverse_iterator | rbegin () |
| const_reverse_iterator | rbegin () const |
| reverse_iterator | rend () |
| const_reverse_iterator | rend () const |
| const_reverse_iterator | rcbegin () const |
| const_reverse_iterator | rcend () const |
| void | clear () |
| bool | empty () const |
| std::size_t | size () const |
Additional Inherited Members | |
Protected Member Functions inherited from unordered_map_base< SELECTOR::template Type< T >, true > | |
| MAXON_ATTRIBUTE_FORCE_INLINE FindResult | ToFindResult (Entry *e) |
| MAXON_ATTRIBUTE_FORCE_INLINE ConstFindResult | ToFindResult (const Entry *e) const |
| using Super = unordered_map_base<typename SELECTOR::template Type<T>, FIND_RETURNS_ITERATOR> |
| using FindResult = std::conditional_t<FIND_RETURNS_ITERATOR, iterator, EntryWrapper<false> > |
| std::pair<FindResult, bool> insert | ( | const T & | value | ) |
| std::pair<FindResult, bool> insert | ( | T && | value | ) |
| size_t erase | ( | const T & | key | ) |
| iterator erase |
| void erase |