38 #ifndef FCL_BROADPHASE_SIMPLEHASHTABLE_INL_H 39 #define FCL_BROADPHASE_SIMPLEHASHTABLE_INL_H 52 template<
typename Key,
typename Data,
typename HashFnc>
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;
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>
void init(size_t size)
Init the number of bins in the hash table.
void clear()
clear the hash table
void remove(Key key, Data value)
remove the key-value pair from the table
SimpleHashTable(const HashFnc &h)
std::vector< Bin > table_
std::vector< Data > query(Key key) const
Find the elements in the hash table whose key is the same as query key.
void insert(Key key, Data value)