38 #ifndef HPP_FCL_BROADPHASE_SPARSEHASHTABLE_INL_H 39 #define HPP_FCL_BROADPHASE_SPARSEHASHTABLE_INL_H 49 template <
typename Key,
typename Data,
typename HashFnc,
50 template <
typename,
typename>
class TableT>
57 template <
typename Key,
typename Data,
typename HashFnc,
58 template <
typename,
typename>
class TableT>
64 template <
typename Key,
typename Data,
typename HashFnc,
65 template <
typename,
typename>
class TableT>
67 std::vector<unsigned int> indices =
h_(key);
68 for (
size_t i = 0; i < indices.size(); ++i)
69 table_[indices[i]].push_back(value);
73 template <
typename Key,
typename Data,
typename HashFnc,
74 template <
typename,
typename>
class TableT>
77 std::vector<unsigned int> indices =
h_(key);
78 std::set<Data> result;
79 for (
size_t i = 0; i < indices.size(); ++i) {
80 unsigned int index = indices[i];
81 typename Table::const_iterator p =
table_.find(index);
83 std::copy((*p).second.begin(), (*p).second.end(),
84 std ::inserter(result, result.end()));
88 return std::vector<Data>(result.begin(), result.end());
92 template <
typename Key,
typename Data,
typename HashFnc,
93 template <
typename,
typename>
class TableT>
95 std::vector<unsigned int> indices =
h_(key);
96 for (
size_t i = 0; i < indices.size(); ++i) {
97 unsigned int index = indices[i];
103 template <
typename Key,
typename Data,
typename HashFnc,
104 template <
typename,
typename>
class TableT>
void init(size_t)
Init the hash table. The bucket size is dynamically decided.
void insert(Key key, Data value)
insert one key-value pair into the hash table
void remove(Key key, Data value)
remove one key-value pair from the hash table
void clear()
clear the hash table
SparseHashTable(const HashFnc &h)
std::vector< Data > query(Key key) const
find the elements whose key is the same as the query