| 113 | } |
| 114 | |
| 115 | void Swap(std::unordered_map<T, uint64> &indices) { |
| 116 | std::vector<std::unordered_map<T, uint64>> tmp_maps; |
| 117 | tmp_maps.resize(part_count_); |
| 118 | for (int i = 0; i < part_count_; i++) { |
| 119 | hash_maps_[i].Swap(tmp_maps[i]); |
| 120 | } |
| 121 | |
| 122 | indices.clear(); |
| 123 | for (int i = 0; i < part_count_; i++) { |
| 124 | for (auto it : tmp_maps[i]) { |
| 125 | auto indiceIt = indices.find(it.first); |
| 126 | if (indiceIt == indices.end()) { |
| 127 | indices[it.first] = it.second; |
| 128 | } else { |
| 129 | indices[it.first] += it.second; |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | void Clear() { |
| 136 | for (size_t i = 0; i < part_count_; i++) { |