3 #ifndef DUNE_ISTL_BASEARRAY_HH 4 #define DUNE_ISTL_BASEARRAY_HH 13 #include <dune/common/iteratorfacades.hh> 45 template<
class B,
class A=std::allocator<B> >
67 #ifdef DUNE_ISTL_WITH_CHECKING 68 if (i>=
n) DUNE_THROW(
ISTLError,
"index out of range");
76 #ifdef DUNE_ISTL_WITH_CHECKING 77 if (i>=
n) DUNE_THROW(
ISTLError,
"index out of range");
85 :
public RandomAccessIteratorFacade<RealIterator<T>, T>
89 typedef typename std::remove_const<T>::type
ValueType;
91 friend class RandomAccessIteratorFacade<
RealIterator<const ValueType>, const ValueType>;
92 friend class RandomAccessIteratorFacade<
RealIterator<ValueType>, ValueType>;
147 B& elementAt (std::ptrdiff_t offset)
const 153 B& dereference ()
const 158 void advance(std::ptrdiff_t d)
213 const_iterator
end ()
const 233 const_iterator
find (size_type i)
const 277 template<
class B,
class A=std::allocator<B> >
317 void set (size_type _n, B* _p)
331 void move (difference_type offset, size_type newsize)
338 void move (difference_type offset)
368 template<
class B,
class A=std::allocator<B> >
405 this->p = allocator_.allocate(this->
n);
406 new (this->p)B[this->
n];
421 this->p = allocator_.allocate(this->
n);
422 new (this->p)B[this->
n];
430 for (size_type i=0; i<this->
n; i++) this->p[i]=a.
p[i];
440 allocator_.deallocate(this->p,this->
n);
447 if (this->
n==_n)
return;
453 allocator_.deallocate(this->p,this->
n);
457 this->p = allocator_.allocate(this->
n);
458 new (this->p)B[this->
n];
478 allocator_.deallocate(this->p,this->
n);
482 this->p = allocator_.allocate(this->
n);
483 new (this->p)B[this->
n];
491 for (size_type i=0; i<this->
n; i++) this->p[i]=a.
p[i];
525 template<
class B,
class A=std::allocator<B> >
546 const size_type* lb = std::lower_bound(j, j+
n, i);
547 if (lb == j+
n || *lb != i)
548 DUNE_THROW(
ISTLError,
"index "<<i<<
" not in compressed array");
555 const size_type* lb = std::lower_bound(j, j+
n, i);
556 if (lb == j+
n || *lb != i)
557 DUNE_THROW(
ISTLError,
"index "<<i<<
" not in compressed array");
564 :
public BidirectionalIteratorFacade<RealIterator<T>, T>
570 friend class BidirectionalIteratorFacade<
RealIterator<const ValueType>, const ValueType>;
571 friend class BidirectionalIteratorFacade<
RealIterator<ValueType>, ValueType>;
582 : p(_p), j(_j), i(_i)
589 : p(it.p), j(it.j), i(it.i)
646 B& dereference ()
const 688 const size_type* lb = std::lower_bound(j, j+
n, i);
689 return (lb != j+
n && *lb == i)
704 const_iterator
end ()
const 724 const_iterator
find (size_type i)
const 726 const size_type* lb = std::lower_bound(j, j+
n, i);
727 return (lb != j+
n && *lb == i)
base_array()
makes empty array
Definition: basearray.hh:396
std::ptrdiff_t distanceTo(const RealIterator &o) const
Definition: basearray.hh:128
base_array_window()
makes empty array
Definition: basearray.hh:305
iterator beforeBegin()
Definition: basearray.hh:192
base_array_window(B *_p, size_type _n)
make array from given pointer and size
Definition: basearray.hh:310
bool equals(const RealIterator< const ValueType > &it) const
equality
Definition: basearray.hh:601
base_array_unmanaged< B, A >::iterator iterator
make iterators available as types
Definition: basearray.hh:291
size_type n
Definition: basearray.hh:256
size_type offset() const
offset from the first entry.
Definition: basearray.hh:627
A simple array container with non-consecutive index set.
Definition: basearray.hh:526
iterator end()
end iterator
Definition: basearray.hh:178
void advance(difference_type newsize)
advance pointer by newsize elements and then set size to new size
Definition: basearray.hh:324
const_iterator find(size_type i) const
random access returning iterator (end if not contained)
Definition: basearray.hh:233
Iterator implementation class.
Definition: basearray.hh:84
RealIterator(const B *_p, B *_i)
Definition: basearray.hh:101
base_array_unmanaged< B, A >::size_type size_type
The type used for the index access.
Definition: basearray.hh:388
const_iterator begin() const
begin const_iterator
Definition: basearray.hh:207
RealIterator(const RealIterator< ValueType > &it)
Copy constructor from mutable iterator.
Definition: basearray.hh:588
A::size_type size_type
the type for the index access
Definition: basearray.hh:59
B * p
Definition: basearray.hh:747
B member_type
export the type representing the components
Definition: basearray.hh:376
RealIterator< const B > const_iterator
const_iterator class for sequential access
Definition: basearray.hh:695
std::remove_const< T >::type ValueType
The unqualified value type.
Definition: basearray.hh:568
RealIterator< B > iterator
The iterator type.
Definition: basearray.hh:657
const_iterator beforeEnd() const
Definition: basearray.hh:220
This container extends base_array_unmanaged by memory management with the usual copy semantics provid...
Definition: basearray.hh:369
B * getptr()
return the pointer
Definition: basearray.hh:344
RealIterator(const RealIterator< ValueType > &it)
Definition: basearray.hh:104
const_iterator beforeEnd() const
Definition: basearray.hh:711
const_iterator end() const
end const_iterator
Definition: basearray.hh:213
size_type index() const
return index corresponding to pointer
Definition: basearray.hh:609
compressed_base_array_unmanaged()
makes empty array
Definition: basearray.hh:742
RealIterator(B *_p, size_type *_j, size_type _i)
constructor
Definition: basearray.hh:581
base_array_unmanaged< B, A >::iterator iterator
make iterators available as types
Definition: basearray.hh:382
void move(difference_type offset)
increment pointer by offset, leave size
Definition: basearray.hh:338
iterator beforeBegin()
Definition: basearray.hh:680
size_type * j
Definition: basearray.hh:748
RealIterator< const B > const_iterator
iterator class for sequential access
Definition: basearray.hh:204
size_type index() const
return index
Definition: basearray.hh:109
void setindex(size_type k)
Set index corresponding to pointer.
Definition: basearray.hh:615
A allocator_type
export the allocator type
Definition: basearray.hh:56
const_iterator begin() const
begin const_iterator
Definition: basearray.hh:698
bool equals(const RealIterator< ValueType > &it) const
equality
Definition: basearray.hh:594
bool equals(const RealIterator< ValueType > &other) const
equality
Definition: basearray.hh:115
Definition: basearray.hh:19
base_array_unmanaged(size_type n_, B *p_)
make an initialized array
Definition: basearray.hh:253
void move(difference_type offset, size_type newsize)
increment pointer by offset and set size
Definition: basearray.hh:331
iterator begin()
begin iterator
Definition: basearray.hh:660
base_array(const base_array &a)
copy constructor
Definition: basearray.hh:415
B member_type
export the type representing the components
Definition: basearray.hh:533
B * p
Definition: basearray.hh:257
iterator find(size_type i)
random access returning iterator (end if not contained)
Definition: basearray.hh:198
const_iterator beforeBegin() const
Definition: basearray.hh:227
base_array_unmanaged< B, A >::const_iterator const_iterator
make iterators available as types
Definition: basearray.hh:294
iterator beforeEnd()
Definition: basearray.hh:673
~base_array()
free dynamic memory
Definition: basearray.hh:434
iterator begin()
begin iterator
Definition: basearray.hh:172
A::difference_type difference_type
The type used for the difference between two iterator positions.
Definition: basearray.hh:391
base_array_unmanaged< B, A >::size_type size_type
The type used for the index access.
Definition: basearray.hh:297
B & operator[](size_type i)
random access to blocks
Definition: basearray.hh:65
A simple array container for objects of type B.
Definition: basearray.hh:46
const_iterator end() const
end const_iterator
Definition: basearray.hh:704
size_type n
Definition: basearray.hh:746
iterator beforeEnd()
Definition: basearray.hh:185
base_array_unmanaged()
makes empty array
Definition: basearray.hh:249
size_type size() const
number of blocks in the array (are of size 1 here)
Definition: basearray.hh:242
B member_type
export the type representing the components
Definition: basearray.hh:285
base_array_unmanaged< B, A >::const_iterator const_iterator
make iterators available as types
Definition: basearray.hh:385
iterator find(size_type i)
random access returning iterator (end if not contained)
Definition: basearray.hh:686
A::difference_type difference_type
The type used for the difference between two iterator positions.
Definition: basearray.hh:300
RealIterator< B > iterator
iterator type for sequential access
Definition: basearray.hh:168
A::size_type size_type
The type used for the index access.
Definition: basearray.hh:539
void resize(size_type _n)
reallocate array to given size, any data is lost
Definition: basearray.hh:445
size_type size() const
number of blocks in the array (are of size 1 here)
Definition: basearray.hh:735
RealIterator()
constructor
Definition: basearray.hh:576
iterator class for sequential access
Definition: basearray.hh:563
std::remove_const< T >::type ValueType
The unqualified value type.
Definition: basearray.hh:89
RealIterator()
constructor
Definition: basearray.hh:97
bool equals(const RealIterator< const ValueType > &other) const
equality
Definition: basearray.hh:122
derive error class from the base class in common
Definition: istlexception.hh:16
Extend base_array_unmanaged by functions to manipulate.
Definition: basearray.hh:278
iterator end()
end iterator
Definition: basearray.hh:666
B member_type
export the type representing the components
Definition: basearray.hh:53
const_iterator find(size_type i) const
random access returning iterator (end if not contained)
Definition: basearray.hh:724
const_iterator beforeBegin() const
Definition: basearray.hh:718
base_array(size_type _n)
make array with _n components
Definition: basearray.hh:401