38 #ifndef FCL_BROADPHASE_SPARSEHASHTABLE_INL_H 39 #define FCL_BROADPHASE_SPARSEHASHTABLE_INL_H 50 template <
typename Key,
typename Data,
typename HashFnc,
51 template<
typename,
typename>
class TableT>
59 template <
typename Key,
typename Data,
typename HashFnc,
60 template<
typename,
typename>
class TableT>
67 template <
typename Key,
typename Data,
typename HashFnc,
68 template<
typename,
typename>
class TableT>
71 std::vector<unsigned int> indices =
h_(key);
72 for(
size_t i = 0; i < indices.size(); ++i)
73 table_[indices[i]].push_back(value);
77 template <
typename Key,
typename Data,
typename HashFnc,
78 template<
typename,
typename>
class TableT>
81 std::vector<unsigned int> indices =
h_(key);
82 std::set<Data> result;
83 for(
size_t i = 0; i < indices.size(); ++i)
85 unsigned int index = indices[i];
86 typename Table::const_iterator p =
table_.find(index);
89 std::copy((*p).second.begin(), (*p).second.end(), std
90 ::inserter(result, result.end()));
94 return std::vector<Data>(result.begin(), result.end());
98 template <
typename Key,
typename Data,
typename HashFnc,
99 template<
typename,
typename>
class TableT>
102 std::vector<unsigned int> indices =
h_(key);
103 for(
size_t i = 0; i < indices.size(); ++i)
105 unsigned int index = indices[i];
106 table_[index].remove(value);
111 template <
typename Key,
typename Data,
typename HashFnc,
112 template<
typename,
typename>
class TableT>
void clear()
clear the hash table
void insert(Key key, Data value)
insert one key-value pair into 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
void init(size_t)
Init the hash table. The bucket size is dynamically decided.
void remove(Key key, Data value)
remove one key-value pair from the hash table