momo  3.9
momo::stdish::map< TKey, TMapped, TLessFunc, TAllocator, TTreeMap > Class Template Reference

momo::stdish::map is similar to std::map, but much more efficient in memory usage. The implementation is based on a B-tree. More...

#include <map.h>

Inheritance diagram for momo::stdish::map< TKey, TMapped, TLessFunc, TAllocator, TTreeMap >:

Public Types

typedef TKey key_type
 
typedef TMapped mapped_type
 
typedef size_t size_type
 
typedef std::pair< const key_type, mapped_typevalue_type
 
typedef const_iterator::Reference const_reference
 
typedef iterator::ConstIterator const_iterator
 
typedef momo::internal::TreeDerivedIterator< TreeMapIterator, momo::internal::MapReferenceStditerator
 

Public Member Functions

mapoperator= (std::initializer_list< value_type > values)
 
TreeMap::ValueReferenceRKey operator[] (key_type &&key)
 
TreeMap::ValueReferenceCKey operator[] (const key_type &key)
 
const mapped_typeat (const key_type &key) const
 
mapped_typeat (const key_type &key)
 
template<typename... MappedArgs>
std::pair< iterator, bool > try_emplace (key_type &&key, MappedArgs &&... mappedArgs)
 
template<typename... MappedArgs>
iterator try_emplace (const_iterator hint, key_type &&key, MappedArgs &&... mappedArgs)
 
template<typename... MappedArgs>
std::pair< iterator, bool > try_emplace (const key_type &key, MappedArgs &&... mappedArgs)
 
template<typename... MappedArgs>
iterator try_emplace (const_iterator hint, const key_type &key, MappedArgs &&... mappedArgs)
 
template<typename MappedArg >
std::pair< iterator, bool > insert_or_assign (key_type &&key, MappedArg &&mappedArg)
 
template<typename MappedArg >
iterator insert_or_assign (const_iterator hint, key_type &&key, MappedArg &&mappedArg)
 
template<typename MappedArg >
std::pair< iterator, bool > insert_or_assign (const key_type &key, MappedArg &&mappedArg)
 
template<typename MappedArg >
iterator insert_or_assign (const_iterator hint, const key_type &key, MappedArg &&mappedArg)
 

Friends

void swap (map &left, map &right) noexcept
 
template<typename ValueFilter >
size_type erase_if (map &cont, const ValueFilter &valueFilter)
 

Detailed Description

template<typename TKey, typename TMapped, typename TLessFunc = std::less<TKey>, typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>, typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>, MemManagerStd<TAllocator>>>
class momo::stdish::map< TKey, TMapped, TLessFunc, TAllocator, TTreeMap >

momo::stdish::map is similar to std::map, but much more efficient in memory usage. The implementation is based on a B-tree.

Deviations from standard class:

  1. Container items must be movable (preferably without exceptions) or copyable, similar to items of std::vector.
  2. After each addition or removal of the item all iterators and references to items become invalid and should not be used.
  3. Type reference is not the same as value_type&, so for (auto& p : map) is illegal, but for (auto p : map) or for (const auto& p : map) or for (auto&& p : map) is allowed.
  4. Functions begin, cbegin, rend and crend have logarithmic complexity.
  5. If ObjectManager<key_type>::isNothrowAnywayAssignable is false or ObjectManager<mapped_type>::isNothrowAnywayAssignable is false, functions erase can throw exceptions.
  6. Functions merge, extract and insert(node_type&&) move items.

It is allowed to pass to functions insert and emplace references to items within the container.

Function merge can work fast, if container types are same and each key from one container is less than each key from other container.

Member Typedef Documentation

◆ const_iterator

template<typename TKey , typename TMapped , typename TLessFunc = std::less<TKey>, typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>, typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>, MemManagerStd<TAllocator>>>
typedef iterator::ConstIterator momo::stdish::internal::map_base< TKey, TMapped, TLessFunc, TAllocator, TTreeMap >::const_iterator

◆ const_reference

