3 #ifndef DUNE_ISTL_VBVECTOR_HH 4 #define DUNE_ISTL_VBVECTOR_HH 35 template<
class B,
class A=std::allocator<B> >
94 block = windowAllocator_.allocate(nblocks);
95 new (block) window_type[nblocks];
117 this->
n = _nblocks*m;
120 this->
p = allocator_.allocate(this->
n);
121 new (this->
p)B[this->
n];
134 block = windowAllocator_.allocate(nblocks);
135 new (block) window_type[nblocks];
138 for (size_type i=0; i<nblocks; ++i)
139 block[i].
set(m,this->
p+(i*m));
159 this->
p = allocator_.allocate(this->
n);
160 new (this->
p)B[this->
n];
163 for (size_type i=0; i<this->
n; i++) this->
p[i]=a.
p[i];
176 block = windowAllocator_.allocate(nblocks);
177 new (block) window_type[nblocks];
181 for (size_type i=1; i<nblocks; ++i)
201 allocator_.deallocate(this->
p,this->
n);
206 block[--i].~window_type();
207 windowAllocator_.deallocate(block,nblocks);
221 allocator_.deallocate(this->
p,this->
n);
226 block[--i].~window_type();
227 windowAllocator_.deallocate(block,nblocks);
236 block = windowAllocator_.allocate(nblocks);
237 new (block) window_type[nblocks];
250 void resize (size_type _nblocks, size_type m)
257 allocator_.deallocate(this->
p,this->
n);
262 block[--i].~window_type();
263 windowAllocator_.deallocate(block,nblocks);
267 this->
n = _nblocks*m;
270 this->
p = allocator_.allocate(this->
n);
271 new (this->
p)B[this->
n];
284 block = windowAllocator_.allocate(nblocks);
285 new (block) window_type[nblocks];
288 for (size_type i=0; i<nblocks; ++i)
289 block[i].
set(m,this->
p+(i*m));
308 if (this->
n!=a.
n || nblocks!=a.nblocks)
315 allocator_.deallocate(this->
p,this->
n);
320 block[--i].~window_type();
321 windowAllocator_.deallocate(block,nblocks);
329 this->
p = allocator_.allocate(this->
n);
330 new (this->
p)B[this->
n];
343 block = windowAllocator_.allocate(nblocks);
344 new (block) window_type[nblocks];
358 for (size_type i=1; i<nblocks; ++i)
363 for (size_type i=0; i<this->
n; i++) this->
p[i]=a.
p[i];
422 v.
p = v.allocator_.allocate(n);
435 for (size_type j=1; j<v.nblocks; ++j)
440 v.initialized =
true;
451 return (i!=it.i) || (&v!=&it.v);
457 return (i==it.i) && (&v==&it.v);
485 #ifdef DUNE_ISTL_WITH_CHECKING 486 if (initialized) DUNE_THROW(
ISTLError,
"no CreateIterator in initialized state");
505 #ifdef DUNE_ISTL_WITH_CHECKING 506 if (i>=nblocks) DUNE_THROW(
ISTLError,
"index out of range");
514 #ifdef DUNE_ISTL_WITH_CHECKING 515 if (i<0 || i>=nblocks) DUNE_THROW(
ISTLError,
"index out of range");
555 return (
p+i)==(it.p+it.i);
561 return (
p+i)!=(it.p+it.i);
567 return (
p+i)==(it.p+it.i);
573 return (
p+i)!=(it.p+it.i);
583 window_type* operator-> ()
const 630 if (i>=0 && i<nblocks)
639 if (i>=0 && i<nblocks)
681 return (
p+i)==(it.p+it.i);
687 return (
p+i)!=(it.p+it.i);
693 return (
p+i)==(it.p+it.i);
699 return (
p+i)!=(it.p+it.i);
709 const window_type* operator-> ()
const 723 const window_type*
p;
769 typename A::template rebind<window_type>::other windowAllocator_;
ConstIterator & operator--()
prefix decrement
Definition: vbvector.hh:672
base_array_unmanaged< T, A >::iterator Iterator
make iterators available as types
Definition: bvector.hh:60
Iterator beforeEnd()
Definition: vbvector.hh:615
ConstIterator find(size_type i) const
random access returning iterator (end if not contained)
Definition: vbvector.hh:637
Iterator begin()
begin Iterator
Definition: vbvector.hh:602
Iterator & operator++()
prefix increment
Definition: vbvector.hh:539
size_type index() const
Definition: vbvector.hh:589
Iterator class for sequential creation of blocks.
Definition: vbvector.hh:386
ConstIterator end() const
end ConstIterator
Definition: vbvector.hh:734
A allocator_type
export the allocator type
Definition: vbvector.hh:49
derive error class from the base class in common
Definition: istlexception.hh:16
The number of blocklevels this vector contains.
Definition: vbvector.hh:65
ConstIterator(const window_type *_p, size_type _i)
constructor from pointer
Definition: vbvector.hh:657
VariableBlockVector(const VariableBlockVector &a)
copy constructor, has copy semantics
Definition: vbvector.hh:152
ConstIterator class for sequential access.
Definition: vbvector.hh:646
window_type & operator[](size_type i)
random access to blocks
Definition: vbvector.hh:503
ConstIterator & operator++()
prefix increment
Definition: vbvector.hh:665
B::field_type field_type
export the type representing the field
Definition: vbvector.hh:46
void setptr(B *_p)
set pointer only
Definition: bvector.hh:692
This file implements a vector space as a tensor product of a given vector space. The number of compon...
Iterator class for sequential access.
Definition: vbvector.hh:524
Iterator find(size_type i)
random access returning iterator (end if not contained)
Definition: vbvector.hh:628
VariableBlockVector()
Definition: vbvector.hh:77
CreateIterator(VariableBlockVector &_v, int _i)
constructor
Definition: vbvector.hh:390
CreateIterator & operator++()
prefix increment
Definition: vbvector.hh:398
void set(size_type _n, B *_p)
set size and pointer
Definition: bvector.hh:679
Iterator end()
end Iterator
Definition: vbvector.hh:608
ConstIterator beforeEnd() const
Definition: vbvector.hh:741
size_type n
Definition: basearray.hh:250
ConstIterator(const Iterator &it)
constructor from non_const iterator
Definition: vbvector.hh:661
ConstIterator rend() const
end ConstIterator
Definition: vbvector.hh:747
Iterator & operator--()
prefix decrement
Definition: vbvector.hh:546
A::size_type size_type
The size type for the index access.
Definition: vbvector.hh:52
A Vector of blocks with different blocksizes.
Definition: vbvector.hh:36
Definition: bvector.hh:583
ConstIterator()
constructor
Definition: vbvector.hh:650
size_type index() const
dereferencing
Definition: vbvector.hh:461
bool operator==(const CreateIterator &it) const
equality
Definition: vbvector.hh:455
B * p
Definition: basearray.hh:251
~VariableBlockVector()
free dynamic memory
Definition: vbvector.hh:195
size_type getsize()
get size
Definition: bvector.hh:704
PromotionTraits< field_type, typename OtherB::field_type >::PromotedType operator*(const block_vector_unmanaged< OtherB, OtherA > &y) const
indefinite vector dot product which corresponds to Petsc's VecTDot
Definition: bvector.hh:132
B * getptr()
get pointer
Definition: bvector.hh:698
void resize(size_type _nblocks, size_type m)
same effect as constructor with same argument
Definition: vbvector.hh:250
size_type index() const
Definition: vbvector.hh:715
void resize(size_type _nblocks)
same effect as constructor with same argument
Definition: vbvector.hh:214
ConstIterator begin() const
begin ConstIterator
Definition: vbvector.hh:728
base_array_unmanaged< T, A >::const_iterator ConstIterator
make iterators available as types
Definition: bvector.hh:63
CreateIterator createend()
get create iterator pointing to one after the last block
Definition: vbvector.hh:492
Iterator beforeBegin() const
Definition: vbvector.hh:622
CreateIterator createbegin()
get initial create iterator
Definition: vbvector.hh:483
BlockVector< B, A > block_type
Definition: vbvector.hh:58
A vector of blocks with memory management.
Definition: bvector.hh:252
void setblocksize(size_type _k)
set size of current block
Definition: vbvector.hh:467
An unmanaged vector of blocks.
Definition: bvector.hh:41
Iterator(window_type *_p, size_type _i)
constructor
Definition: vbvector.hh:535
VariableBlockVector & operator=(const VariableBlockVector &a)
assignment
Definition: vbvector.hh:302
VariableBlockVector(size_type _nblocks)
Definition: vbvector.hh:88
Iterator()
constructor, no arguments
Definition: vbvector.hh:528
void setsize(size_type _n)
set size only
Definition: bvector.hh:686
Definition: basearray.hh:19
VariableBlockVector(size_type _nblocks, size_type m)
Definition: vbvector.hh:114
bool operator!=(const CreateIterator &it) const
inequality
Definition: vbvector.hh:449
size_type N() const
number of blocks in the vector (are of variable size here)
Definition: vbvector.hh:756
BlockVectorWindow< B, A > window_type
Definition: vbvector.hh:69