![]() |
ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
|
Bag of elements. More...
#include <Bag.hpp>
Public Types | |
| using | value_type = T |
| using | iterator = T * |
| using | const_iterator = const T * |
| using | pointer = T * |
| using | reference = T & |
Public Member Functions | |
| Bag ()=default | |
| Construct an empty container. | |
| iterator | begin () |
| iterator | end () |
| const_iterator | begin () const |
| const_iterator | end () const |
| std::size_t | size () const |
| Number of elements in the container. | |
| bool | empty () const |
| Is the container empty? | |
| std::size_t | capacity () const |
| Capacity of the container. | |
| std::size_t | max_size () const |
| Maximum number of elements the container can hold. | |
| void | reserve (std::size_t new_capacity) |
| Reserve storage. | |
| void | resize (std::size_t new_size) |
| Resize container. | |
| void | clear () |
| Remove all elements form container. | |
| T & | insert (T const &v) |
| Insert an element into the container. | |
| T & | insert (T &&v) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| iterator | erase (iterator it) |
| Remove element from the list. | |
Friends | |
| void | swap (Bag &lhs, Bag &rhs) |
| Swap two Bags. | |
Bag of elements.
A bag is a container in which the elements do not have a fixed order. It can be considered an unordered variant of vector, and implements the Container named requirement specified in C++11.
Elements in the container do not have a stable position and removing elements can change the order of the other elements. The looser contract (compared to a vector) allows removing any element in the container in constant time.
| T | Element type, needs to be Swappable. |
| using Utils::Bag< T >::const_iterator = const T * |
| using Utils::Bag< T >::iterator = T * |
| using Utils::Bag< T >::pointer = T * |
| using Utils::Bag< T >::reference = T & |
| using Utils::Bag< T >::value_type = T |
|
default |
Construct an empty container.
References stream.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 83 of file Bag.hpp.
References Utils::Bag< T >::size().
|
inline |
Definition at line 85 of file Bag.hpp.
References Utils::Bag< T >::size().
|
inline |
|
inline |
|
inline |
Insert an element into the container.
If before the call size() >= capacity(), this may reallocate, in which case all iterators into the container are invalidated. Otherwise only the end iterator is invalidated.
| v | Element to add. |
|
inline |
|
inline |
|
inline |
Resize container.
Newly added Ts are default-initialized. If the new size is larger than the capacity, all iterators into the container are invalidated.
| new_size | Size to resize to. |
Definition at line 129 of file Bag.hpp.
Referenced by prepare_ghost_cell().
|
inline |
Number of elements in the container.
Definition at line 90 of file Bag.hpp.
Referenced by Utils::Bag< T >::end(), and Utils::Bag< T >::end().