38 #ifndef FCL_BROADPHASE_SPARSEHASHTABLE_INL_H 39 #define FCL_BROADPHASE_SPARSEHASHTABLE_INL_H 41 #include "fcl/broadphase/detail/sparse_hash_table.h" 50 template <
typename Key,
typename Data,
typename HashFnc,
51 template<
typename,
typename>
class TableT>
52 SparseHashTable<Key, Data, HashFnc, TableT>::SparseHashTable(
const HashFnc& h)
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>
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
void clear()
clear the hash table
Definition: sparse_hash_table-inl.h:113
void insert(Key key, Data value)
insert one key-value pair into the hash table
Definition: sparse_hash_table-inl.h:69
std::vector< Data > query(Key key) const
find the elements whose key is the same as the query
Definition: sparse_hash_table-inl.h:79
void init(size_t)
Init the hash table. The bucket size is dynamically decided.
Definition: sparse_hash_table-inl.h:61
void remove(Key key, Data value)
remove one key-value pair from the hash table
Definition: sparse_hash_table-inl.h:100