Essentia  2.1-beta6-dev
EssentiaMap< KeyType, ValueType, Compare > Class Template Reference

#include <types.h>

Inheritance diagram for EssentiaMap< KeyType, ValueType, Compare >:

Public Types

typedef std::map< KeyType, ValueType, Compare > BaseClass
 

Public Member Functions

ValueType & operator[] (const KeyType &key)
 
const ValueType & operator[] (const KeyType &key) const
 
std::pair< typename BaseClass::iterator, bool > insert (const KeyType &key, const ValueType &value)
 
std::vector< std::string > keys () const
 

Detailed Description

template<typename KeyType, typename ValueType, typename Compare = std::less<KeyType>>
class essentia::EssentiaMap< KeyType, ValueType, Compare >

Special version of a std::map that allows us to use the [] operator on a const object. In this case, if the key is found, it returns the associated value, otherwise it throws an exception. If not used on a constant object, it also throws an exception if the key is not found, in order to have a consistent behavior. It also redefines the insert() method to be more convenient.

Member Typedef Documentation

◆ BaseClass

typedef std::map<KeyType, ValueType, Compare> BaseClass

Member Function Documentation

◆ insert()

std::pair<typename BaseClass::iterator, bool> insert ( const KeyType &  key,
const ValueType &  value 
)
inline

◆ keys()

std::vector<std::string> keys ( ) const
inline

◆ operator[]() [1/2]

ValueType& operator[] ( const KeyType &  key)
inline

Classic version of the map accessor.

References EssentiaMap< KeyType, ValueType, Compare >::keys().

◆ operator[]() [2/2]

const ValueType& operator[] ( const KeyType &  key) const
inline

New version that can be called on a constant object and instead of creating a new null object and inserting it in the map just throws an exception.

References EssentiaMap< KeyType, ValueType, Compare >::keys().


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