|
Stride Reference Manual
- generated for commit 9643b11
|
Container that stores objects "almost contiguously" (in a chain of blocks) and guarantees that pointers/iterators are not invalidated when the container grows. More...
#include <SegmentedVector.h>


Public Types | |
| using | value_type = T |
| using | size_type = std::size_t |
| using | self_type = SegmentedVector< T, N > |
| using | iterator = SVIterator< T, N, Safe, T *, T &, false > |
| using | const_iterator = SVIterator< T, N, Safe > |
Public Member Functions | |
| SegmentedVector () | |
| Construct empty SegmentedVector. More... | |
| SegmentedVector (size_type i) | |
| Construct with given number of elements but DO NOT INITIALIZE them. More... | |
| SegmentedVector (size_type i, const value_type &value) | |
| Construct with given number of elements and INITIALIZE them with value. More... | |
| SegmentedVector (const self_type &other) | |
| Copy constructor. More... | |
| SegmentedVector (self_type &&other) noexcept | |
| Move constructor. More... | |
| SegmentedVector & | operator= (const self_type &other) |
| Copy assignment. More... | |
| SegmentedVector & | operator= (self_type &&other) noexcept |
| Move assignment. More... | |
| ~SegmentedVector () | |
| Destructor. More... | |
| T & | at (std::size_t pos) |
| Access specified element with bounds checking. More... | |
| const T & | at (std::size_t pos) const |
| Access specified element with bounds checking. More... | |
| T & | back () |
| Access the last element. More... | |
| const T & | back () const |
| Access the last element. More... | |
| T & | operator[] (size_t pos) |
| Access specified element (no bounds checking). More... | |
| const T & | operator[] (size_t pos) const |
| Access specified element (no bounds checking). More... | |
| iterator | begin () |
| Returns an iterator to the beginning of the container. More... | |
| const_iterator | begin () const |
| Returns a const_iterator to the beginning of the container. More... | |
| const_iterator | cbegin () const |
| Returns a const_iterator to the beginning of the container. More... | |
| iterator | end () |
| Returns an iterator to the end of the container. More... | |
| const_iterator | end () const |
| Returns a const_iterator to the end of the container. More... | |
| const_iterator | cend () const |
| Returns a const_iterator to the end. More... | |
| std::size_t | capacity () const |
| Returns number of elements that can be stored without allocating additional blocks. More... | |
| bool | empty () const |
| Checks whether container is empty. More... | |
| std::size_t | get_block_count () const |
| Returns number of currently allocated blocks. More... | |
| std::size_t | get_elements_per_block () const |
| Returns number of elements block (template parameter 'N'). More... | |
| std::size_t | size () const |
| Returns the number of elements. More... | |
| void | resize (size_type new_size) |
| Increases the number of elements (but DOES NOT INITIALIZE the additional elements) or pops elements (and DOES RUN those element's destructor). More... | |
| void | resize (size_type new_size, const value_type &value) |
| void | clear () |
| Clears the content. More... | |
| template<class... Args> | |
| T * | emplace (size_type pos, Args &&...args) |
| Constructs element in-place at position pos. More... | |
| template<class... Args> | |
| T * | emplace_back (Args &&...args) |
| Constructs element in-place at the end. More... | |
| void | pop_back () |
| Removes the last element. More... | |
| T * | push_back (const T &obj) |
| Adds element to end. More... | |
| T * | push_back (T &&obj) |
| Adds element to end. More... | |
Private Types | |
| using | Chunk = typename std::aligned_storage< sizeof(T), std::alignment_of< T >::value >::type |
| POD type with same alignment requirement as for T's. More... | |
Private Member Functions | |
| T * | get_chunk () |
| Get next available chunk for element construction with placement new. More... | |
Private Attributes | |
| std::vector< Chunk * > | m_blocks |
| Vector registers pointers to blocks of chunks. More... | |
| size_t | m_size |
| Index of first free chunk when indexed contiguously. More... | |
Friends | |
| class | SVIterator< T, N, Safe > |
| class | SVIterator< T, N, Safe, T *, T &, false > |
Container that stores objects "almost contiguously" (in a chain of blocks) and guarantees that pointers/iterators are not invalidated when the container grows.
Elements are assigned to the container either sequentially through push_back and emplace_back or through direct adressing with emplace, at or the subscript operator. It supports most familiar operators except reserve (no need for advance reservation of capacity to avoid re-allocation that invalidates pointers as in std::vector) and insertion/deletion.
Template parameters: T type of elements stored in the container N block size i.e. number of elements per block
Definition at line 53 of file SegmentedVector.h.
| using stride::util::SegmentedVector< T, N, Safe >::value_type = T |
Definition at line 59 of file SegmentedVector.h.
| using stride::util::SegmentedVector< T, N, Safe >::size_type = std::size_t |
Definition at line 60 of file SegmentedVector.h.
| using stride::util::SegmentedVector< T, N, Safe >::self_type = SegmentedVector<T, N> |
Definition at line 61 of file SegmentedVector.h.
| using stride::util::SegmentedVector< T, N, Safe >::iterator = SVIterator<T, N, Safe, T*, T&, false> |
Definition at line 62 of file SegmentedVector.h.
| using stride::util::SegmentedVector< T, N, Safe >::const_iterator = SVIterator<T, N, Safe> |
Definition at line 63 of file SegmentedVector.h.
|
private |
POD type with same alignment requirement as for T's.
Definition at line 335 of file SegmentedVector.h.
|
inlineexplicit |
Construct empty SegmentedVector.
CAVEAT: if you resize itbut do not subsequently initialize all elements, the SegmentedVector destructor or a call to clear will cause a segmentation fault because of the destructor call on unitilialezed elements.
Definition at line 73 of file SegmentedVector.h.
|
inlineexplicit |
Construct with given number of elements but DO NOT INITIALIZE them.
CAVEAT: if you resize (as you do here) but do not subsequently initialize all elements, the SegmentedVector destructor or a call to clear will cause a segmentation fault because of the destructor call on unitilialezed elements.
Definition at line 79 of file SegmentedVector.h.
|
inlineexplicit |
Construct with given number of elements and INITIALIZE them with value.
CAVEAT: if you resize (as you do here) but do not subsequently initialize all elements, the SegmentedVector destructor or a call to clear will cause a segmentation fault because of the destructor call on unitilialezed elements.
Definition at line 85 of file SegmentedVector.h.
|
inlineexplicit |
Copy constructor.
Definition at line 88 of file SegmentedVector.h.
|
inlineexplicitnoexcept |
Move constructor.
Definition at line 98 of file SegmentedVector.h.
|
inline |
Destructor.
Definition at line 129 of file SegmentedVector.h.
|
inline |
Copy assignment.
Definition at line 104 of file SegmentedVector.h.
|
inlinenoexcept |
Move assignment.
Definition at line 118 of file SegmentedVector.h.
|
inline |
Access specified element with bounds checking.
Definition at line 136 of file SegmentedVector.h.
Referenced by stride::util::SegmentedVector< Person, 2048 >::pop_back().

|
inline |
Access specified element with bounds checking.
Definition at line 145 of file SegmentedVector.h.
|
inline |
Access the last element.
Definition at line 154 of file SegmentedVector.h.
|
inline |
Access the last element.
Definition at line 157 of file SegmentedVector.h.
|
inline |
Access specified element (no bounds checking).
Definition at line 163 of file SegmentedVector.h.
|
inline |
Access specified element (no bounds checking).
Definition at line 166 of file SegmentedVector.h.
|
inline |
Returns an iterator to the beginning of the container.
Definition at line 176 of file SegmentedVector.h.
|
inline |
Returns a const_iterator to the beginning of the container.
Definition at line 179 of file SegmentedVector.h.
|
inline |
Returns a const_iterator to the beginning of the container.
Definition at line 182 of file SegmentedVector.h.
Referenced by stride::util::operator==().

|
inline |
Returns an iterator to the end of the container.
Definition at line 185 of file SegmentedVector.h.
Referenced by stride::util::SegmentedVector< Person, 2048 >::begin(), and stride::util::SegmentedVector< Person, 2048 >::cbegin().

|
inline |
Returns a const_iterator to the end of the container.
Definition at line 188 of file SegmentedVector.h.
|
inline |
Returns a const_iterator to the end.
Definition at line 191 of file SegmentedVector.h.
Referenced by stride::util::operator==().

|
inline |
Returns number of elements that can be stored without allocating additional blocks.
Definition at line 198 of file SegmentedVector.h.
Referenced by stride::util::SegmentedVector< Person, 2048 >::resize().

|
inline |
Checks whether container is empty.
Definition at line 201 of file SegmentedVector.h.
|
inline |
Returns number of currently allocated blocks.
Definition at line 204 of file SegmentedVector.h.
Referenced by stride::util::SegmentedVector< Person, 2048 >::resize().

|
inline |
Returns number of elements block (template parameter 'N').
Definition at line 207 of file SegmentedVector.h.
|
inline |
Returns the number of elements.
Definition at line 210 of file SegmentedVector.h.
Referenced by stride::util::SegmentedVector< Person, 2048 >::cend(), stride::util::SegmentedVector< Person, 2048 >::clear(), stride::Immunizer::Cocoon(), stride::util::SegmentedVector< Person, 2048 >::end(), stride::util::SegmentedVector< Person, 2048 >::resize(), stride::SurveySeeder::Seed(), and stride::Sim::TimeStep().

|
inline |
Increases the number of elements (but DOES NOT INITIALIZE the additional elements) or pops elements (and DOES RUN those element's destructor).
CAVEAT: if you resize (as you do here) but do not subsequently initialize all elements, the SegmentedVector destructor or a call to clear will cause a segmentation fault because of the destructor call on unitilialezed elements.
Definition at line 221 of file SegmentedVector.h.
Referenced by stride::util::SegmentedVector< Person, 2048 >::resize(), and stride::util::SegmentedVector< Person, 2048 >::SegmentedVector().

|
inline |
Definition at line 252 of file SegmentedVector.h.
|
inline |
Clears the content.
Definition at line 266 of file SegmentedVector.h.
Referenced by stride::util::SegmentedVector< Person, 2048 >::operator=(), and stride::util::SegmentedVector< Person, 2048 >::~SegmentedVector().

|
inline |
Constructs element in-place at position pos.
Definition at line 284 of file SegmentedVector.h.
|
inline |
Constructs element in-place at the end.
Definition at line 293 of file SegmentedVector.h.
|
inline |
Removes the last element.
Definition at line 300 of file SegmentedVector.h.
Referenced by stride::util::SegmentedVector< Person, 2048 >::resize().

|
inline |
Adds element to end.
Definition at line 320 of file SegmentedVector.h.
Referenced by stride::util::SegmentedVector< Person, 2048 >::operator=(), stride::util::SegmentedVector< Person, 2048 >::resize(), and stride::util::SegmentedVector< Person, 2048 >::SegmentedVector().

|
inline |
Adds element to end.
Definition at line 327 of file SegmentedVector.h.
|
inlineprivate |
Get next available chunk for element construction with placement new.
Definition at line 343 of file SegmentedVector.h.
Referenced by stride::util::SegmentedVector< Person, 2048 >::emplace_back(), and stride::util::SegmentedVector< Person, 2048 >::push_back().

|
friend |
Definition at line 338 of file SegmentedVector.h.
|
friend |
Definition at line 339 of file SegmentedVector.h.
|
private |
Vector registers pointers to blocks of chunks.
Definition at line 357 of file SegmentedVector.h.
Referenced by stride::util::SegmentedVector< Person, 2048 >::at(), stride::util::SegmentedVector< Person, 2048 >::back(), stride::util::SegmentedVector< Person, 2048 >::capacity(), stride::util::SegmentedVector< Person, 2048 >::clear(), stride::util::SegmentedVector< Person, 2048 >::emplace(), stride::util::SegmentedVector< Person, 2048 >::get_block_count(), stride::util::SegmentedVector< Person, 2048 >::get_chunk(), stride::util::SegmentedVector< Person, 2048 >::operator=(), stride::util::SegmentedVector< Person, 2048 >::operator[](), stride::util::SegmentedVector< Person, 2048 >::pop_back(), stride::util::SegmentedVector< Person, 2048 >::resize(), and stride::util::SegmentedVector< Person, 2048 >::SegmentedVector().
|
private |
Index of first free chunk when indexed contiguously.
Definition at line 358 of file SegmentedVector.h.
Referenced by stride::util::SegmentedVector< Person, 2048 >::at(), stride::util::SegmentedVector< Person, 2048 >::back(), stride::util::SegmentedVector< Person, 2048 >::begin(), stride::util::SegmentedVector< Person, 2048 >::cbegin(), stride::util::SegmentedVector< Person, 2048 >::clear(), stride::util::SegmentedVector< Person, 2048 >::emplace(), stride::util::SegmentedVector< Person, 2048 >::empty(), stride::util::SegmentedVector< Person, 2048 >::get_chunk(), stride::util::SegmentedVector< Person, 2048 >::operator=(), stride::util::SegmentedVector< Person, 2048 >::pop_back(), stride::util::SegmentedVector< Person, 2048 >::resize(), stride::util::SegmentedVector< Person, 2048 >::SegmentedVector(), and stride::util::SegmentedVector< Person, 2048 >::size().