NEST main@caf0ae8
 
Loading...
Searching...
No Matches
BlockVector< value_type_ > Class Template Reference

Container with a vector-of-vectors structure. More...

#include <block_vector.h>

Inheritance diagram for BlockVector< value_type_ >:
[legend]
Collaboration diagram for BlockVector< value_type_ >:
[legend]

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
 

Detailed Description

template<typename value_type_>
class BlockVector< value_type_ >

Container with a vector-of-vectors structure.

Template Parameters
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.

Member Typedef Documentation

◆ const_iterator

template<typename value_type_ >
using BlockVector< value_type_ >::const_iterator = bv_iterator< value_type_, const value_type_&, const value_type_* >

◆ const_pointer

template<typename value_type_ >
using BlockVector< value_type_ >::const_pointer = const value_type*

◆ const_reference

template<typename value_type_ >
using BlockVector< value_type_ >::const_reference = const value_type&

◆ const_reverse_iterator

template<typename value_type_ >
using BlockVector< value_type_ >::const_reverse_iterator = std::reverse_iterator< const_iterator >

◆ difference_type

template<typename value_type_ >
using BlockVector< value_type_ >::difference_type = typename std::vector< value_type >::difference_type

◆ iterator

template<typename value_type_ >
using BlockVector< value_type_ >::iterator = bv_iterator< value_type_, value_type_&, value_type_* >

◆ reverse_iterator

template<typename value_type_ >
using BlockVector< value_type_ >::reverse_iterator = std::reverse_iterator< iterator >

◆ size_type

template<typename value_type_ >
using BlockVector< value_type_ >::size_type = size_t

◆ value_type

template<typename value_type_ >
using BlockVector< value_type_ >::value_type = value_type_

Constructor & Destructor Documentation

◆ BlockVector() [1/3]

template<typename value_type_ >
BlockVector< value_type_ >::BlockVector ( )

Creates an empty BlockVector.

◆ BlockVector() [2/3]

template<typename value_type_ >
BlockVector< value_type_ >::BlockVector ( size_t  n)
explicit

Creates a BlockVector containing a number of elements.

Parameters
nNumber of elements.

References BlockVector< value_type_ >::begin(), BlockVector< value_type_ >::blockmap_, BlockVector< value_type_ >::finish_, and max_block_size.

Here is the call graph for this function:

◆ BlockVector() [3/3]

template<typename value_type_ >
BlockVector< value_type_ >::BlockVector ( const BlockVector< value_type_ > &  other)
inline

BlockVector copy constructor.

Parameters
otherBlockVector to copy.

◆ ~BlockVector()

template<typename value_type_ >
BlockVector< value_type_ >::~BlockVector ( )
inlinevirtualdefault

Member Function Documentation

◆ begin() [1/2]

template<typename value_type_ >
BlockVector< value_type_ >::iterator BlockVector< value_type_ >::begin ( )
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< value_type_ >::BlockVector(), nest::SourceTable::clean(), nest::Connector< ConnectionT >::remove_disabled_connections(), nest::SourceTable::remove_disabled_sources(), and nest::sort().

Here is the caller graph for this function:

◆ begin() [2/2]

template<typename value_type_ >
BlockVector< value_type_ >::const_iterator BlockVector< value_type_ >::begin ( ) const
inline

Returns a read-only (constant) iterator that points to the first element in the BlockVector.

Iteration is done in ordinary element order.

◆ clear()

template<typename value_type_ >
void BlockVector< value_type_ >::clear ( )

Erases all the elements.

References max_block_size.

Referenced by nest::SourceTable::clean(), and nest::Connector< ConnectionT >::~Connector().

Here is the caller graph for this function:

◆ end() [1/2]

template<typename value_type_ >
BlockVector< value_type_ >::iterator BlockVector< value_type_ >::end ( )
inline

Returns a read/write iterator that points one past the last element in the BlockVector.

Iteration is done in ordinary element order.

Referenced by nest::SourceTable::clean(), nest::SourceTable::clear(), nest::Connector< ConnectionT >::remove_disabled_connections(), nest::SourceTable::remove_disabled_sources(), nest::SourceTable::reset_processed_flags(), and nest::sort().

Here is the caller graph for this function:

◆ end() [2/2]

template<typename value_type_ >
BlockVector< value_type_ >::const_iterator BlockVector< value_type_ >::end ( ) const
inline

Returns a read-only (constant) iterator that points one past the last element in the BlockVector.

Iteration is done in ordinary element order.

◆ erase()

template<typename value_type_ >
BlockVector< value_type_ >::iterator BlockVector< value_type_ >::erase ( const_iterator  first,
const_iterator  last 
)

Remove a range of elements.

