MRPT  1.9.9
List of all members | Public Types | Public Member Functions | Private Attributes
mrpt::containers::bimap< KEY, VALUE > Class Template Reference

Detailed Description

template<typename KEY, typename VALUE>
class mrpt::containers::bimap< KEY, VALUE >

A bidirectional version of std::map, declared as bimap<KEY,VALUE> and which actually contains two std::map's, one for keys and another for values.

To use this class, insert new pairs KEY<->VALUE with bimap::insert. Then, you can access the KEY->VALUE map with bimap::direct(), and the VALUE->KEY map with bimap::inverse(). The consistency of the two internal maps is assured at any time.

Note
This class can be accessed through iterators to the map KEY->VALUE only.
Both typenames KEY and VALUE must be suitable for being employed as keys in a std::map, i.e. they must be comparable through a "< operator".
Defined in #include <mrpt/containers/bimap.h>

Definition at line 31 of file bimap.h.

#include <mrpt/containers/bimap.h>

Inheritance diagram for mrpt::containers::bimap< KEY, VALUE >:

Public Types

using const_iterator = typename std::map< KEY, VALUE >::const_iterator
 
using iterator = typename std::map< KEY, VALUE >::iterator
 
using const_iterator_inverse = typename std::map< VALUE, KEY >::const_iterator
 
using iterator_inverse = typename std::map< VALUE, KEY >::iterator
 

Public Member Functions

 bimap ()=default
 Default constructor - does nothing. More...
 
const_iterator begin () const
 
iterator begin ()
 
const_iterator end () const
 
iterator end ()
 
const_iterator_inverse inverse_begin () const
 
iterator_inverse inverse_begin ()
 
const_iterator_inverse inverse_end () const
 
iterator_inverse inverse_end ()
 
size_t size () const
 
bool empty () const
 
const std::map< KEY, VALUE > & getDirectMap () const
 Return a read-only reference to the internal map KEY->VALUES. More...
 
const std::map< VALUE, KEY > & getInverseMap () const
 Return a read-only reference to the internal map KEY->VALUES. More...
 
void clear ()
 Clear the contents of the bi-map. More...
 
void insert (const KEY &k, const VALUE &v)
 Insert a new pair KEY<->VALUE in the bi-map. More...
 
bool direct (const KEY &k, VALUE &out_v) const
 Get the value associated the given key, KEY->VALUE, returning false if not present. More...
 
bool hasKey (const KEY &k) const
 Return true if the given key 'k' is in the bi-map. More...
 
bool hasValue (const VALUE &v) const
 Return true if the given value 'v' is in the bi-map. More...
 
VALUE direct (const KEY &k) const
 Get the value associated the given key, KEY->VALUE, raising an exception if not present. More...
 
bool inverse (const VALUE &v, KEY &out_k) const
 Get the key associated the given value, VALUE->KEY, returning false if not present. More...
 
KEY inverse (const VALUE &v) const
 Get the key associated the given value, VALUE->KEY, raising an exception if not present. More...
 
const_iterator find_key (const KEY &k) const
 
iterator find_key (const KEY &k)
 
const_iterator_inverse find_value (const VALUE &v) const
 
iterator_inverse find_value (const VALUE &v)
 

Private Attributes

std::map< KEY, VALUE > m_k2v
 
std::map< VALUE, KEY > m_v2k
 

Member Typedef Documentation

◆ const_iterator

template<typename KEY, typename VALUE>
using mrpt::containers::bimap< KEY, VALUE >::const_iterator = typename std::map<KEY, VALUE>::const_iterator

Definition at line 38 of file bimap.h.

◆ const_iterator_inverse

template<typename KEY, typename VALUE>
using mrpt::containers::bimap< KEY, VALUE >::const_iterator_inverse = typename std::map<VALUE, KEY>::const_iterator

Definition at line 41 of file bimap.h.

◆ iterator

template<typename KEY, typename VALUE>
using mrpt::containers::bimap< KEY, VALUE >::iterator = typename std::map<KEY, VALUE>::iterator

Definition at line 39 of file bimap.h.

◆ iterator_inverse

template<typename KEY, typename VALUE>
using mrpt::containers::bimap< KEY, VALUE >::iterator_inverse = typename std::map<VALUE, KEY>::iterator

Definition at line 42 of file bimap.h.

Constructor & Destructor Documentation

◆ bimap()

template<typename KEY, typename VALUE>
mrpt::containers::bimap< KEY, VALUE >::bimap ( )
default

