Container with a vector-of-vectors structure. More...
#include <block_vector.h>
Public Types | |
| using | value_type = value_type_ |
| using | difference_type = typename std::vector< value_type >::difference_type |
| using | const_reference = const value_type& |
| using | const_pointer = const value_type* |
| using | iterator = bv_iterator< value_type_, value_type_&, value_type_* > |
| using | const_iterator = bv_iterator< value_type_, const value_type_&, const value_type_* > |
| using | reverse_iterator = std::reverse_iterator< iterator > |
| using | const_reverse_iterator = std::reverse_iterator< const_iterator > |
| using | size_type = size_t |
Public Member Functions | |
| BlockVector () | |
| Creates an empty BlockVector. | |
| BlockVector (size_t) | |
| Creates a BlockVector containing a number of elements. | |
| BlockVector (const BlockVector< value_type_ > &) | |
| BlockVector copy constructor. | |
| virtual | ~BlockVector () |
| value_type_ & | operator[] (const size_t pos) |
| Subscript access to the data contained in the BlockVector. | |
| const value_type_ & | operator[] (const size_t pos) const |
| Subscript access to the data contained in the BlockVector. | |
| iterator | begin () |
| Returns a read/write iterator that points to the first element in the BlockVector. | |
| const_iterator | begin () const |
| Returns a read-only (constant) iterator that points to the first element in the BlockVector. | |
| iterator | end () |
| Returns a read/write iterator that points one past the last element in the BlockVector. | |
| const_iterator | end () const |
| Returns a read-only (constant) iterator that points one past the last element in the BlockVector. | |
| void | push_back (const value_type_ &value) |
| Add data to the end of the BlockVector. | |
| void | push_back (value_type_ &&value) |
| Move data to the end of the BlockVector. | |
| void | clear () |
| Erases all the elements. | |
| size_t | size () const |
| Returns the number of elements in the BlockVector. | |
| iterator | erase (const_iterator, const_iterator) |
| Remove a range of elements. | |
| void | print_blocks () const |
| Writes the contents of the BlockVector, separated into blocks, to cerr. | |
| int | get_max_block_size () const |
| Returns the block-size. | |
| size_type | max_size () const |
| Returns the size() of the largest possible BlockVector. | |
| reverse_iterator | rbegin () |
| Returns a read/write reverse iterator that points to the last element in the BlockVector. | |
| reverse_iterator | rbegin () const |
| Returns a read-only (constant) reverse iterator that points to the last element in the BlockVector. | |
| reverse_iterator | rend () |
| Returns a read/write reverse iterator that points to one before the first element in the BlockVector. | |
| reverse_iterator | rend () const |
| Returns a read-only (constant) reverse iterator that points to one before the first element in the BlockVector. | |
Private Attributes | |
| std::vector< std::vector< value_type_ > > | blockmap_ |
| Vector holding blocks containing data. | |
| iterator | finish_ |
| Iterator pointing to one past the last element. | |
Friends | |
| template<typename cv_value_type_, typename ref_, typename ptr_> | |
| class | bv_iterator |
Container with a vector-of-vectors structure.
| value_type_ | Type of element. |
Elements are stored in blocks held in a blockmap. Each block is of fixed size, with elements default-initialised on creation of the block. A new block is automatically created when a block is filled. The size of each block is a power of two, which allows use of bitwise operators to efficiently map an index to the right block and the right position in that block.
| using BlockVector< value_type_ >::const_iterator = bv_iterator< value_type_, const value_type_&, const value_type_* > |
| using BlockVector< value_type_ >::const_pointer = const value_type* |
| using BlockVector< value_type_ >::const_reference = const value_type& |
| using BlockVector< value_type_ >::const_reverse_iterator = std::reverse_iterator< const_iterator > |
| using BlockVector< value_type_ >::difference_type = typename std::vector< value_type >::difference_type |
| using BlockVector< value_type_ >::iterator = bv_iterator< value_type_, value_type_&, value_type_* > |
| using BlockVector< value_type_ >::reverse_iterator = std::reverse_iterator< iterator > |
| using BlockVector< value_type_ >::size_type = size_t |
| using BlockVector< value_type_ >::value_type = value_type_ |
| BlockVector< value_type_ >::BlockVector | ( | ) |
Creates an empty BlockVector.
References begin(), blockmap_, finish_, and max_block_size.
Referenced by BlockVector().
|
explicit |
Creates a BlockVector containing a number of elements.
| n | Number of elements. |
References begin(), blockmap_, finish_, and max_block_size.
|
inline |
BlockVector copy constructor.
| other | BlockVector to copy. |
References begin(), blockmap_, BlockVector(), and finish_.
|
inlinevirtualdefault |
|
inline |
Returns a read/write iterator that points to the first element in the BlockVector.
Iteration is done in ordinary element order.
Referenced by BlockVector(), BlockVector(), BlockVector(), nest::SourceTable::clean(), clear(), nest::SourceTable::compute_buffer_pos_for_unique_secondary_sources(), erase(), print_blocks(), nest::SourceTable::remove_disabled_sources(), and nest::sort().
|
inline |
Returns a read-only (constant) iterator that points to the first element in the BlockVector.
Iteration is done in ordinary element order.
| void BlockVector< value_type_ >::clear | ( | ) |
Erases all the elements.
References begin(), blockmap_, finish_, and max_block_size.
Referenced by nest::SourceTable::clean(), and erase().
|
inline |
Returns a read/write iterator that points one past the last element in the BlockVector.
Iteration is done in ordinary element order.
References finish_.
Referenced by nest::SourceTable::clean(), erase(), print_blocks(), nest::SourceTable::remove_disabled_sources(), and nest::sort().
|
inline |
Returns a read-only (constant) iterator that points one past the last element in the BlockVector.
Iteration is done in ordinary element order.
References finish_.
| BlockVector< value_type_ >::iterator BlockVector< value_type_ >::erase | ( | const_iterator | first, |
| const_iterator | last ) |
Remove a range of elements.
| first | Iterator pointing to the first element to be erased. |
| last | Iterator pointing one past the last element to be erased. |
This function will erase the elements in the range [first, last) and shorten the BlockVector accordingly.
References begin(), bv_iterator< value_type_, ref_, ptr_ >::block_vector_, blockmap_, clear(), bv_iterator< value_type_, ref_, ptr_ >::const_cast_(), end(), finish_, and max_block_size.
Referenced by nest::SourceTable::clean(), and nest::SourceTable::remove_disabled_sources().
|
inline |
Returns the block-size.
References max_block_size.
|
inline |
Returns the size() of the largest possible BlockVector.
|
inline |
Subscript access to the data contained in the BlockVector.
| pos | The index of the element for which data should be accessed. |
Note that data access with this operator is unchecked.
References block_size_shift, blockmap_, and max_block_size_sub_1.
|
inline |
Subscript access to the data contained in the BlockVector.
| pos | The index of the element for which data should be accessed. |
Note that data access with this operator is unchecked.
References block_size_shift, blockmap_, and max_block_size_sub_1.
| void BlockVector< value_type_ >::print_blocks | ( | ) | const |
Writes the contents of the BlockVector, separated into blocks, to cerr.
References begin(), blockmap_, end(), and finish_.
| void BlockVector< value_type_ >::push_back | ( | const value_type_ & | value | ) |
Add data to the end of the BlockVector.
| value | Data to be added. |
Assigns given data to the element at the end of the BlockVector.
References blockmap_, finish_, and max_block_size.
| void BlockVector< value_type_ >::push_back | ( | value_type_ && | value | ) |
Move data to the end of the BlockVector.
| value | Data to be moved to end of BlockVector. |
Moves given data to the element at the end of the BlockVector.
References blockmap_, finish_, and max_block_size.
|
inline |
Returns a read/write reverse iterator that points to the last element in the BlockVector.
Iteration is done in reverse element order.
|
inline |
Returns a read-only (constant) reverse iterator that points to the last element in the BlockVector.
Iteration is done in reverse element order.
|
inline |
Returns a read/write reverse iterator that points to one before the first element in the BlockVector.
Iteration is done in reverse element order.
|
inline |
Returns a read-only (constant) reverse iterator that points to one before the first element in the BlockVector.
Iteration is done in reverse element order.
|
inline |
Returns the number of elements in the BlockVector.
References blockmap_, finish_, and max_block_size.
Referenced by nest::SourceTable::clean(), nest::quicksort3way(), nest::SourceTable::remove_disabled_sources(), and nest::sort().
|
friend |
|
private |
Vector holding blocks containing data.
Referenced by BlockVector(), BlockVector(), BlockVector(), clear(), erase(), operator[](), operator[](), print_blocks(), push_back(), push_back(), and size().
|
private |
Iterator pointing to one past the last element.
Referenced by BlockVector(), BlockVector(), BlockVector(), clear(), end(), end(), erase(), print_blocks(), push_back(), push_back(), and size().