38 #ifndef HPP_FCL_BROADPHASE_SIMPLEHASHTABLE_INL_H
39 #define HPP_FCL_BROADPHASE_SIMPLEHASHTABLE_INL_H
50 template <
typename Key,
typename Data,
typename HashFnc>
56 template <
typename Key,
typename Data,
typename HashFnc>
68 template <
typename Key,
typename Data,
typename HashFnc>
70 std::vector<unsigned int> indices = h_(key);
71 size_t range = table_.size();
72 for (
size_t i = 0; i < indices.size(); ++i)
73 table_[indices[i] % range].push_back(value);
77 template <
typename Key,
typename Data,
typename HashFnc>
79 size_t range = table_.size();
80 std::vector<unsigned int> indices = h_(key);
81 std::set<Data> result;
82 for (
size_t i = 0; i < indices.size(); ++i) {
83 size_t index = indices[i] % range;
84 std::copy(table_[index].begin(), table_[index].end(),
85 std::inserter(result, result.end()));
88 return std::vector<Data>(result.begin(), result.end());
92 template <
typename Key,
typename Data,
typename HashFnc>
94 size_t range = table_.size();
95 std::vector<unsigned int> indices = h_(key);
96 for (
size_t i = 0; i < indices.size(); ++i) {
97 size_t index = indices[i] % range;
98 table_[index].remove(value);
103 template <
typename Key,
typename Data,
typename HashFnc>
106 table_.resize(table_size_);
SimpleHashTable(const HashFnc &h)
Definition: simple_hash_table-inl.h:51
void insert(Key key, Data value)
Definition: simple_hash_table-inl.h:69
void clear()
clear the hash table
Definition: simple_hash_table-inl.h:104
std::vector< Data > query(Key key) const
Find the elements in the hash table whose key is the same as query key.
Definition: simple_hash_table-inl.h:78
void init(size_t size)
Init the number of bins in the hash table.
Definition: simple_hash_table-inl.h:57
void remove(Key key, Data value)
remove the key-value pair from the table
Definition: simple_hash_table-inl.h:93
#define HPP_FCL_THROW_PRETTY(message, exception)
Definition: fwd.hh:64
Main namespace.
Definition: broadphase_bruteforce.h:44