1 #ifndef FAST_RESET_VECTOR_H
2 #define FAST_RESET_VECTOR_H
9 class FastResetVector {
11 FastResetVector(
size_t size, T && init_value_in)
12 : init_value(init_value_in), round(1), data(size, std::pair<T, unsigned int>(init_value, 0))
19 const T & operator[](
size_t index)
const
21 if (data[index].second != this->round) {
22 return this->init_value;
24 return data[index].first;
28 T & operator[](
size_t index)
30 if (data[index].second != this->round) {
31 data[index] = {this->init_value, this->round};
34 return data[index].first;
40 std::vector<std::pair<T, unsigned int>> data;