Removes `value` from the set. Assumes `value` is already present in the set.
| 46 | // Removes `value` from the set. Assumes `value` is already present in the |
| 47 | // set. |
| 48 | void Erase(T value) { |
| 49 | auto it = value_to_index_.find(value); |
| 50 | DCHECK(it != value_to_index_.end()); |
| 51 | |
| 52 | // Since we don't want to move values around in `value_sequence_` we swap |
| 53 | // the value in the last position and with value to be deleted and then |
| 54 | // pop_back. |
| 55 | value_to_index_[value_sequence_.back()] = it->second; |
| 56 | std::swap(value_sequence_[it->second], value_sequence_.back()); |
| 57 | value_sequence_.pop_back(); |
| 58 | value_to_index_.erase(it); |
| 59 | } |
| 60 | |
| 61 | void Reserve(size_t new_size) { |
| 62 | value_to_index_.reserve(new_size); |