38 #ifndef FCL_BROADPHASE_SIMPLEHASHTABLE_INL_H 39 #define FCL_BROADPHASE_SIMPLEHASHTABLE_INL_H 41 #include "fcl/broadphase/detail/simple_hash_table.h" 52 template<
typename Key,
typename Data,
typename HashFnc>
53 SimpleHashTable<Key, Data, HashFnc>::SimpleHashTable(
const HashFnc& h)
60 template<
typename Key,
typename Data,
typename HashFnc>
65 throw std::logic_error(
"SimpleHashTable must have non-zero size.");
73 template<
typename Key,
typename Data,
typename HashFnc>
76 std::vector<unsigned int> indices = h_(key);
77 size_t range = table_.size();
78 for(
size_t i = 0; i < indices.size(); ++i)
79 table_[indices[i] % range].push_back(value);
83 template<
typename Key,
typename Data,
typename HashFnc>
86 size_t range = table_.size();
87 std::vector<unsigned int> indices = h_(key);
88 std::set<Data> result;
89 for(
size_t i = 0; i < indices.size(); ++i)
91 unsigned int index = indices[i] % range;
92 std::copy(table_[index].begin(), table_[index].end(),
93 std::inserter(result, result.end()));
96 return std::vector<Data>(result.begin(), result.end());
100 template<
typename Key,
typename Data,
typename HashFnc>
103 size_t range = table_.size();
104 std::vector<unsigned int> indices = h_(key);
105 for(
size_t i = 0; i < indices.size(); ++i)
107 unsigned int index = indices[i] % range;
108 table_[index].remove(value);
113 template<
typename Key,
typename Data,
typename HashFnc>
117 table_.resize(table_size_);
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
void init(size_t size)
Init the number of bins in the hash table.
Definition: simple_hash_table-inl.h:61
void clear()
clear the hash table
Definition: simple_hash_table-inl.h:114
void remove(Key key, Data value)
remove the key-value pair from the table
Definition: simple_hash_table-inl.h:101
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:84
A simple hash table implemented as multiple buckets. HashFnc is any extended hash function: HashFnc(k...
Definition: simple_hash_table.h:55