Parameters
firstIterator pointing to the first element to be erased.
lastIterator pointing one past the last element to be erased.
Returns
An iterator pointing to the element pointed to by last prior to erasing (or end()).

This function will erase the elements in the range [first, last) and shorten the BlockVector accordingly.

References bv_iterator< value_type_, ref_, ptr_ >::block_vector_, bv_iterator< value_type_, ref_, ptr_ >::const_cast_(), and max_block_size.

Referenced by nest::SourceTable::clean(), nest::Connector< ConnectionT >::remove_disabled_connections(), and nest::SourceTable::remove_disabled_sources().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_max_block_size()

template<typename value_type_ >
int BlockVector< value_type_ >::get_max_block_size ( ) const
inline

Returns the block-size.

References max_block_size.

◆ max_size()

template<typename value_type_ >
BlockVector< value_type_ >::size_type BlockVector< value_type_ >::max_size ( ) const
inline

Returns the size() of the largest possible BlockVector.

◆ operator[]() [1/2]

template<typename value_type_ >
value_type_ & BlockVector< value_type_ >::operator[] ( const size_t  pos)
inline

Subscript access to the data contained in the BlockVector.

Parameters
posThe index of the element for which data should be accessed.
Returns
Read/write reference to data.

Note that data access with this operator is unchecked.

References block_size_shift, and max_block_size_sub_1.

◆ operator[]() [2/2]

template<typename value_type_ >
const value_type_ & BlockVector< value_type_ >::operator[] ( const size_t  pos) const
inline

Subscript access to the data contained in the BlockVector.

Parameters
posThe index of the element for which data should be accessed.
Returns
Read-only (constant) reference to data.

Note that data access with this operator is unchecked.

References block_size_shift, and max_block_size_sub_1.

◆ print_blocks()

template<typename value_type_ >
void BlockVector< value_type_ >::print_blocks ( ) const

Writes the contents of the BlockVector, separated into blocks, to cerr.

References bv_iterator< value_type_, ref_, ptr_ >::block_vector_.

◆ push_back() [1/2]

template<typename value_type_ >
void BlockVector< value_type_ >::push_back ( const value_type_ &  value)

Add data to the end of the BlockVector.

Parameters
valueData to be added.

Assigns given data to the element at the end of the BlockVector.

References bv_iterator< value_type_, ref_, ptr_ >::block_vector_, bv_iterator< value_type_, ref_, ptr_ >::block_vector_it_, and max_block_size.

Referenced by nest::Connector< ConnectionT >::get_connection(), nest::Connector< ConnectionT >::get_connection_with_specified_targets(), nest::Connector< ConnectionT >::get_source_lcids(), nest::Connector< ConnectionT >::push_back(), and nest::Connector< ConnectionT >::push_back().

Here is the caller graph for this function:

◆ push_back() [2/2]

template<typename value_type_ >
void BlockVector< value_type_ >::push_back ( value_type_ &&  value)

Move data to the end of the BlockVector.

Parameters
valueData to be moved to end of BlockVector.

Moves given data to the element at the end of the BlockVector.

References max_block_size.

◆ rbegin() [1/2]

template<typename value_type_ >
BlockVector< value_type_ >::reverse_iterator BlockVector< value_type_ >::rbegin ( )
inline

Returns a read/write reverse iterator that points to the last element in the BlockVector.

Iteration is done in reverse element order.

◆ rbegin() [2/2]

template<typename value_type_ >
BlockVector< value_type_ >::reverse_iterator BlockVector< value_type_ >::rbegin ( ) const
inline

Returns a read-only (constant) reverse iterator that points to the last element in the BlockVector.

Iteration is done in reverse element order.

◆ rend() [1/2]

template<typename value_type_ >
BlockVector< value_type_ >::reverse_iterator BlockVector< value_type_ >::rend ( )
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.

◆ rend() [2/2]

template<typename value_type_ >
BlockVector< value_type_ >::reverse_iterator BlockVector< value_type_ >::rend ( ) const
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.

◆ size()

Friends And Related Symbol Documentation

◆ bv_iterator

template<typename value_type_ >
template<typename cv_value_type_ , typename ref_ , typename ptr_ >
friend class bv_iterator
friend

Member Data Documentation

◆ blockmap_

template<typename value_type_ >
std::vector< std::vector< value_type_ > > BlockVector< value_type_ >::blockmap_
private

Vector holding blocks containing data.

Referenced by BlockVector< value_type_ >::BlockVector().

◆ finish_

template<typename value_type_ >
iterator BlockVector< value_type_ >::finish_
private

Iterator pointing to one past the last element.

Referenced by BlockVector< value_type_ >::BlockVector().


The documentation for this class was generated from the following file: