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 | |
typedef std::unordered_map< index_type, T >::iterator | iterator |
typedef std::unordered_map< index_type, T >::const_iterator | const_iterator |
typedef std::unordered_map< index_type, T >::value_type | 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 41 of file NumeratedContainer.hpp.
typedef std::unordered_map<index_type,T>::const_iterator Utils::NumeratedContainer< T, index_type >::const_iterator |
Definition at line 45 of file NumeratedContainer.hpp.
typedef std::unordered_map<index_type,T>::iterator Utils::NumeratedContainer< T, index_type >::iterator |
Definition at line 43 of file NumeratedContainer.hpp.
typedef std::unordered_map<index_type,T>::value_type Utils::NumeratedContainer< T, index_type >::value_type |
Definition at line 46 of file NumeratedContainer.hpp.
|
inline |
Definition at line 48 of file NumeratedContainer.hpp.
|
inlineexplicit |
Construct from list of key-value pairs.
The keys have to be unique.
Definition at line 57 of file NumeratedContainer.hpp.
|
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 82 of file NumeratedContainer.hpp.
|
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 89 of file NumeratedContainer.hpp.
|
inline |
Get iterator to beginning of the container.
Definition at line 130 of file NumeratedContainer.hpp.
|
inline |
Get a const iterator to beginning of the container.
Definition at line 135 of file NumeratedContainer.hpp.
|
inline |
Get an iterator to end of the container.
Definition at line 140 of file NumeratedContainer.hpp.
|
inline |
Get a const iterator to end of the container.
Definition at line 145 of file NumeratedContainer.hpp.
|
inline |
find object by id.
id | id of the object to find. |
Definition at line 153 of file NumeratedContainer.hpp.
|
inline |
find object by id.
id | id of the object to find. |
Definition at line 161 of file NumeratedContainer.hpp.
|
inline |
Get element from container.
i | The object to get. |
Definition at line 117 of file NumeratedContainer.hpp.
|
inline |
Get element from container.
i | The object to get. |
Definition at line 125 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 103 of file NumeratedContainer.hpp.
|
inline |
Definition at line 163 of file NumeratedContainer.hpp.