27 template <
typename KEY,
typename VALUE>
44 inline const_iterator
begin()
const {
return m_k2v.begin(); }
45 inline iterator
begin() {
return m_k2v.begin(); }
46 inline const_iterator
end()
const {
return m_k2v.end(); }
47 inline iterator
end() {
return m_k2v.end(); }
49 inline const_iterator_inverse
inverse_begin()
const {
return m_v2k.begin(); }
51 inline const_iterator_inverse
inverse_end()
const {
return m_v2k.end(); }
54 inline size_t size()
const {
return m_k2v.size(); }
55 inline bool empty()
const {
return m_k2v.empty(); }
69 void insert(
const KEY &k,
const VALUE &v)
79 bool direct(
const KEY &k, VALUE &out_v)
const 81 const_iterator i=m_k2v.find(k);
82 if (i==m_k2v.end())
return false;
88 inline bool hasKey(
const KEY& k)
const {
89 return m_k2v.find(k)!=m_k2v.end();
93 return m_v2k.find(v)!=m_v2k.end();
102 const_iterator i=m_k2v.find(k);
111 bool inverse(
const VALUE &v, KEY &out_k)
const 113 const_iterator_inverse i=m_v2k.find(v);
114 if (i==m_v2k.end())
return false;
125 const_iterator_inverse i=m_v2k.find(v);
131 inline const_iterator
find_key(
const KEY& k)
const {
return m_k2v.find(k); }
132 inline iterator
find_key(
const KEY& k) {
return m_k2v.find(k); }
134 inline const_iterator_inverse
find_value(
const VALUE& v)
const {
return m_v2k.find(v); }
135 inline iterator_inverse
find_value(
const VALUE& v) {
return m_v2k.find(v); }
bool inverse(const VALUE &v, KEY &out_k) const
Get the key associated the given value, VALUE->KEY, returning false if not present.
iterator find_key(const KEY &k)
bool hasKey(const KEY &k) const
Return true if the given key 'k' is in the bi-map.
const_iterator end() const
bimap()
Default constructor - does nothing.
const_iterator_inverse inverse_end() const
std::map< KEY, VALUE >::const_iterator const_iterator
const_iterator_inverse find_value(const VALUE &v) const
bool hasValue(const VALUE &v) const
Return true if the given value 'v' is in the bi-map.
#define THROW_EXCEPTION(msg)
const std::map< VALUE, KEY > & getInverseMap() const
Return a read-only reference to the internal map KEY->VALUES.
std::map< VALUE, KEY >::const_iterator const_iterator_inverse
iterator_inverse inverse_end()
KEY inverse(const VALUE &v) const
Get the key associated the given value, VALUE->KEY, raising an exception if not present.
const Scalar * const_iterator
const_iterator_inverse inverse_begin() const
const std::map< KEY, VALUE > & getDirectMap() const
Return a read-only reference to the internal map KEY->VALUES.
const_iterator find_key(const KEY &k) const
bool direct(const KEY &k, VALUE &out_v) const
Get the value associated the given key, KEY->VALUE, returning false if not present.
A bidirectional version of std::map, declared as bimap<KEY,VALUE> and which actually contains two std...
iterator_inverse find_value(const VALUE &v)
std::map< KEY, VALUE >::iterator iterator
std::map< VALUE, KEY >::iterator iterator_inverse
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
VALUE direct(const KEY &k) const
Get the value associated the given key, KEY->VALUE, raising an exception if not present.
std::map< VALUE, KEY > m_v2k
std::map< KEY, VALUE > m_k2v
void insert(const KEY &k, const VALUE &v)
Insert a new pair KEY<->VALUE in the bi-map.
iterator_inverse inverse_begin()
const_iterator begin() const