5#ifndef DUNE_ISTL_VBVECTOR_HH
6#define DUNE_ISTL_VBVECTOR_HH
14#include <dune/common/iteratorfacades.hh>
41 template<
class B,
class A=std::allocator<B> >
48 typedef Imp::BlockVectorWindow<B,A> window_type;
55 using field_type =
typename Imp::BlockTraits<B>::field_type;
89 [[deprecated(
"Use free function blockLevel(). Will be removed after 2.8.")]]
114 block = windowAllocator_.allocate(nblocks);
115 new (block) window_type[nblocks];
140 this->p = allocator_.allocate(this->n);
141 new (this->p)B[this->n];
154 block = windowAllocator_.allocate(nblocks);
155 new (block) window_type[nblocks];
159 block[i].set(m,this->p+(i*m));
179 this->p = allocator_.allocate(this->n);
180 new (this->p)B[this->n];
183 for (
size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
196 block = windowAllocator_.allocate(nblocks);
197 new (block) window_type[nblocks];
200 block[0].set(a.block[0].getsize(),this->p);
202 block[i].set(a.block[i].getsize(),block[i-1].getptr()+block[i-1].getsize());
221 allocator_.deallocate(this->p,this->n);
226 block[--i].~window_type();
227 windowAllocator_.deallocate(block,nblocks);
241 allocator_.deallocate(this->p,this->n);
246 block[--i].~window_type();
247 windowAllocator_.deallocate(block,nblocks);
256 block = windowAllocator_.allocate(nblocks);
257 new (block) window_type[nblocks];
277 allocator_.deallocate(this->p,this->n);
282 block[--i].~window_type();
283 windowAllocator_.deallocate(block,nblocks);
290 this->p = allocator_.allocate(this->n);
291 new (this->p)B[this->n];
304 block = windowAllocator_.allocate(nblocks);
305 new (block) window_type[nblocks];
309 block[i].set(m,this->p+(i*m));
328 if (this->n!=a.n || nblocks!=a.nblocks)
335 allocator_.deallocate(this->p,this->n);
340 block[--i].~window_type();
341 windowAllocator_.deallocate(block,nblocks);
349 this->p = allocator_.allocate(this->n);
350 new (this->p)B[this->n];
363 block = windowAllocator_.allocate(nblocks);
364 new (block) window_type[nblocks];
377 block[0].set(a.block[0].getsize(),this->p);
379 block[i].set(a.block[i].getsize(),block[i-1].getptr()+block[i-1].getsize());
383 for (
size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
398 (
static_cast<Imp::block_vector_unmanaged<B,A>&
>(*this)) =
k;
419 return target->getsize();
424 target->setsize(
size);
477 if (
not isEnd && i==v.nblocks &&
not v.initialized)
501 return (i!=
it.i) || (&v!=&
it.v);
507 return (i==
it.i) && (&v==&
it.v);
519 v.block[i].setsize(
_k);
545#ifdef DUNE_ISTL_WITH_CHECKING
565#ifdef DUNE_ISTL_WITH_CHECKING
574#ifdef DUNE_ISTL_WITH_CHECKING
581 template <
class T,
class R>
583 :
public RandomAccessIteratorFacade<RealIterator<T,R>, T, R>
613 return (p+i)==(
it.p+
it.i);
714 return Iterator(block,std::min(i,nblocks));
744 if (this->initialized)
745 DUNE_THROW(
ISTLError,
"Attempt to re-allocate already initialized VariableBlockVector");
750 this->n += block[i].size();
757 this->p = allocator_.allocate(this->n);
758 new (this->p)B[this->n];
766 this->block[0].setptr(this->p);
768 block[j].setptr(block[j-1].getptr()+block[j-1].getsize());
771 this->initialized =
true;
780 typename std::allocator_traits<A>::template rebind_alloc<window_type> windowAllocator_;
Helper functions for determining the vector/matrix block level.
This file implements a vector space as a tensor product of a given vector space. The number of compon...
Definition allocator.hh:11
derive error class from the base class in common
Definition istlexception.hh:19
A Vector of blocks with different blocksizes.
Definition vbvector.hh:46
RealIterator< value_type, window_type & > Iterator
Definition vbvector.hh:649
VariableBlockVector()
Definition vbvector.hh:97
friend class CreateIterator
Definition vbvector.hh:540
typename Imp::BlockTraits< B >::field_type field_type
export the type representing the field
Definition vbvector.hh:55
A allocator_type
export the allocator type
Definition vbvector.hh:58
VariableBlockVector(size_type _nblocks, size_type m)
Definition vbvector.hh:134
size_type size() const
Definition vbvector.hh:735
size_type N() const
number of blocks in the vector (are of variable size here)
Definition vbvector.hh:726
VariableBlockVector(const VariableBlockVector &a)
copy constructor, has copy semantics
Definition vbvector.hh:172
VariableBlockVector(size_type _nblocks)
Definition vbvector.hh:108
~VariableBlockVector()
free dynamic memory
Definition vbvector.hh:215
window_type & operator[](size_type i)
random access to blocks
Definition vbvector.hh:563
CreateIterator createend()
get create iterator pointing to one after the last block
Definition vbvector.hh:552
Iterator beforeBegin() const
Definition vbvector.hh:672
CreateIterator createbegin()
get initial create iterator
Definition vbvector.hh:543
VariableBlockVector & operator=(const VariableBlockVector &a)
assignment
Definition vbvector.hh:322
static constexpr auto blocklevel
Definition vbvector.hh:90
ConstIterator rend() const
end ConstIterator
Definition vbvector.hh:706
A::size_type size_type
The size type for the index access.
Definition vbvector.hh:73
ConstIterator find(size_type i) const
random access returning iterator (end if not contained)
Definition vbvector.hh:718
ConstIterator beforeEnd() const
Definition vbvector.hh:700
Iterator find(size_type i)
random access returning iterator (end if not contained)
Definition vbvector.hh:712
const window_type & const_reference
Export type used for const references to container entries.
Definition vbvector.hh:70
RealIterator< const value_type, const window_type & > ConstIterator
Const iterator.
Definition vbvector.hh:681
Iterator end()
end Iterator
Definition vbvector.hh:658
ConstIterator begin() const
begin ConstIterator
Definition vbvector.hh:687
BlockVector< B, A > value_type
Type of the elements of the outer vector, i.e., dynamic vectors of B.
Definition vbvector.hh:80
ConstIterator end() const
end ConstIterator
Definition vbvector.hh:693
BlockVector< B, A > block_type
Same as value_type, here for historical reasons.
Definition vbvector.hh:84
void resize(size_type _nblocks, size_type m)
same effect as constructor with same argument
Definition vbvector.hh:270
window_type & reference
Export type used for references to container entries.
Definition vbvector.hh:64
void resize(size_type _nblocks)
same effect as constructor with same argument
Definition vbvector.hh:234
Iterator beforeEnd()
Definition vbvector.hh:665
Iterator begin()
begin Iterator
Definition vbvector.hh:652
Iterator class for sequential creation of blocks.
Definition vbvector.hh:443
bool operator==(const CreateIterator &it) const
equality
Definition vbvector.hh:505
size_type index() const
dereferencing
Definition vbvector.hh:511
size_type * pointer
pointer type
Definition vbvector.hh:460
bool operator!=(const CreateIterator &it) const
inequality
Definition vbvector.hh:499
~CreateIterator()
Definition vbvector.hh:471
size_type value_type
value type
Definition vbvector.hh:449
CreateIterator(VariableBlockVector &_v, int _i, bool _isEnd)
constructor
Definition vbvector.hh:466
void setblocksize(size_type _k)
set size of current block
Definition vbvector.hh:517
size_type & operator*()
Access size of current block.
Definition vbvector.hh:528
std::output_iterator_tag iterator_category
iterator category
Definition vbvector.hh:446
CreateIterator & operator++()
prefix increment
Definition vbvector.hh:482
Iterator class for sequential access.
Definition vbvector.hh:584
RealIterator(window_type *_p, size_type _i)
constructor
Definition vbvector.hh:594
bool equals(const RealIterator &it) const
equality
Definition vbvector.hh:611
size_type index() const
Return the index of the entry this iterator is pointing to.
Definition vbvector.hh:639
window_type & elementAt(std::ptrdiff_t offset) const
Definition vbvector.hh:633
void decrement()
prefix decrement
Definition vbvector.hh:605
void advance(std::ptrdiff_t d)
Definition vbvector.hh:622
void increment()
prefix increment
Definition vbvector.hh:599
RealIterator()
constructor, no arguments
Definition vbvector.hh:587
std::ptrdiff_t distanceTo(const RealIterator &o) const
Definition vbvector.hh:627
window_type & dereference() const
dereferencing
Definition vbvector.hh:617