Default constructor - does nothing.

Member Function Documentation

◆ begin() [1/2]

template<typename KEY, typename VALUE>
const_iterator mrpt::containers::bimap< KEY, VALUE >::begin ( ) const
inline

Definition at line 46 of file bimap.h.

◆ begin() [2/2]

template<typename KEY, typename VALUE>
iterator mrpt::containers::bimap< KEY, VALUE >::begin ( )
inline

Definition at line 47 of file bimap.h.

◆ clear()

template<typename KEY, typename VALUE>
void mrpt::containers::bimap< KEY, VALUE >::clear ( )
inline

Clear the contents of the bi-map.

Definition at line 64 of file bimap.h.

Referenced by mrpt::slam::CRangeBearingKFSLAM2D::reset(), and mrpt::slam::CRangeBearingKFSLAM::reset().

Here is the caller graph for this function:

◆ direct() [1/2]

template<typename KEY, typename VALUE>
bool mrpt::containers::bimap< KEY, VALUE >::direct ( const KEY &  k,
VALUE &  out_v 
) const
inline

Get the value associated the given key, KEY->VALUE, returning false if not present.

See also
inverse, hasKey, hasValue
Returns
false on key not found.

Definition at line 82 of file bimap.h.

Referenced by mrpt::apps::KFSLAMApp::Run_KF_SLAM().

Here is the caller graph for this function:

◆ direct() [2/2]

template<typename KEY, typename VALUE>
VALUE mrpt::containers::bimap< KEY, VALUE >::direct ( const KEY &  k) const
inline

Get the value associated the given key, KEY->VALUE, raising an exception if not present.

See also
inverse, hasKey, hasValue
Exceptions
std::exceptionOn key not present in the bi-map.

Definition at line 108 of file bimap.h.

◆ empty()

template<typename KEY, typename VALUE>
bool mrpt::containers::bimap< KEY, VALUE >::empty ( ) const
inline

Definition at line 58 of file bimap.h.

◆ end() [1/2]

template<typename KEY, typename VALUE>
const_iterator mrpt::containers::bimap< KEY, VALUE >::end ( ) const
inline

Definition at line 48 of file bimap.h.

Referenced by mrpt::slam::CRangeBearingKFSLAM2D::OnGetObservationsAndDataAssociation(), and mrpt::slam::CRangeBearingKFSLAM::OnGetObservationsAndDataAssociation().

Here is the caller graph for this function:

◆ end() [2/2]

template<typename KEY, typename VALUE>
iterator mrpt::containers::bimap< KEY, VALUE >::end ( )
inline

Definition at line 49 of file bimap.h.

◆ find_key() [1/2]

template<typename KEY, typename VALUE>
const_iterator mrpt::containers::bimap< KEY, VALUE >::find_key ( const KEY &  k) const
inline

Definition at line 140 of file bimap.h.

Referenced by mrpt::slam::CRangeBearingKFSLAM2D::OnGetObservationsAndDataAssociation(), and mrpt::slam::CRangeBearingKFSLAM::OnGetObservationsAndDataAssociation().

Here is the caller graph for this function:

◆ find_key() [2/2]

template<typename KEY, typename VALUE>
iterator mrpt::containers::bimap< KEY, VALUE >::find_key ( const KEY &  k)
inline

Definition at line 141 of file bimap.h.

◆ find_value() [1/2]

template<typename KEY, typename VALUE>
const_iterator_inverse mrpt::containers::bimap< KEY, VALUE >::find_value ( const VALUE &  v) const
inline

Definition at line 142 of file bimap.h.

◆ find_value() [2/2]

template<typename KEY, typename VALUE>
iterator_inverse mrpt::containers::bimap< KEY, VALUE >::find_value ( const VALUE &  v)
inline

Definition at line 146 of file bimap.h.

◆ getDirectMap()

template<typename KEY, typename VALUE>
const std::map<KEY, VALUE>& mrpt::containers::bimap< KEY, VALUE >::getDirectMap ( ) const
inline

Return a read-only reference to the internal map KEY->VALUES.

Definition at line 60 of file bimap.h.

◆ getInverseMap()

template<typename KEY, typename VALUE>
const std::map<VALUE, KEY>& mrpt::containers::bimap< KEY, VALUE >::getInverseMap ( ) const
inline

Return a read-only reference to the internal map KEY->VALUES.

Definition at line 62 of file bimap.h.

