26 template <
typename KEY,
typename VALUE>
43 inline const_iterator
begin()
const {
return m_k2v.begin(); }
44 inline iterator
begin() {
return m_k2v.begin(); }
45 inline const_iterator
end()
const {
return m_k2v.end(); }
46 inline iterator
end() {
return m_k2v.end(); }
48 inline const_iterator_inverse
inverse_begin()
const {
return m_v2k.begin(); }
50 inline const_iterator_inverse
inverse_end()
const {
return m_v2k.end(); }
53 inline size_t size()
const {
return m_k2v.size(); }
54 inline bool empty()
const {
return m_k2v.empty(); }
68 void insert(
const KEY &k,
const VALUE &v)
78 bool direct(
const KEY &k, VALUE &out_v)
const
80 const_iterator i=m_k2v.find(k);
81 if (i==m_k2v.end())
return false;
87 inline bool hasKey(
const KEY& k)
const {
88 return m_k2v.find(k)!=m_k2v.end();
92 return m_v2k.find(v)!=m_v2k.end();
101 const_iterator i=m_k2v.find(k);
110 bool inverse(
const VALUE &v, KEY &out_k)
const
112 const_iterator_inverse i=m_v2k.find(v);
113 if (i==m_v2k.end())
return false;
124 const_iterator_inverse i=m_v2k.find(v);
130 inline const_iterator
find_key(
const KEY& k)
const {
return m_k2v.find(k); }
131 inline iterator
find_key(
const KEY& k) {
return m_k2v.find(k); }
133 inline const_iterator_inverse
find_value(
const VALUE& v)
const {
return m_v2k.find(v); }
134 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 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