| 194 | // Invalidates all iterators. |
| 195 | template<typename Value> |
| 196 | void SparseSetT<Value>::resize(int new_max_size) { |
| 197 | DebugCheckInvariants(); |
| 198 | if (new_max_size > max_size()) { |
| 199 | const int old_max_size = max_size(); |
| 200 | |
| 201 | // Construct these first for exception safety. |
| 202 | PODArray<int> a(new_max_size); |
| 203 | PODArray<int> b(new_max_size); |
| 204 | |
| 205 | std::copy_n(sparse_.data(), old_max_size, a.data()); |
| 206 | std::copy_n(dense_.data(), old_max_size, b.data()); |
| 207 | |
| 208 | sparse_ = std::move(a); |
| 209 | dense_ = std::move(b); |
| 210 | |
| 211 | MaybeInitializeMemory(old_max_size, new_max_size); |
| 212 | } |
| 213 | if (size_ > new_max_size) |
| 214 | size_ = new_max_size; |
| 215 | DebugCheckInvariants(); |
| 216 | } |
| 217 | |
| 218 | // Check whether index i is in the set. |
| 219 | template<typename Value> |