70 class ContainerData :
virtual public AttributableData
73 using InternalContainer = T_container;
80 ContainerData() =
default;
82 ContainerData(ContainerData
const &) =
delete;
83 ContainerData(ContainerData &&) =
delete;
85 ContainerData &operator=(ContainerData
const &) =
delete;
86 ContainerData &operator=(ContainerData &&) =
delete;
103class Container :
virtual public Attributable
106 std::is_base_of<Attributable, T>::value,
107 "Type of container element must be derived from Writable");
109 friend class Iteration;
110 friend class ParticleSpecies;
111 friend class ParticlePatches;
116 friend class StatefulIterator;
120 using InternalContainer = T_container;
122 std::shared_ptr<ContainerData> m_containerData;
124 inline void setData(std::shared_ptr<ContainerData> containerData)
126 m_containerData = std::move(containerData);
127 Attributable::setData(m_containerData);
130 inline InternalContainer
const &container()
const
132 return m_containerData->m_container;
135 inline InternalContainer &container()
137 return m_containerData->m_container;
141 using key_type =
typename InternalContainer::key_type;
142 using mapped_type =
typename InternalContainer::mapped_type;
143 using value_type =
typename InternalContainer::value_type;
144 using size_type =
typename InternalContainer::size_type;
145 using difference_type =
typename InternalContainer::difference_type;
146 using allocator_type =
typename InternalContainer::allocator_type;
147 using reference =
typename InternalContainer::reference;
148 using const_reference =
typename InternalContainer::const_reference;
149 using pointer =
typename InternalContainer::pointer;
150 using const_pointer =
typename InternalContainer::const_pointer;
151 using iterator =
typename InternalContainer::iterator;
152 using const_iterator =
typename InternalContainer::const_iterator;
153 using reverse_iterator =
typename InternalContainer::reverse_iterator;
154 using const_reverse_iterator =
155 typename InternalContainer::const_reverse_iterator;
157 iterator begin()
noexcept;
158 const_iterator begin()
const noexcept;
159 const_iterator cbegin()
const noexcept;
161 iterator end()
noexcept;
162 const_iterator end()
const noexcept;
163 const_iterator cend()
const noexcept;
165 reverse_iterator rbegin()
noexcept;
166 const_reverse_iterator rbegin()
const noexcept;
167 const_reverse_iterator crbegin()
const noexcept;
169 reverse_iterator rend()
noexcept;
170 const_reverse_iterator rend()
const noexcept;
171 const_reverse_iterator crend()
const noexcept;
173 bool empty()
const noexcept;
175 size_type size()
const noexcept;
185 std::pair<iterator, bool> insert(value_type
const &value);
186 std::pair<iterator, bool> insert(value_type &&value);
187 iterator insert(const_iterator hint, value_type
const &value);
188 iterator insert(const_iterator hint, value_type &&value);
189 template <
class InputIt>
190 void insert(InputIt first, InputIt last)
192 container().insert(first, last);
194 void insert(std::initializer_list<value_type> ilist);
198 mapped_type &at(key_type
const &key);
199 mapped_type
const &at(key_type
const &key)
const;
224 iterator find(key_type
const &key);
225 const_iterator find(key_type
const &key)
const;
232 size_type
count(key_type
const &key)
const;
250 size_type
erase(key_type
const &key);
257 template <
class... Args>
259 ->
decltype(InternalContainer().emplace(std::forward<Args>(args)...))
261 return container().emplace(std::forward<Args>(args)...);
268 void clear_unchecked();
311 class EraseStaleEntries
314 std::is_same_v<Container_t, std::remove_reference_t<Container_t>>);
315 using key_type =
typename Container_t::key_type;
316 using mapped_type =
typename Container_t::mapped_type;
317 std::set<key_type> m_accessedKeys;
325 Container_t &m_originalContainer;
328 explicit EraseStaleEntries(Container_t &container_in);
330 EraseStaleEntries(EraseStaleEntries &&) =
delete;
331 EraseStaleEntries &operator=(EraseStaleEntries &&) =
delete;
333 mapped_type &operator[](
typename Container_t::key_type
const &k);
335 mapped_type &at(
typename Container_t::key_type
const &k);
342 void forget(
typename Container_t::key_type
const &k);
344 ~EraseStaleEntries();