18 #ifndef BIDIRECTIONAL_MAP_HH_ 19 #define BIDIRECTIONAL_MAP_HH_ 22 #include <unordered_map> 40 unsigned int size()
const;
48 void set_item(T val,
unsigned int pos);
60 void reserve(
unsigned int init_size = 0);
101 typename std::unordered_map<T, unsigned int>::const_iterator iter =
vals_map_.find(val);
103 else return iter->second;
126 #endif // BIDIRECTIONAL_MAP_HH_ BidirectionalMap()
Constructor.
#define ASSERT_EQ_DBG(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
unsigned int size() const
Return size of map.
void reserve(unsigned int init_size=0)
Reset data of map, reserve space for given size.
std::vector< T > vals_vec_
Space to save values.
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
unsigned int add_item(T val)
Add new item at the end position of map.
std::unordered_map< T, unsigned int > vals_map_
Maps values to indexes into vals_vec_.
void set_item(T val, unsigned int pos)
int get_position(T val) const
Return position of item of given value.
T operator[](unsigned int pos) const
Return value on given position.
Bidirectional map templated by <T, unsigned int>.
void clear()
Clear the content. Do not release memory.
#define ASSERT_LT_DBG(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.