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> >
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];
155 for (size_type i=0; i<nblocks; ++i)
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];
198 for (size_type i=1; i<nblocks; ++i)
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];
267 void resize (size_type _nblocks, size_type m)
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];
305 for (size_type i=0; i<nblocks; ++i)
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];
375 for (size_type i=1; i<nblocks; ++i)
380 for (size_type i=0; i<this->
n; i++) this->
p[i]=a.
p[i];
439 v.
p = v.allocator_.allocate(n);
452 for (size_type j=1; j<v.nblocks; ++j)
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_;
void decrement()
prefix decrement
Definition: vbvector.hh:562
ConstIterator beforeEnd() const
Definition: vbvector.hh:657
A vector of blocks with memory management.
Definition: bvector.hh:312
ConstIterator begin() const
begin ConstIterator
Definition: vbvector.hh:644
size_type n
Definition: basearray.hh:256
void setblocksize(size_type _k)
set size of current block
Definition: vbvector.hh:484
size_type getsize()
get size
Definition: bvector.hh:751
VariableBlockVector(const VariableBlockVector &a)
copy constructor, has copy semantics
Definition: vbvector.hh:169
void set(size_type _n, B *_p)
set size and pointer
Definition: bvector.hh:726
void resize(size_type _nblocks)
same effect as constructor with same argument
Definition: vbvector.hh:231
Iterator implementation class.
Definition: basearray.hh:84
RealIterator< const value_type, const window_type & > ConstIterator
Const iterator.
Definition: vbvector.hh:638
ConstIterator find(size_type i) const
random access returning iterator (end if not contained)
Definition: vbvector.hh:675
Iterator end()
end Iterator
Definition: vbvector.hh:615
A Vector of blocks with different blocksizes.
Definition: vbvector.hh:37
const window_type & const_reference
Export type used for const references to container entries.
Definition: vbvector.hh:65
RealIterator< value_type, window_type & > Iterator
Definition: vbvector.hh:606
void increment()
prefix increment
Definition: vbvector.hh:556
ConstIterator rend() const
end ConstIterator
Definition: vbvector.hh:663
A::size_type size_type
The size type for the index access.
Definition: vbvector.hh:68
Iterator find(size_type i)
random access returning iterator (end if not contained)
Definition: vbvector.hh:669
B * getptr()
get pointer
Definition: bvector.hh:745
Iterator class for sequential access.
Definition: vbvector.hh:539
size_type size() const
Definition: vbvector.hh:692
BlockVector< B, A > value_type
Type of the elements of the outer vector, i.e., dynamic vectors of B.
Definition: vbvector.hh:75
RealIterator()
constructor, no arguments
Definition: vbvector.hh:544
VariableBlockVector()
Definition: vbvector.hh:94
window_type & reference
Export type used for references to container entries.
Definition: vbvector.hh:59
window_type & operator[](size_type i)
random access to blocks
Definition: vbvector.hh:520
The number of blocklevels this vector contains.
Definition: vbvector.hh:86
B::field_type field_type
export the type representing the field
Definition: vbvector.hh:50
A allocator_type
export the allocator type
Definition: vbvector.hh:53
std::ptrdiff_t distanceTo(const RealIterator &o) const
Definition: vbvector.hh:584
void advance(std::ptrdiff_t d)
Definition: vbvector.hh:579
VariableBlockVector(size_type _nblocks)
Definition: vbvector.hh:105
Iterator beforeEnd()
Definition: vbvector.hh:622
Definition: basearray.hh:19
ConstIterator end() const
end ConstIterator
Definition: vbvector.hh:650
Iterator beforeBegin() const
Definition: vbvector.hh:629
void setptr(B *_p)
set pointer only
Definition: bvector.hh:739
window_type & elementAt(std::ptrdiff_t offset) const
Definition: vbvector.hh:590
This file implements a vector space as a tensor product of a given vector space. The number of compon...
bool operator!=(const CreateIterator &it) const
inequality
Definition: vbvector.hh:466
VariableBlockVector(size_type _nblocks, size_type m)
Definition: vbvector.hh:131
B * p
Definition: basearray.hh:257
BlockVector< B, A > block_type
Same as value_type, here for historical reasons.
Definition: vbvector.hh:79
size_type N() const
number of blocks in the vector (are of variable size here)
Definition: vbvector.hh:683
~VariableBlockVector()
free dynamic memory
Definition: vbvector.hh:212
void setsize(size_type _n)
set size only
Definition: bvector.hh:733
CreateIterator(VariableBlockVector &_v, int _i)
constructor
Definition: vbvector.hh:407
bool equals(const RealIterator &it) const
equality
Definition: vbvector.hh:568
An unmanaged vector of blocks.
Definition: bvector.hh:45
CreateIterator & operator++()
prefix increment
Definition: vbvector.hh:415
CreateIterator createend()
get create iterator pointing to one after the last block
Definition: vbvector.hh:509
bool operator==(const CreateIterator &it) const
equality
Definition: vbvector.hh:472
CreateIterator createbegin()
get initial create iterator
Definition: vbvector.hh:500
Iterator begin()
begin Iterator
Definition: vbvector.hh:609
size_type index() const
Return the index of the entry this iterator is pointing to.
Definition: vbvector.hh:596
size_type index() const
dereferencing
Definition: vbvector.hh:478
derive error class from the base class in common
Definition: istlexception.hh:16
VariableBlockVector & operator=(const VariableBlockVector &a)
assignment
Definition: vbvector.hh:319
RealIterator(window_type *_p, size_type _i)
constructor
Definition: vbvector.hh:551
window_type & dereference() const
dereferencing
Definition: vbvector.hh:574
Iterator class for sequential creation of blocks.
Definition: vbvector.hh:403
void resize(size_type _nblocks, size_type m)
same effect as constructor with same argument
Definition: vbvector.hh:267
Definition: bvector.hh:29