3 #ifndef DUNE_ISTL_BASEARRAY_HH 4 #define DUNE_ISTL_BASEARRAY_HH 13 #include <dune/common/iteratorfacades.hh> 39 template<
class B,
class A=std::allocator<B> >
61 #ifdef DUNE_ISTL_WITH_CHECKING 62 if (i>=
n) DUNE_THROW(
ISTLError,
"index out of range");
70 #ifdef DUNE_ISTL_WITH_CHECKING 71 if (i>=
n) DUNE_THROW(
ISTLError,
"index out of range");
79 :
public RandomAccessIteratorFacade<RealIterator<T>, T>
85 friend class RandomAccessIteratorFacade<
RealIterator<const ValueType>, const ValueType>;
86 friend class RandomAccessIteratorFacade<
RealIterator<ValueType>, ValueType>;
141 B& dereference ()
const 146 void advance(std::ptrdiff_t d)
204 const_iterator
end ()
const 224 const_iterator
find (size_type i)
const 270 template<
class B,
class A=std::allocator<B> >
310 void set (size_type _n, B* _p)
324 void move (difference_type offset, size_type newsize)
331 void move (difference_type offset)
360 template<
class B,
class A=std::allocator<B> >
397 this->p = allocator_.allocate(this->
n);
398 new (this->p)B[this->
n];
413 this->p = allocator_.allocate(this->
n);
414 new (this->p)B[this->
n];
422 for (size_type i=0; i<this->
n; i++) this->p[i]=a.
p[i];
433 this->p = allocator_.allocate(this->
n);
434 new (this->p)B[this->
n];
442 for (size_type i=0; i<this->
n; i++) this->p[i]=a.
p[i];
453 allocator_.deallocate(this->p,this->
n);
460 if (this->
n==_n)
return;
466 allocator_.deallocate(this->p,this->
n);
470 this->p = allocator_.allocate(this->
n);
471 new (this->p)B[this->
n];
491 allocator_.deallocate(this->p,this->
n);
495 this->p = allocator_.allocate(this->
n);
496 new (this->p)B[this->
n];
504 for (size_type i=0; i<this->
n; i++) this->p[i]=a.
p[i];
512 return this->operator=(static_cast<const base_array&>(a));
542 template<
class B,
class A=std::allocator<B> >
563 const size_type* lb = std::lower_bound(j, j+
n, i);
564 if (lb == j+
n || *lb != i)
565 DUNE_THROW(
ISTLError,
"index "<<i<<
" not in compressed array");
572 const size_type* lb = std::lower_bound(j, j+
n, i);
573 if (lb == j+
n || *lb != i)
574 DUNE_THROW(
ISTLError,
"index "<<i<<
" not in compressed array");
581 :
public BidirectionalIteratorFacade<RealIterator<T>, T>
587 friend class BidirectionalIteratorFacade<
RealIterator<const ValueType>, const ValueType>;
588 friend class BidirectionalIteratorFacade<
RealIterator<ValueType>, ValueType>;
599 : p(_p), j(_j), i(_i)
606 : p(it.p), j(it.j), i(it.i)
663 B& dereference ()
const 705 const size_type* lb = std::lower_bound(j, j+
n, i);
706 return (lb != j+
n && *lb == i)
721 const_iterator
end ()
const 741 const_iterator
find (size_type i)
const 743 const size_type* lb = std::lower_bound(j, j+
n, i);
744 return (lb != j+
n && *lb == i)
void setindex(size_type k)
Set index corresponding to pointer.
Definition: basearray.hh:632
B * getptr()
return the pointer
Definition: basearray.hh:337
iterator beforeBegin()
Definition: basearray.hh:697
A::size_type size_type
The type used for the index access.
Definition: basearray.hh:556
RealIterator(B *_p, size_type *_j, size_type _i)
constructor
Definition: basearray.hh:598
const_iterator begin() const
begin const_iterator
Definition: basearray.hh:198
B & operator[](size_type i)
random access to blocks
Definition: basearray.hh:59
base_array_unmanaged< B, A >::iterator iterator
make iterators available as types
Definition: basearray.hh:374
iterator beforeEnd()
Definition: basearray.hh:690
RealIterator()
constructor
Definition: basearray.hh:593
Extend base_array_unmanaged by functions to manipulate.
Definition: basearray.hh:271
iterator find(size_type i)
random access returning iterator (end if not contained)
Definition: basearray.hh:703
iterator begin()
begin iterator
Definition: basearray.hh:677
RealIterator(const B *_p, B *_i)
Definition: basearray.hh:95
A::size_type size_type
the type for the index access
Definition: basearray.hh:53
iterator end()
end iterator
Definition: basearray.hh:683
base_array_window()
makes empty array
Definition: basearray.hh:298
size_type n
Definition: basearray.hh:763
iterator class for sequential access
Definition: basearray.hh:580
derive error class from the base class in common
Definition: istlexception.hh:16
iterator beforeEnd()
Definition: basearray.hh:173
base_array_unmanaged< B, A >::const_iterator const_iterator
make iterators available as types
Definition: basearray.hh:377
iterator beforeBegin()
Definition: basearray.hh:180
base_array_unmanaged< B, A >::iterator iterator
make iterators available as types
Definition: basearray.hh:284
B member_type
export the type representing the components
Definition: basearray.hh:368
B member_type
export the type representing the components
Definition: basearray.hh:550
A simple array container for objects of type B.
Definition: basearray.hh:40
void move(difference_type offset, size_type newsize)
increment pointer by offset and set size
Definition: basearray.hh:324
const_iterator find(size_type i) const
random access returning iterator (end if not contained)
Definition: basearray.hh:741
const_iterator beforeBegin() const
Definition: basearray.hh:735
base_array()
makes empty array
Definition: basearray.hh:388
RealIterator< B > iterator
The iterator type.
Definition: basearray.hh:674
A::difference_type difference_type
The type used for the difference between two iterator positions.
Definition: basearray.hh:293
Iterator implementation class.
Definition: basearray.hh:78
const_iterator beforeEnd() const
Definition: basearray.hh:728
base_array_unmanaged< B, A >::const_iterator const_iterator
make iterators available as types
Definition: basearray.hh:287
void advance(difference_type newsize)
advance pointer by newsize elements and then set size to new size
Definition: basearray.hh:317
base_array(const base_array &a)
copy constructor
Definition: basearray.hh:407
const_iterator beforeEnd() const
Definition: basearray.hh:211
bool equals(const RealIterator< ValueType > &other) const
equality
Definition: basearray.hh:109
const_iterator begin() const
begin const_iterator
Definition: basearray.hh:715
void resize(size_type _n)
reallocate array to given size, any data is lost
Definition: basearray.hh:458
A allocator_type
export the allocator type
Definition: basearray.hh:371
bool equals(const RealIterator< ValueType > &it) const
equality
Definition: basearray.hh:611
B member_type
export the type representing the components
Definition: basearray.hh:278
A allocator_type
export the allocator type
Definition: basearray.hh:50
const_iterator beforeBegin() const
Definition: basearray.hh:218
RealIterator(const RealIterator< ValueType > &it)
Definition: basearray.hh:98
size_type n
Definition: basearray.hh:250
std::ptrdiff_t distanceTo(const RealIterator &o) const
Definition: basearray.hh:122
base_array_window(B *_p, size_type _n)
make array from given pointer and size
Definition: basearray.hh:303
A allocator_type
export the allocator type
Definition: basearray.hh:281
B * p
Definition: basearray.hh:764
const_iterator find(size_type i) const
random access returning iterator (end if not contained)
Definition: basearray.hh:224
base_array(const base_array_unmanaged< B, A > &_a)
construct from base class object
Definition: basearray.hh:426
RealIterator< const B > const_iterator
iterator class for sequential access
Definition: basearray.hh:195
base_array(size_type _n)
make array with _n components
Definition: basearray.hh:393
base_array_unmanaged(size_type n_, B *p_)
make an initialized array
Definition: basearray.hh:247
A allocator_
Definition: basearray.hh:517
This container extends base_array_unmanaged by memory management with the usual copy semantics provid...
Definition: basearray.hh:361
B * p
Definition: basearray.hh:251
A::difference_type difference_type
The type used for the difference between two iterator positions.
Definition: basearray.hh:383
B member_type
export the type representing the components
Definition: basearray.hh:47
base_array_unmanaged()
makes empty array
Definition: basearray.hh:243
A simple array container with non-consecutive index set.
Definition: basearray.hh:543
A allocator_type
export the allocator type
Definition: basearray.hh:553
base_array_unmanaged< B, A >::size_type size_type
The type used for the index access.
Definition: basearray.hh:380
size_type size() const
number of blocks in the array (are of size 1 here)
Definition: basearray.hh:236
bool equals(const RealIterator< const ValueType > &other) const
equality
Definition: basearray.hh:116
size_type offset() const
offset from the first entry.
Definition: basearray.hh:644
remove_const< T >::type ValueType
The unqualified value type.
Definition: basearray.hh:83
compressed_base_array_unmanaged()
makes empty array
Definition: basearray.hh:759
const_iterator end() const
end const_iterator
Definition: basearray.hh:721
size_type index() const
return index corresponding to pointer
Definition: basearray.hh:626
base_array_unmanaged< B, A >::size_type size_type
The type used for the index access.
Definition: basearray.hh:290
size_type * j
Definition: basearray.hh:765
~base_array()
free dynamic memory
Definition: basearray.hh:447
RealIterator< B > iterator
iterator type for sequential access
Definition: basearray.hh:156
remove_const< T >::type ValueType
The unqualified value type.
Definition: basearray.hh:585
size_type size() const
number of blocks in the array (are of size 1 here)
Definition: basearray.hh:752
iterator find(size_type i)
random access returning iterator (end if not contained)
Definition: basearray.hh:186
void move(difference_type offset)
increment pointer by offset, leave size
Definition: basearray.hh:331
const_iterator end() const
end const_iterator
Definition: basearray.hh:204
iterator end()
end iterator
Definition: basearray.hh:166
iterator begin()
begin iterator
Definition: basearray.hh:160
RealIterator(const RealIterator< ValueType > &it)
Copy constructor from mutable iterator.
Definition: basearray.hh:605
RealIterator< const B > const_iterator
const_iterator class for sequential access
Definition: basearray.hh:712
bool equals(const RealIterator< const ValueType > &it) const
equality
Definition: basearray.hh:618
Definition: basearray.hh:19
size_type index() const
return index
Definition: basearray.hh:103
RealIterator()
constructor
Definition: basearray.hh:91