Build hash table and entry array from scratch.
| 76 | |
| 77 | // Build hash table and entry array from scratch. |
| 78 | void |
| 79 | NeighborhoodSearch::init() |
| 80 | { |
| 81 | m_entries.clear(); |
| 82 | m_map.clear(); |
| 83 | |
| 84 | // Determine existing entries. |
| 85 | std::vector<HashKey> temp_keys; |
| 86 | for (unsigned int j = 0; j < m_point_sets.size(); ++j) |
| 87 | { |
| 88 | PointSet& d = m_point_sets[j]; |
| 89 | d.m_locks.resize(d.n_points()); |
| 90 | for (unsigned int i = 0; i < d.n_points(); i++) |
| 91 | { |
| 92 | HashKey const& key = cell_index(d.point(i)); |
| 93 | d.m_keys[i] = d.m_old_keys[i] = key; |
| 94 | auto it = m_map.find(key); |
| 95 | if (it == m_map.end()) |
| 96 | { |
| 97 | m_entries.push_back({{ j, i }}); |
| 98 | temp_keys.push_back(key); |
| 99 | m_map[key] = static_cast<unsigned int>(m_entries.size() - 1); |
| 100 | } |
| 101 | else |
| 102 | { |
| 103 | m_entries[it->second].add({j, i}); |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | m_map.clear(); |
| 109 | for (unsigned int i = 0; i < m_entries.size(); ++i) |
| 110 | { |
| 111 | m_map.emplace(temp_keys[i], i); |
| 112 | } |
| 113 | |
| 114 | m_initialized = true; |
| 115 | } |
| 116 | |
| 117 | |
| 118 | void |