MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/CompactNSearch / update_hash_table

Method update_hash_table

src/CompactNSearch.cpp:234–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232}
233
234void
235NeighborhoodSearch::update_hash_table(std::vector<unsigned int>& to_delete)
236{
237 // Indicate points changing inheriting cell.
238 for (unsigned int j = 0; j < m_point_sets.size(); ++j)
239 {
240 PointSet& d = m_point_sets[j];
241 for (unsigned int i = 0; i < d.n_points(); ++i)
242 {
243 if (d.m_keys[i] == d.m_old_keys[i]) continue;
244
245 HashKey const& key = d.m_keys[i];
246 auto it = m_map.find(key);
247 if (it == m_map.end())
248 {
249 m_entries.push_back({{j, i}});
250 m_map.insert({ key, static_cast<unsigned int>(m_entries.size() - 1) });
251 }
252 else
253 {
254 HashEntry& entry = m_entries[it->second];
255 entry.add({j, i});
256 }
257
258 unsigned int entry_index = m_map[d.m_old_keys[i]];
259 m_entries[entry_index].erase({j, i});
260 if (m_erase_empty_cells)
261 {
262 if (m_entries[entry_index].n_indices() == 0)
263 {
264 to_delete.push_back(entry_index);
265 }
266 }
267 }
268 }
269
270 to_delete.erase(std::remove_if(to_delete.begin(), to_delete.end(),
271 [&](unsigned int index)
272 {
273 return m_entries[index].n_indices() != 0;
274 }), to_delete.end());
275 std::sort(to_delete.begin(), to_delete.end(), std::greater<unsigned int>());
276}
277
278void
279NeighborhoodSearch::query()

Callers

nothing calls this directly

Calls 4

n_pointsMethod · 0.80
addMethod · 0.80
eraseMethod · 0.80
n_indicesMethod · 0.80

Tested by

no test coverage detected