![]() |
ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
|
Container for objects that are identified by a numeric id. More...
#include <NumeratedContainer.hpp>
Public Types | |
| using | iterator = std::unordered_map< index_type, T >::iterator |
| using | const_iterator = std::unordered_map< index_type, T >::const_iterator |
| using | value_type = std::unordered_map< index_type, T >::value_type |
Public Member Functions | |
| NumeratedContainer () | |
| NumeratedContainer (std::initializer_list< value_type > l) | |
| Construct from list of key-value pairs. | |
| index_type | add (const T &c) |
| Copy c into the container. | |
| index_type | add (T &&c) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | remove (index_type i) |
| Remove element from container. | |
| T & | operator[] (index_type i) |
| Get element from container. | |
| const T & | operator[] (index_type i) const |
| Get element from container. | |
| iterator | begin () |
| Get iterator to beginning of the container. | |
| const_iterator | begin () const |
| Get a const iterator to beginning of the container. | |
| iterator | end () |
| Get an iterator to end of the container. | |
| const_iterator | end () const |
| Get a const iterator to end of the container. | |
| iterator | find (int id) |
| find object by id. | |
| const_iterator | find (int id) const |
| find object by id. | |
| std::size_t | size () const |
Container for objects that are identified by a numeric id.
This class implements a container that holds T instances and references them by an integral index. New elements get the lowest free index and indexes are reused. The Container keeps a copy of the objects added.
Definition at line 40 of file NumeratedContainer.hpp.
| using Utils::NumeratedContainer< T, index_type >::const_iterator = std::unordered_map<index_type, T>::const_iterator |
Definition at line 43 of file NumeratedContainer.hpp.
| using Utils::NumeratedContainer< T, index_type >::iterator = std::unordered_map<index_type, T>::iterator |
Definition at line 42 of file NumeratedContainer.hpp.
| using Utils::NumeratedContainer< T, index_type >::value_type = std::unordered_map<index_type, T>::value_type |
Definition at line 44 of file NumeratedContainer.hpp.
|
inline |
Definition at line 46 of file NumeratedContainer.hpp.
|
inlineexplicit |
Construct from list of key-value pairs.
The keys have to be unique.
Definition at line 55 of file NumeratedContainer.hpp.
References stream.
|
inline |
Copy c into the container.
Assign a free id to c and copy it into the container.
| c | The object to add. |
Definition at line 80 of file NumeratedContainer.hpp.
References stream.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 87 of file NumeratedContainer.hpp.
References stream.
|
inline |
Get iterator to beginning of the container.
Definition at line 128 of file NumeratedContainer.hpp.
|
inline |
Get a const iterator to beginning of the container.
Definition at line 133 of file NumeratedContainer.hpp.
|
inline |
Get an iterator to end of the container.
Definition at line 138 of file NumeratedContainer.hpp.
|
inline |
Get a const iterator to end of the container.
Definition at line 143 of file NumeratedContainer.hpp.
|
inline |
find object by id.
| id | id of the object to find. |
Definition at line 151 of file NumeratedContainer.hpp.
|
inline |
find object by id.
| id | id of the object to find. |
Definition at line 159 of file NumeratedContainer.hpp.
|
inline |
Get element from container.
| i | The object to get. |
Definition at line 115 of file NumeratedContainer.hpp.
|
inline |
Get element from container.
| i | The object to get. |
Definition at line 123 of file NumeratedContainer.hpp.
|
inline |
Remove element from container.
Remove element i and add i to the free indices.
| i | The object to remove. |
Definition at line 101 of file NumeratedContainer.hpp.
References stream.
|
inline |
Definition at line 161 of file NumeratedContainer.hpp.