20 template <
typename KEY,
typename VALUE >
48 unsigned int NUM_BYTES_HASH_TABLE = 1,
49 unsigned int NUM_HAS_TABLE_COLLISIONS_ALLOWED = 5,
57 typedef ts_hash_map<KEY, VALUE, NUM_BYTES_HASH_TABLE, NUM_HAS_TABLE_COLLISIONS_ALLOWED, VECTOR_T> self_t;
59 typedef ts_map_entry<KEY,VALUE> value_type;
60 typedef VECTOR_T vec_t;
67 const_iterator(
const VECTOR_T &vec,
const self_t &parent,
int idx_outer,
int idx_inner) :
m_vec(const_cast<VECTOR_T*>(&vec)), m_parent(const_cast<self_t*>(&parent)), m_idx_outer(idx_outer), m_idx_inner(idx_inner) {}
71 const value_type &
operator *()
const {
return (*
m_vec)[m_idx_outer][m_idx_inner]; }
72 const value_type * operator ->()
const {
return &(*m_vec)[m_idx_outer][m_idx_inner]; }
78 int m_idx_outer, m_idx_inner;
82 if (++m_idx_inner >= (
int)NUM_HAS_TABLE_COLLISIONS_ALLOWED) {
86 }
while (m_idx_outer<(
int)m_parent->m_vec.size() && !(*m_vec)[m_idx_outer][m_idx_inner].used);
94 iterator(VECTOR_T &vec, self_t &parent,
int idx_outer,
int idx_inner) :
const_iterator(vec,parent,idx_outer,idx_inner) {}
96 value_type * operator ->() {
return &(*const_iterator::m_vec)[const_iterator::m_idx_outer][const_iterator::m_idx_inner]; }
115 for (
size_t oi = 0; oi <
m_vec.size(); oi++)
116 for (
size_t ii = 0; ii < NUM_HAS_TABLE_COLLISIONS_ALLOWED; ii++)
117 m_vec[oi][ii] = value_type();
127 for (
unsigned int i = 0; i < NUM_HAS_TABLE_COLLISIONS_ALLOWED; i++)
129 if (!match_arr[i].used) {
131 match_arr[i].used =
true;
132 match_arr[i].first = key;
133 return match_arr[i].second;
135 if (match_arr[i].
first == key)
return match_arr[i].second;
143 for (
unsigned int i = 0; i < NUM_HAS_TABLE_COLLISIONS_ALLOWED; i++)
145 if (match_arr[i].used && match_arr[i].
first == key)
const_iterator end() const
bool operator!=(const CArray< T, N > &x, const CArray< T, N > &y)
unsigned __int16 uint16_t
ts_hash_map()
< Default constructor */
iterator operator++(int)
A thread-safe (ts) container which minimally emulates a std::map<>'s [] and find() methods but which ...
#define THROW_EXCEPTION(msg)
const_iterator begin() const
Usage: uint_select_by_bytecount<N>type var; allows defining var as a unsigned integer with...
const Scalar * const_iterator
const_iterator find(const KEY &key) const
void clear()
Clear the contents of this container.
A STL container (as wrapper) for arrays of constant size defined at compile time. ...
VALUE & operator[](const KEY &key)
Write/read via [i] operator, that creates an element if it didn't exist already.
GLsizei const GLchar ** string
void BASE_IMPEXP reduced_hash(const std::string &value, uint8_t &hash)
hash function used by ts_hash_map. Uses dbj2 method
size_t m_size
Number of elements accessed with write access so far.
vec_t m_vec
The actual container.
unsigned __int64 uint64_t
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
bool operator==(const CArray< T, N > &x, const CArray< T, N > &y)
GLsizei const GLfloat * value
unsigned __int32 uint32_t
std::vector< T1 > operator*(const std::vector< T1 > &a, const std::vector< T2 > &b)
a*b (element-wise multiplication)