16 #ifndef dealii_storage_h
17 #define dealii_storage_h
25 #include <type_traits>
56 "This class requires that the elements of type T are default constructible.");
72 add(
const T &element);
81 remove(
const std::size_t index);
124 std::deque<std::unique_ptr<T>>
data;
130 std::deque<std::unique_ptr<T>>
cache;
140 template <
typename T>
142 : max_n_elements(max_elements)
147 template <
typename T>
152 auto el = std::move(data[ind]);
153 data.erase(data.begin() + ind);
155 cache.push_back(std::move(el));
164 template <
typename T>
168 std::unique_ptr<T> new_el;
169 if (data.size() < max_n_elements)
172 if (cache.size() == 0)
175 new_el = std_cxx14::make_unique<T>(element);
181 new_el = std::move(cache.back());
191 new_el = std::move(data.back());
198 data.push_front(std::move(new_el));
207 template <
typename T>
216 template <
typename T>
225 template <
typename T>
234 template <
typename T>
238 return max_n_elements;
243 template <
typename T>
255 #endif // dealii_storage_h