Referenced by mrpt::slam::CRangeBearingKFSLAM2D::getCurrentState(), mrpt::slam::CRangeBearingKFSLAM::getCurrentState(), and mrpt::slam::CRangeBearingKFSLAM2D::getLandmarkIDsFromIndexInStateVector().

Here is the caller graph for this function:

◆ hasKey()

template<typename KEY, typename VALUE>
bool mrpt::containers::bimap< KEY, VALUE >::hasKey ( const KEY &  k) const
inline

Return true if the given key 'k' is in the bi-map.

See also
hasValue, direct, inverse

Definition at line 92 of file bimap.h.

Referenced by mrpt::apps::KFSLAMApp::Run_KF_SLAM().

Here is the caller graph for this function:

◆ hasValue()

template<typename KEY, typename VALUE>
bool mrpt::containers::bimap< KEY, VALUE >::hasValue ( const VALUE &  v) const
inline

Return true if the given value 'v' is in the bi-map.

See also
hasKey, direct, inverse

Definition at line 98 of file bimap.h.

Referenced by mrpt::apps::KFSLAMApp::Run_KF_SLAM().

Here is the caller graph for this function:

◆ insert()

template<typename KEY, typename VALUE>
void mrpt::containers::bimap< KEY, VALUE >::insert ( const KEY &  k,
const VALUE &  v 
)
inline

Insert a new pair KEY<->VALUE in the bi-map.

Definition at line 71 of file bimap.h.

Referenced by mrpt::slam::CRangeBearingKFSLAM2D::OnNewLandmarkAddedToMap(), mrpt::slam::CRangeBearingKFSLAM::OnNewLandmarkAddedToMap(), and mrpt::apps::KFSLAMApp::Run_KF_SLAM().

Here is the caller graph for this function:

◆ inverse() [1/2]

template<typename KEY, typename VALUE>
bool mrpt::containers::bimap< KEY, VALUE >::inverse ( const VALUE &  v,
KEY &  out_k 
) const
inline

Get the key associated the given value, VALUE->KEY, returning false if not present.

See also
direct, hasKey, hasValue
Returns
false on value not found.

Definition at line 120 of file bimap.h.

Referenced by mrpt::slam::CRangeBearingKFSLAM::getAs3DObject(), and mrpt::slam::CRangeBearingKFSLAM::getLastPartitionLandmarks().

Here is the caller graph for this function:

◆ inverse() [2/2]

template<typename KEY, typename VALUE>
KEY mrpt::containers::bimap< KEY, VALUE >::inverse ( const VALUE &  v) const
inline

Get the key associated the given value, VALUE->KEY, raising an exception if not present.

See also
direct, hasKey, hasValue
Returns
false on value not found.

Definition at line 133 of file bimap.h.

◆ inverse_begin() [1/2]

template<typename KEY, typename VALUE>
const_iterator_inverse mrpt::containers::bimap< KEY, VALUE >::inverse_begin ( ) const
inline

Definition at line 50 of file bimap.h.

◆ inverse_begin() [2/2]

template<typename KEY, typename VALUE>
iterator_inverse mrpt::containers::bimap< KEY, VALUE >::inverse_begin ( )
inline

Definition at line 54 of file bimap.h.

◆ inverse_end() [1/2]

template<typename KEY, typename VALUE>
const_iterator_inverse mrpt::containers::bimap< KEY, VALUE >::inverse_end ( ) const
inline

Definition at line 55 of file bimap.h.

◆ inverse_end() [2/2]

template<typename KEY, typename VALUE>
iterator_inverse mrpt::containers::bimap< KEY, VALUE >::inverse_end ( )
inline

Definition at line 56 of file bimap.h.

◆ size()

template<typename KEY, typename VALUE>
size_t mrpt::containers::bimap< KEY, VALUE >::size ( ) const
inline

Definition at line 57 of file bimap.h.

Referenced by mrpt::slam::CRangeBearingKFSLAM2D::processActionObservation(), and mrpt::slam::CRangeBearingKFSLAM::processActionObservation().

Here is the caller graph for this function:

Member Data Documentation

◆ m_k2v

template<typename KEY, typename VALUE>
std::map<KEY, VALUE> mrpt::containers::bimap< KEY, VALUE >::m_k2v
private

◆ m_v2k

template<typename KEY, typename VALUE>
std::map<VALUE, KEY> mrpt::containers::bimap< KEY, VALUE >::m_v2k
private



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c7a3bec24 Sun Mar 29 18:33:13 2020 +0200 at dom mar 29 18:50:38 CEST 2020