Go to the documentation of this file.
3 #ifndef DUNE_ISTL_VBVECTOR_HH
4 #define DUNE_ISTL_VBVECTOR_HH
11 #include <dune/common/iteratorfacades.hh>
36 template<
class B,
class A=std::allocator<B> >
43 typedef Imp::BlockVectorWindow<B,A> window_type;
111 block = windowAllocator_.allocate(nblocks);
112 new (block) window_type[nblocks];
134 this->n = _nblocks*m;
137 this->p = allocator_.allocate(this->n);
138 new (this->p)B[this->n];
151 block = windowAllocator_.allocate(nblocks);
152 new (block) window_type[nblocks];
156 block[i].set(m,this->p+(i*m));
176 this->p = allocator_.allocate(this->n);
177 new (this->p)B[this->n];
180 for (
size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
193 block = windowAllocator_.allocate(nblocks);
194 new (block) window_type[nblocks];
197 block[0].set(a.block[0].getsize(),this->p);
199 block[i].set(a.block[i].getsize(),block[i-1].getptr()+block[i-1].getsize());
218 allocator_.deallocate(this->p,this->n);
223 block[--i].~window_type();
224 windowAllocator_.deallocate(block,nblocks);
238 allocator_.deallocate(this->p,this->n);
243 block[--i].~window_type();
244 windowAllocator_.deallocate(block,nblocks);
253 block = windowAllocator_.allocate(nblocks);
254 new (block) window_type[nblocks];
274 allocator_.deallocate(this->p,this->n);
279 block[--i].~window_type();
280 windowAllocator_.deallocate(block,nblocks);
284 this->n = _nblocks*m;
287 this->p = allocator_.allocate(this->n);
288 new (this->p)B[this->n];
301 block = windowAllocator_.allocate(nblocks);
302 new (block) window_type[nblocks];
306 block[i].set(m,this->p+(i*m));
325 if (this->n!=a.n || nblocks!=a.nblocks)
332 allocator_.deallocate(this->p,this->n);
337 block[--i].~window_type();
338 windowAllocator_.deallocate(block,nblocks);
346 this->p = allocator_.allocate(this->n);
347 new (this->p)B[this->n];
360 block = windowAllocator_.allocate(nblocks);
361 new (block) window_type[nblocks];
374 block[0].set(a.block[0].getsize(),this->p);
376 block[i].set(a.block[i].getsize(),block[i-1].getptr()+block[i-1].getsize());
380 for (
size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
395 (
static_cast<Imp::block_vector_unmanaged<B,A>&
>(*this)) = k;
420 v.block[i].setsize(k);
439 v.p = v.allocator_.allocate(n);
451 v.block[0].setptr(v.p);
453 v.block[j].setptr(v.block[j-1].getptr()+v.block[j-1].getsize());
457 v.initialized =
true;
468 return (i!=it.i) || (&v!=&it.v);
474 return (i==it.i) && (&v==&it.v);
502 #ifdef DUNE_ISTL_WITH_CHECKING
503 if (initialized) DUNE_THROW(
ISTLError,
"no CreateIterator in initialized state");
522 #ifdef DUNE_ISTL_WITH_CHECKING
523 if (i>=nblocks) DUNE_THROW(
ISTLError,
"index out of range");
531 #ifdef DUNE_ISTL_WITH_CHECKING
532 if (i<0 || i>=nblocks) DUNE_THROW(
ISTLError,
"index out of range");
538 template <
class T,
class R>
540 :
public RandomAccessIteratorFacade<RealIterator<T,R>, T, R>
570 return (p+i)==(it.p+it.i);
671 return Iterator(block,std::min(i,nblocks));
705 typename A::template rebind<window_type>::other windowAllocator_;
Iterator class for sequential creation of blocks.
Definition: vbvector.hh:403
VariableBlockVector(size_type _nblocks, size_type m)
Definition: vbvector.hh:131
bool operator!=(const CreateIterator &it) const
inequality
Definition: vbvector.hh:466
Iterator beforeBegin() const
Definition: vbvector.hh:629
void setblocksize(size_type _k)
set size of current block
Definition: vbvector.hh:484
ConstIterator beforeEnd() const
Definition: vbvector.hh:657
const typedef window_type & const_reference
Export type used for const references to container entries.
Definition: vbvector.hh:65
void increment()
prefix increment
Definition: vbvector.hh:556
VariableBlockVector & operator=(const VariableBlockVector &a)
assignment
Definition: vbvector.hh:319
CreateIterator(VariableBlockVector &_v, int _i)
constructor
Definition: vbvector.hh:407
window_type & dereference() const
dereferencing
Definition: vbvector.hh:574
B::field_type field_type
export the type representing the field
Definition: vbvector.hh:50
@ blocklevel
The number of blocklevels this vector contains.
Definition: vbvector.hh:86
A Vector of blocks with different blocksizes.
Definition: vbvector.hh:37
RealIterator()
constructor, no arguments
Definition: vbvector.hh:544
VariableBlockVector(const VariableBlockVector &a)
copy constructor, has copy semantics
Definition: vbvector.hh:169
A allocator_type
export the allocator type
Definition: vbvector.hh:53
Iterator class for sequential access.
Definition: vbvector.hh:539
RealIterator< const value_type, const window_type & > ConstIterator
Const iterator.
Definition: vbvector.hh:638
bool equals(const RealIterator &it) const
equality
Definition: vbvector.hh:568
window_type & elementAt(std::ptrdiff_t offset) const
Definition: vbvector.hh:590
window_type & reference
Export type used for references to container entries.
Definition: vbvector.hh:59
ConstIterator find(size_type i) const
random access returning iterator (end if not contained)
Definition: vbvector.hh:675
BlockVector< B, A > value_type
Type of the elements of the outer vector, i.e., dynamic vectors of B.
Definition: vbvector.hh:75
Iterator find(size_type i)
random access returning iterator (end if not contained)
Definition: vbvector.hh:669
CreateIterator & operator++()
prefix increment
Definition: vbvector.hh:415
size_type index() const
Return the index of the entry this iterator is pointing to.
Definition: vbvector.hh:596
Iterator beforeEnd()
Definition: vbvector.hh:622
CreateIterator createbegin()
get initial create iterator
Definition: vbvector.hh:500
RealIterator< value_type, window_type & > Iterator
Definition: vbvector.hh:606
VariableBlockVector()
Definition: vbvector.hh:94
ConstIterator begin() const
begin ConstIterator
Definition: vbvector.hh:644
RealIterator(window_type *_p, size_type _i)
constructor
Definition: vbvector.hh:551
ConstIterator rend() const
end ConstIterator
Definition: vbvector.hh:663
Iterator begin()
begin Iterator
Definition: vbvector.hh:609
size_type N() const
number of blocks in the vector (are of variable size here)
Definition: vbvector.hh:683
void resize(size_type _nblocks)
same effect as constructor with same argument
Definition: vbvector.hh:231
void decrement()
prefix decrement
Definition: vbvector.hh:562
~VariableBlockVector()
free dynamic memory
Definition: vbvector.hh:212
Definition: allocator.hh:7
window_type & operator[](size_type i)
random access to blocks
Definition: vbvector.hh:520
void advance(std::ptrdiff_t d)
Definition: vbvector.hh:579
Iterator end()
end Iterator
Definition: vbvector.hh:615
size_type size() const
Definition: vbvector.hh:692
derive error class from the base class in common
Definition: istlexception.hh:16
VariableBlockVector(size_type _nblocks)
Definition: vbvector.hh:105
std::ptrdiff_t distanceTo(const RealIterator &o) const
Definition: vbvector.hh:584
BlockVector< B, A > block_type
Same as value_type, here for historical reasons.
Definition: vbvector.hh:79
bool operator==(const CreateIterator &it) const
equality
Definition: vbvector.hh:472
This file implements a vector space as a tensor product of a given vector space. The number of compon...
A::size_type size_type
The size type for the index access.
Definition: vbvector.hh:68
size_type index() const
dereferencing
Definition: vbvector.hh:478
ConstIterator end() const
end ConstIterator
Definition: vbvector.hh:650
friend class CreateIterator
Definition: vbvector.hh:497
void resize(size_type _nblocks, size_type m)
same effect as constructor with same argument
Definition: vbvector.hh:267
CreateIterator createend()
get create iterator pointing to one after the last block
Definition: vbvector.hh:509
A vector of blocks with memory management.
Definition: bvector.hh:316