dune-istl  2.6-git
Public Types | Public Member Functions | Protected 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

enum  { blocklevel = B::blocklevel+1 }
 increment block level counter More...
 
typedef B::field_type 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, bool copyOldValues=true)
 Reserve space. More...
 
size_type capacity () const
 Get the capacity of the vector. More...
 
void resize (size_type size, bool copyOldValues=true)
 Resize the vector. More...
 
 BlockVector (const BlockVector &a)
 copy constructor More...
 
 ~BlockVector ()
 free dynamic memory More...
 
BlockVectoroperator= (const BlockVector &a)
 assignment More...
 
BlockVectoroperator= (const field_type &k)
 assign from scalar More...
 
template<class OtherAlloc >
BlockVectoroperator= (const BlockVectorWindow< B, OtherAlloc > &other)
 Assignment from BlockVectorWindow. More...
 

Protected Attributes

size_type capacity_
 
allocator_
 

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>>
typedef B::field_type Dune::BlockVector< B, A >::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.

Member Enumeration Documentation

◆ anonymous enum

template<class B , class A = std::allocator<B>>
anonymous enum

increment block level counter

Enumerator
blocklevel 

The number of blocklevel we contain.

Constructor & Destructor Documentation

◆ BlockVector() [1/5]

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

makes empty vector

◆ BlockVector() [2/5]

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

make vector with _n components

◆ BlockVector() [3/5]

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/5]

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
BlockVector<FieldVector<double,1> > my_vector(100,0);
expecting to obtain a vector of 100 doubles initialized with zero. However, the code calls this constructor which tacitly does something else!

◆ BlockVector() [5/5]

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

copy constructor

◆ ~BlockVector()

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

free dynamic memory

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= ( const BlockVector< B, A > &  a)
inline

assignment

◆ operator=() [2/3]

template<class B , class A = std::allocator<B>>
template<class OtherAlloc >
BlockVector& Dune::BlockVector< B, A >::operator= ( const BlockVectorWindow< B, OtherAlloc > &  other)
inline

Assignment from BlockVectorWindow.

◆ 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,
bool  copyOldValues = true 
)
inline

Reserve space.

After calling this method the vector can hold up to capacity values. If the specified capacity is smaller than the current capacity and bigger than the current size space will be freed.

If the template parameter copyOldValues is true the values will be copied. If it is false the old values are lost.

Parameters
capacityThe maximum number of elements the vector needs to hold.
copyOldValuesIf false no object will be copied and the data might be lost. Default value is true.

◆ resize()

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

Resize the vector.

After calling this method BlockVector::N() will return size If the capacity of the vector is smaller than the specified size then reserve(size) will be called.

If the template parameter copyOldValues is true the values will be copied if the capacity changes. If it is false the old values are lost.

Parameters
sizeThe new size of the vector.
copyOldValuesIf false no object will be copied and the data might be lost.

Member Data Documentation

◆ allocator_

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

◆ capacity_

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

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