template<typename TKey , typename TMapped , typename TLessFunc = std::less<TKey>, typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>, typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>, MemManagerStd<TAllocator>>>
typedef const_iterator::Reference momo::stdish::internal::map_base< TKey, TMapped, TLessFunc, TAllocator, TTreeMap >::const_reference

◆ iterator

template<typename TKey , typename TMapped , typename TLessFunc = std::less<TKey>, typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>, typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>, MemManagerStd<TAllocator>>>
typedef momo::internal::TreeDerivedIterator<TreeMapIterator, momo::internal::MapReferenceStd> momo::stdish::internal::map_base< TKey, TMapped, TLessFunc, TAllocator, TTreeMap >::iterator

◆ key_type

template<typename TKey , typename TMapped , typename TLessFunc = std::less<TKey>, typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>, typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>, MemManagerStd<TAllocator>>>
typedef TKey momo::stdish::internal::map_base< TKey, TMapped, TLessFunc, TAllocator, TTreeMap >::key_type

◆ mapped_type

template<typename TKey , typename TMapped , typename TLessFunc = std::less<TKey>, typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>, typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>, MemManagerStd<TAllocator>>>
typedef TMapped momo::stdish::internal::map_base< TKey, TMapped, TLessFunc, TAllocator, TTreeMap >::mapped_type

◆ size_type

template<typename TKey , typename TMapped , typename TLessFunc = std::less<TKey>, typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>, typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>, MemManagerStd<TAllocator>>>
typedef size_t momo::stdish::internal::map_base< TKey, TMapped, TLessFunc, TAllocator, TTreeMap >::size_type

◆ value_type

template<typename TKey , typename TMapped , typename TLessFunc = std::less<TKey>, typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>, typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>, MemManagerStd<TAllocator>>>
typedef std::pair<const key_type, mapped_type> momo::stdish::internal::map_base< TKey, TMapped, TLessFunc, TAllocator, TTreeMap >::value_type

Member Function Documentation

◆ at() [1/2]

template<typename TKey , typename TMapped , typename TLessFunc = std::less<TKey>, typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>, typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>, MemManagerStd<TAllocator>>>
mapped_type& momo::stdish::map< TKey, TMapped, TLessFunc, TAllocator, TTreeMap >::at ( const key_type key)
inline

◆ at() [2/2]

template<typename TKey , typename TMapped , typename TLessFunc = std::less<TKey>, typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>, typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>, MemManagerStd<TAllocator>>>
const mapped_type& momo::stdish::map< TKey, TMapped, TLessFunc, TAllocator, TTreeMap >::at ( const key_type key) const
inline

◆ insert_or_assign() [1/4]

template<typename TKey , typename TMapped , typename TLessFunc = std::less<TKey>, typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>, typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>, MemManagerStd<TAllocator>>>
template<typename MappedArg >
std::pair<iterator, bool> momo::stdish::map< TKey, TMapped, TLessFunc, TAllocator, TTreeMap >::insert_or_assign ( const key_type key,
MappedArg &&  mappedArg 
)
inline

◆ insert_or_assign() [2/4]

template<typename TKey , typename TMapped , typename TLessFunc = std::less<TKey>, typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>, typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>, MemManagerStd<TAllocator>>>
template<typename MappedArg >
iterator momo::stdish::map< TKey, TMapped, TLessFunc, TAllocator, TTreeMap >::insert_or_assign ( const_iterator  hint,
const key_type key,
MappedArg &&  mappedArg 
)
inline

◆ insert_or_assign() [3/4]

template<typename TKey , typename TMapped , typename TLessFunc = std::less<TKey>, typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>, typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>, MemManagerStd<TAllocator>>>
template<typename MappedArg >
iterator momo::stdish::map< TKey, TMapped, TLessFunc, TAllocator, TTreeMap >::insert_or_assign ( const_iterator  hint,
key_type &&  key,
MappedArg &&  mappedArg 
)
inline

◆ insert_or_assign() [4/4]

