3 #ifndef DUNE_ISTL_BASEARRAY_HH 4 #define DUNE_ISTL_BASEARRAY_HH 13 #include <dune/common/iteratorfacades.hh> 43 template<
class B,
class A=std::allocator<B> >
65 #ifdef DUNE_ISTL_WITH_CHECKING 66 if (i>=
n) DUNE_THROW(
ISTLError,
"index out of range");
74 #ifdef DUNE_ISTL_WITH_CHECKING 75 if (i>=
n) DUNE_THROW(
ISTLError,
"index out of range");
83 :
public RandomAccessIteratorFacade<RealIterator<T>, T>
87 typedef typename std::remove_const<T>::type
ValueType;
89 friend class RandomAccessIteratorFacade<
RealIterator<const ValueType>, const ValueType>;
90 friend class RandomAccessIteratorFacade<
RealIterator<ValueType>, ValueType>;
145 B& elementAt (std::ptrdiff_t offset)
const 151 B& dereference ()
const 156 void advance(std::ptrdiff_t d)
211 const_iterator
end ()
const 231 const_iterator
find (size_type i)
const 274 template<
class B,
class A=std::allocator<B> >
314 void set (size_type _n, B* _p)
328 void move (difference_type offset, size_type newsize)
335 void move (difference_type offset)
364 template<
class B,
class A=std::allocator<B> >
401 this->p = allocator_.allocate(this->
n);
402 new (this->p)B[this->
n];
417 this->p = allocator_.allocate(this->
n);
418 new (this->p)B[this->
n];
426 for (size_type i=0; i<this->
n; i++) this->p[i]=a.
p[i];
437 this->p = allocator_.allocate(this->
n);
438 new (this->p)B[this->
n];
446 for (size_type i=0; i<this->
n; i++) this->p[i]=a.
p[i];
457 allocator_.deallocate(this->p,this->
n);
464 if (this->
n==_n)
return;
470 allocator_.deallocate(this->p,this->
n);
474 this->p = allocator_.allocate(this->
n);
475 new (this->p)B[this->
n];
495 allocator_.deallocate(this->p,this->
n);
499 this->p = allocator_.allocate(this->
n);
500 new (this->p)B[this->
n];
508 for (size_type i=0; i<this->
n; i++) this->p[i]=a.
p[i];
516 return this->operator=(static_cast<const base_array&>(a));
546 template<
class B,
class A=std::allocator<B> >
567 const size_type* lb = std::lower_bound(j, j+
n, i);
568 if (lb == j+
n || *lb != i)
569 DUNE_THROW(
ISTLError,
"index "<<i<<
" not in compressed array");
576 const size_type* lb = std::lower_bound(j, j+
n, i);
577 if (lb == j+
n || *lb != i)
578 DUNE_THROW(
ISTLError,
"index "<<i<<
" not in compressed array");
585 :
public BidirectionalIteratorFacade<RealIterator<T>, T>
591 friend class BidirectionalIteratorFacade<
RealIterator<const ValueType>, const ValueType>;
592 friend class BidirectionalIteratorFacade<
RealIterator<ValueType>, ValueType>;
603 : p(_p), j(_j), i(_i)
610 : p(it.p), j(it.j), i(it.i)
667 B& dereference ()
const 709 const size_type* lb = std::lower_bound(j, j+
n, i);
710 return (lb != j+
n && *lb == i)
725 const_iterator
end ()
const 745 const_iterator
find (size_type i)
const 747 const size_type* lb = std::lower_bound(j, j+
n, i);
748 return (lb != j+
n && *lb == i)
base_array()
makes empty array
Definition: basearray.hh:392
std::ptrdiff_t distanceTo(const RealIterator &o) const
Definition: basearray.hh:126
base_array_window()
makes empty array
Definition: basearray.hh:302
iterator beforeBegin()
Definition: basearray.hh:190
base_array_window(B *_p, size_type _n)
make array from given pointer and size
Definition: basearray.hh:307
bool equals(const RealIterator< const ValueType > &it) const
equality
Definition: basearray.hh:622
base_array_unmanaged< B, A >::iterator iterator
make iterators available as types
Definition: basearray.hh:288
size_type n
Definition: basearray.hh:254
size_type offset() const
offset from the first entry.
Definition: basearray.hh:648
A simple array container with non-consecutive index set.
Definition: basearray.hh:547
iterator end()
end iterator
Definition: basearray.hh:176
void advance(difference_type newsize)
advance pointer by newsize elements and then set size to new size
Definition: basearray.hh:321
const_iterator find(size_type i) const
random access returning iterator (end if not contained)
Definition: basearray.hh:231
Iterator implementation class.
Definition: basearray.hh:82
RealIterator(const B *_p, B *_i)
Definition: basearray.hh:99
base_array_unmanaged< B, A >::size_type size_type
The type used for the index access.
Definition: basearray.hh:384
const_iterator begin() const
begin const_iterator
Definition: basearray.hh:205
RealIterator(const RealIterator< ValueType > &it)
Copy constructor from mutable iterator.
Definition: basearray.hh:609
A::size_type size_type
the type for the index access
Definition: basearray.hh:57
B * p
Definition: basearray.hh:768
B member_type
export the type representing the components
Definition: basearray.hh:372
RealIterator< const B > const_iterator
const_iterator class for sequential access
Definition: basearray.hh:716
std::remove_const< T >::type ValueType
The unqualified value type.
Definition: basearray.hh:589
RealIterator< B > iterator
The iterator type.
Definition: basearray.hh:678
const_iterator beforeEnd() const
Definition: basearray.hh:218
This container extends base_array_unmanaged by memory management with the usual copy semantics provid...
Definition: basearray.hh:365
B * getptr()
return the pointer
Definition: basearray.hh:341
RealIterator(const RealIterator< ValueType > &it)
Definition: basearray.hh:102
const_iterator beforeEnd() const
Definition: basearray.hh:732
const_iterator end() const
end const_iterator
Definition: basearray.hh:211
size_type index() const
return index corresponding to pointer
Definition: basearray.hh:630
compressed_base_array_unmanaged()
makes empty array
Definition: basearray.hh:763
RealIterator(B *_p, size_type *_j, size_type _i)
constructor
Definition: basearray.hh:602
base_array_unmanaged< B, A >::iterator iterator
make iterators available as types
Definition: basearray.hh:378
void move(difference_type offset)
increment pointer by offset, leave size
Definition: basearray.hh:335
iterator beforeBegin()
Definition: basearray.hh:701
size_type * j
Definition: basearray.hh:769
RealIterator< const B > const_iterator
iterator class for sequential access
Definition: basearray.hh:202
size_type index() const
return index
Definition: basearray.hh:107
void setindex(size_type k)
Set index corresponding to pointer.
Definition: basearray.hh:636
A allocator_type
export the allocator type
Definition: basearray.hh:54
base_array(const base_array_unmanaged< B, A > &_a)
construct from base class object
Definition: basearray.hh:430
const_iterator begin() const
begin const_iterator
Definition: basearray.hh:719
bool equals(const RealIterator< ValueType > &it) const
equality
Definition: basearray.hh:615
bool equals(const RealIterator< ValueType > &other) const
equality
Definition: basearray.hh:113
Definition: basearray.hh:19
base_array_unmanaged(size_type n_, B *p_)
make an initialized array
Definition: basearray.hh:251
void move(difference_type offset, size_type newsize)
increment pointer by offset and set size
Definition: basearray.hh:328
iterator begin()
begin iterator
Definition: basearray.hh:681
base_array(const base_array &a)
copy constructor
Definition: basearray.hh:411
B member_type
export the type representing the components
Definition: basearray.hh:554
B * p
Definition: basearray.hh:255
iterator find(size_type i)
random access returning iterator (end if not contained)
Definition: basearray.hh:196
const_iterator beforeBegin() const
Definition: basearray.hh:225
base_array_unmanaged< B, A >::const_iterator const_iterator
make iterators available as types
Definition: basearray.hh:291
iterator beforeEnd()
Definition: basearray.hh:694
~base_array()
free dynamic memory
Definition: basearray.hh:451
iterator begin()
begin iterator
Definition: basearray.hh:170
A::difference_type difference_type
The type used for the difference between two iterator positions.
Definition: basearray.hh:387
base_array_unmanaged< B, A >::size_type size_type
The type used for the index access.
Definition: basearray.hh:294
B & operator[](size_type i)
random access to blocks
Definition: basearray.hh:63
A simple array container for objects of type B.
Definition: basearray.hh:44
const_iterator end() const
end const_iterator
Definition: basearray.hh:725
size_type n
Definition: basearray.hh:767
iterator beforeEnd()
Definition: basearray.hh:183
base_array_unmanaged()
makes empty array
Definition: basearray.hh:247
size_type size() const
number of blocks in the array (are of size 1 here)
Definition: basearray.hh:240
B member_type
export the type representing the components
Definition: basearray.hh:282
base_array_unmanaged< B, A >::const_iterator const_iterator
make iterators available as types
Definition: basearray.hh:381
iterator find(size_type i)
random access returning iterator (end if not contained)
Definition: basearray.hh:707
A::difference_type difference_type
The type used for the difference between two iterator positions.
Definition: basearray.hh:297
RealIterator< B > iterator
iterator type for sequential access
Definition: basearray.hh:166
A::size_type size_type
The type used for the index access.
Definition: basearray.hh:560
void resize(size_type _n)
reallocate array to given size, any data is lost
Definition: basearray.hh:462
size_type size() const
number of blocks in the array (are of size 1 here)
Definition: basearray.hh:756
RealIterator()
constructor
Definition: basearray.hh:597
iterator class for sequential access
Definition: basearray.hh:584
std::remove_const< T >::type ValueType
The unqualified value type.
Definition: basearray.hh:87
RealIterator()
constructor
Definition: basearray.hh:95
bool equals(const RealIterator< const ValueType > &other) const
equality
Definition: basearray.hh:120
derive error class from the base class in common
Definition: istlexception.hh:16
Extend base_array_unmanaged by functions to manipulate.
Definition: basearray.hh:275
iterator end()
end iterator
Definition: basearray.hh:687
B member_type
export the type representing the components
Definition: basearray.hh:51
const_iterator find(size_type i) const
random access returning iterator (end if not contained)
Definition: basearray.hh:745
const_iterator beforeBegin() const
Definition: basearray.hh:739
base_array(size_type _n)
make array with _n components
Definition: basearray.hh:397