dune-istl 2.9.0
Public Types | Public Member Functions | Static Public Attributes | List of all members
Dune::BlockVector< B, A > Class Template Reference

A vector of blocks with memory management. More...

#include <dune/istl/bvector.hh>

Inheritance diagram for Dune::BlockVector< B, A >:
Inheritance graph

Public Types

using field_type = typename Imp::BlockTraits< B >::field_type
 export the type representing the field More...
 
typedef B block_type
 export the type representing the components More...
 
typedef A allocator_type
 export the allocator type More...
 
typedef A::size_type size_type
 The type for the index access. More...
 
typedef Imp::block_vector_unmanaged< B, A >::Iterator Iterator
 make iterators available as types More...
 
typedef Imp::block_vector_unmanaged< B, A >::ConstIterator ConstIterator
 make iterators available as types More...
 

Public Member Functions

 BlockVector ()
 makes empty vector More...
 
 BlockVector (size_type _n)
 make vector with _n components More...
 
 BlockVector (std::initializer_list< B > const &l)
 Construct from a std::initializer_list. More...
 
template<typename S >
 BlockVector (size_type _n, S _capacity)
 Make vector with _n components but preallocating capacity components. More...
 
void reserve (size_type capacity)
 Reserve space. More...
 
size_type capacity () const
 Get the capacity of the vector. More...
 
void resize (size_type size)
 Resize the vector. More...
 
 BlockVector (const BlockVector &a) noexcept(noexcept(std::declval< BlockVector >().storage_=a.storage_))
 copy constructor More...
 
 BlockVector (BlockVector &&a) noexcept(noexcept(std::declval< BlockVector >().swap(a)))
 move constructor More...
 
BlockVectoroperator= (const BlockVector &a) noexcept(noexcept(std::declval< BlockVector >().storage_=a.storage_))
 assignment More...
 
BlockVectoroperator= (BlockVector &&a) noexcept(noexcept(std::declval< BlockVector >().swap(a)))
 move assignment More...
 
void swap (BlockVector &other) noexcept(noexcept(std::declval< BlockVector & >().storage_.swap(other.storage_)))
 swap operation More...
 
BlockVectoroperator= (const field_type &k)
 assign from scalar More...
 

Static Public Attributes

static constexpr unsigned int blocklevel = blockLevel<B>()+1
 increment block level counter More...
 

Detailed Description

template<class B, class A = std::allocator<B>>
class Dune::BlockVector< B, A >

A vector of blocks with memory management.

BlockVector adds memory management with ordinary copy semantics to the block_vector_unmanaged template.

Error checking: no error checking is provided normally.
Setting the compile time switch DUNE_ISTL_WITH_CHECKING
enables error checking.

Member Typedef Documentation

◆ allocator_type

template<class B , class A = std::allocator<B>>
typedef A Dune::BlockVector< B, A >::allocator_type

export the allocator type

◆ block_type

template<class B , class A = std::allocator<B>>
typedef B Dune::BlockVector< B, A >::block_type

export the type representing the components

◆ ConstIterator

template<class B , class A = std::allocator<B>>
typedef Imp::block_vector_unmanaged<B,A>::ConstIterator Dune::BlockVector< B, A >::ConstIterator

make iterators available as types

◆ field_type

template<class B , class A = std::allocator<B>>
using Dune::BlockVector< B, A >::field_type = typename Imp::BlockTraits<B>::field_type

export the type representing the field

◆ Iterator

template<class B , class A = std::allocator<B>>
typedef Imp::block_vector_unmanaged<B,A>::Iterator Dune::BlockVector< B, A >::Iterator

make iterators available as types

◆ size_type

template<class B , class A = std::allocator<B>>
typedef A::size_type Dune::BlockVector< B, A >::size_type

The type for the index access.

Constructor & Destructor Documentation

◆ BlockVector() [1/6]

template<class B , class A = std::allocator<B>>
Dune::BlockVector< B, A >::BlockVector ( )
inline

makes empty vector

◆ BlockVector() [2/6]

template<class B , class A = std::allocator<B>>
Dune::BlockVector< B, A >::BlockVector ( size_type  _n)
inlineexplicit

make vector with _n components

◆ BlockVector() [3/6]

template<class B , class A = std::allocator<B>>
Dune::BlockVector< B, A >::BlockVector ( std::initializer_list< B > const &  l)
inline

Construct from a std::initializer_list.

◆ BlockVector() [4/6]

template<class B , class A = std::allocator<B>>
template<typename S >
Dune::BlockVector< B, A >::BlockVector ( size_type  _n,
_capacity 
)
inline

Make vector with _n components but preallocating capacity components.

If _n > capacity then space for _n entries is allocated.

Note
This constructor is somewhat dangerous. People may be tempted to write something like
A vector of blocks with memory management.
Definition: bvector.hh:395
expecting to obtain a vector of 100 doubles initialized with zero. However, the code calls this constructor which tacitly does something else!

◆ BlockVector() [5/6]

template<class B , class A = std::allocator<B>>
Dune::BlockVector< B, A >::BlockVector ( const BlockVector< B, A > &  a)
inlinenoexcept

copy constructor

◆ BlockVector() [6/6]

template<class B , class A = std::allocator<B>>
Dune::BlockVector< B, A >::BlockVector ( BlockVector< B, A > &&  a)
inlinenoexcept

move constructor

Member Function Documentation

◆ capacity()

template<class B , class A = std::allocator<B>>
size_type Dune::BlockVector< B, A >::capacity ( ) const
inline

Get the capacity of the vector.

I. e. the maximum number of elements the vector can hold.

Returns
The capacity of the vector.

◆ operator=() [1/3]

template<class B , class A = std::allocator<B>>
BlockVector & Dune::BlockVector< B, A >::operator= ( BlockVector< B, A > &&  a)
inlinenoexcept

move assignment

◆ operator=() [2/3]

template<class B , class A = std::allocator<B>>
BlockVector & Dune::BlockVector< B, A >::operator= ( const BlockVector< B, A > &  a)
inlinenoexcept

assignment

◆ operator=() [3/3]

template<class B , class A = std::allocator<B>>
BlockVector & Dune::BlockVector< B, A >::operator= ( const field_type k)
inline

assign from scalar

◆ reserve()

template<class B , class A = std::allocator<B>>
void Dune::BlockVector< B, A >::reserve ( size_type  capacity)
inline

Reserve space.

Allocate storage for up to capacity blocks. Resizing won't cause reallocation until the size exceeds the capacity

Parameters
capacityThe maximum number of elements the vector needs to hold.

◆ resize()

template<class B , class A = std::allocator<B>>
void Dune::BlockVector< B, A >::resize ( size_type  size)
inline

Resize the vector.

Resize the vector to the given number of blocks. Blocks below the given size are copied (moved if possible). Old blocks above the given size are destructed, new blocks above the given size are value-initialized.

Parameters
sizeThe new number of blocks of the vector.

◆ swap()

template<class B , class A = std::allocator<B>>
void Dune::BlockVector< B, A >::swap ( BlockVector< B, A > &  other)
inlinenoexcept

swap operation

Member Data Documentation

◆ blocklevel

template<class B , class A = std::allocator<B>>
constexpr unsigned int Dune::BlockVector< B, A >::blocklevel = blockLevel<B>()+1
staticconstexpr

increment block level counter


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