Dune Core Modules (2.7.1)
A vector of blocks with memory management. More...
#include <dune/istl/bvector.hh>
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) |
Reserve space. More... | |
void | reserve (size_type capacity, bool copyOldValues) |
Reserve space. More... | |
size_type | capacity () const |
Get the capacity of the vector. More... | |
void | resize (size_type size) |
Resize the vector. More... | |
void | resize (size_type size, bool copyOldValues) |
Resize the vector. More... | |
BlockVector (const BlockVector &a) noexcept(noexcept(std::declval< BlockVector >().storage_=a.storage_)) | |
copy constructor | |
BlockVector (BlockVector &&a) noexcept(noexcept(std::declval< BlockVector >().swap(a))) | |
move constructor | |
BlockVector & | operator= (const BlockVector &a) noexcept(noexcept(std::declval< BlockVector >().storage_=a.storage_)) |
assignment | |
BlockVector & | operator= (BlockVector &&a) noexcept(noexcept(std::declval< BlockVector >().swap(a))) |
move assignment | |
void | swap (BlockVector &other) noexcept(noexcept(std::declval< BlockVector & >().storage_.swap(other.storage_))) |
swap operation | |
BlockVector & | operator= (const field_type &k) |
assign from scalar | |
Static Public Attributes | |
static constexpr unsigned int | blocklevel = Imp::BlockTraits<B>::blockLevel()+1 |
increment block level counter | |
Detailed Description
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.
Constructor & Destructor Documentation
◆ BlockVector()
|
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 expecting to obtain a vector of 100 doubles initialized with zero. However, the code calls this constructor which tacitly does something else!BlockVector<FieldVector<double,1> > my_vector(100,0);
Member Function Documentation
◆ capacity()
|
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 >::reserve().
◆ reserve() [1/2]
|
inline |
Reserve space.
Allocate storage for up to capacity
blocks. Resizing won't cause reallocation until the size exceeds the capacity
- Parameters
-
capacity The maximum number of elements the vector needs to hold.
References DUNE_UNUSED.
Referenced by Dune::BlockVector< B, A >::reserve().
◆ reserve() [2/2]
|
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
-
capacity The maximum number of elements the vector needs to hold. copyOldValues Ignored, values are always copied.
- Deprecated:
- This method is deprecated, since the extra copyOldValues parameter is unusual, and the previous implementation did not always reduce memory anyway.
- Deprecated:
- "Use the overload without the second parameter, " "values are always copied"
References Dune::BlockVector< B, A >::capacity(), and Dune::BlockVector< B, A >::reserve().
◆ resize() [1/2]
|
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
-
size The new number of blocks of the vector.
◆ resize() [2/2]
|
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
-
size The new size of the vector. copyOldValues Ignored, values are always copied.
- Deprecated:
- This method is deprecated, since the extra copyOldValues parameter is unusual and conflicts with the usual meaning (default value for newly created elements).
- Deprecated:
- "Use the overload without the second parameter, " "values are always copied"
The documentation for this class was generated from the following file:
- dune/istl/bvector.hh