Dune Core Modules (2.6.0)

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

#include <dune/istl/bvector.hh>

Public Types

enum  { blocklevel = B::blocklevel+1 }
 increment block level counter More...
 
typedef B::field_type field_type
 export the type representing the field
 
typedef B block_type
 export the type representing the components
 
typedef A allocator_type
 export the allocator type
 
typedef A::size_type size_type
 The type for the index access.
 
typedef Imp::block_vector_unmanaged< B, A >::Iterator Iterator
 make iterators available as types
 
typedef Imp::block_vector_unmanaged< B, A >::ConstIterator ConstIterator
 make iterators available as types
 

Public Member Functions

 BlockVector ()
 makes empty vector
 
 BlockVector (size_type _n)
 make vector with _n components
 
 BlockVector (std::initializer_list< B > const &l)
 Construct from a std::initializer_list.
 
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
 
 ~BlockVector ()
 free dynamic memory
 
BlockVectoroperator= (const BlockVector &a)
 assignment
 
BlockVectoroperator= (const field_type &k)
 assign from scalar
 
template<class OtherAlloc >
BlockVectoroperator= (const BlockVectorWindow< B, OtherAlloc > &other)
 Assignment from BlockVectorWindow.
 

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 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()

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:317
expecting to obtain a vector of 100 doubles initialized with zero. However, the code calls this constructor which tacitly does something else!

References Dune::BlockVector< B, A >::capacity().

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.

Referenced by Dune::BlockVector< B, A >::BlockVector(), and Dune::BlockVector< B, A >::reserve().

◆ 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.

References Dune::BlockVector< B, A >::capacity().

◆ 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.

Referenced by Dune::BlockVector< B, A >::operator=().


The documentation for this class was generated from the following file:
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 24, 23:30, 2024)