template<typename TKey , typename TMapped , typename TLessFunc = std::less<TKey>, typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>, typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>, MemManagerStd<TAllocator>>>
template<typename MappedArg >
std::pair<iterator, bool> momo::stdish::map< TKey, TMapped, TLessFunc, TAllocator, TTreeMap >::insert_or_assign ( key_type &&  key,
MappedArg &&  mappedArg 
)
inline

◆ operator=()

template<typename TKey , typename TMapped , typename TLessFunc = std::less<TKey>, typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>, typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>, MemManagerStd<TAllocator>>>
map& momo::stdish::map< TKey, TMapped, TLessFunc, TAllocator, TTreeMap >::operator= ( std::initializer_list< value_type values)
inline

◆ operator[]() [1/2]

template<typename TKey , typename TMapped , typename TLessFunc = std::less<TKey>, typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>, typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>, MemManagerStd<TAllocator>>>
TreeMap::ValueReferenceCKey momo::stdish::map< TKey, TMapped, TLessFunc, TAllocator, TTreeMap >::operator[] ( const key_type key)
inline

◆ operator[]() [2/2]

template<typename TKey , typename TMapped , typename TLessFunc = std::less<TKey>, typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>, typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>, MemManagerStd<TAllocator>>>
TreeMap::ValueReferenceRKey momo::stdish::map< TKey, TMapped, TLessFunc, TAllocator, TTreeMap >::operator[] ( key_type &&  key)
inline

◆ try_emplace() [1/4]

template<typename TKey , typename TMapped , typename TLessFunc = std::less<TKey>, typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>, typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>, MemManagerStd<TAllocator>>>
template<typename... MappedArgs>
std::pair<iterator, bool> momo::stdish::map< TKey, TMapped, TLessFunc, TAllocator, TTreeMap >::try_emplace ( const key_type key,
MappedArgs &&...  mappedArgs 
)
inline

◆ try_emplace() [2/4]

template<typename TKey , typename TMapped , typename TLessFunc = std::less<TKey>, typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>, typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>, MemManagerStd<TAllocator>>>
template<typename... MappedArgs>
iterator momo::stdish::map< TKey, TMapped, TLessFunc, TAllocator, TTreeMap >::try_emplace ( const_iterator  hint,
const key_type key,
MappedArgs &&...  mappedArgs 
)
inline

◆ try_emplace() [3/4]

template<typename TKey , typename TMapped , typename TLessFunc = std::less<TKey>, typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>, typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>, MemManagerStd<TAllocator>>>
template<typename... MappedArgs>
iterator momo::stdish::map< TKey, TMapped, TLessFunc, TAllocator, TTreeMap >::try_emplace ( const_iterator  hint,
key_type &&  key,
MappedArgs &&...  mappedArgs 
)
inline

◆ try_emplace() [4/4]

template<typename TKey , typename TMapped , typename TLessFunc = std::less<TKey>, typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>, typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>, MemManagerStd<TAllocator>>>
template<typename... MappedArgs>
std::pair<iterator, bool> momo::stdish::map< TKey, TMapped, TLessFunc, TAllocator, TTreeMap >::try_emplace ( key_type &&  key,
MappedArgs &&...  mappedArgs 
)
inline

Friends And Related Function Documentation

◆ erase_if

template<typename TKey , typename TMapped , typename TLessFunc = std::less<TKey>, typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>, typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>, MemManagerStd<TAllocator>>>
template<typename ValueFilter >
size_type erase_if ( map< TKey, TMapped, TLessFunc, TAllocator, TTreeMap > &  cont,
const ValueFilter &  valueFilter 
)
friend

◆ swap

template<typename TKey , typename TMapped , typename TLessFunc = std::less<TKey>, typename TAllocator = std::allocator<std::pair<const TKey, TMapped>>, typename TTreeMap = TreeMap<TKey, TMapped, TreeTraitsStd<TKey, TLessFunc>, MemManagerStd<TAllocator>>>
void swap ( map< TKey, TMapped, TLessFunc, TAllocator, TTreeMap > &  left,
map< TKey, TMapped, TLessFunc, TAllocator, TTreeMap > &  right 
)
friend

The documentation for this class was generated from the following file: