#include <maxonstd.h>

maxonstd::unordered_map adapts a Maxon core HashMap to look like a std::unordered_map, so that it can be used as a substitute thereof. To change the settings of the underlying HashMap, you have to provide a HashMapSelector or BlockHashMapSelector 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_map. However, for an unordered map you almost never need the iterator capability of find's return value, because usually it makes no sense to proceed from there (an unordered map 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 HashMap::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 map.end():
Note that maxonstd::unordered_map doesn't support std::unordered_map's additional template parameters for hash, comparison and allocator directly. However, you can achieve the same effect with corresponding template parameters of the HashMapSelector.
| K | Type of keys. |
| V | 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 HashMap::Entry is returned without iterator capabilities. |
| SELECTOR | To choose a HashMap with non-default template parameters, you have to provide a HashMapSelector with the desired configuration. |
Public Types | |
| using | Super = unordered_map_base< typename SELECTOR::template Type< K, V >, FIND_RETURNS_ITERATOR > |
| using | value_type = Entry |
| 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< K, V >, true > | |
| using | Super = container< SELECTOR::template Type< K, V > > |
| 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< K, V > > | |
| 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 std::pair< const K, V > &value) |
| std::pair< FindResult, bool > | insert (std::pair< const K, V > &&value) |
| template<typename PAIR > | |
| std::pair< FindResult, bool > | insert (PAIR &&value) |
| V & | operator[] (const K &key) |
Public Member Functions inherited from unordered_map_base< SELECTOR::template Type< K, V >, 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< K, V > > | |
| 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 |
Private Member Functions | |
| template<typename PAIR > | |
| std::pair< FindResult, bool > | insert_pair (PAIR &&value) |
Additional Inherited Members | |
Protected Member Functions inherited from unordered_map_base< SELECTOR::template Type< K, V >, 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<K, V>, FIND_RETURNS_ITERATOR> |
| using value_type = Entry |
| using FindResult = std::conditional_t<FIND_RETURNS_ITERATOR, iterator, EntryWrapper<false> > |
| std::pair<FindResult, bool> insert | ( | const std::pair< const K, V > & | value | ) |
| std::pair<FindResult, bool> insert | ( | std::pair< const K, V > && | value | ) |
| std::pair<FindResult, bool> insert | ( | PAIR && | value | ) |
| V& operator[] | ( | const K & | key | ) |
|
private |