4 #ifndef DUNE_ARRAYLIST_HH 5 #define DUNE_ARRAYLIST_HH 16 template<
class T,
int N,
class A>
19 template<
class T,
int N,
class A>
58 template<
class T,
int N=100,
class A=std::allocator<T> >
134 const_iterator
begin()
const;
146 const_iterator
end()
const;
152 inline void push_back(const_reference entry);
166 inline const_reference
operator[](size_type i)
const;
172 inline size_type
size()
const;
197 typedef typename A::template rebind<shared_ptr<array<MemberType,chunkSize_> > >::other
198 SmartPointerAllocator;
203 typedef typename A::template rebind<array<MemberType,chunkSize_> >::other
213 std::vector<shared_ptr<array<MemberType,chunkSize_> >,
214 SmartPointerAllocator> chunks_;
236 inline reference elementAt(size_type i);
246 inline const_reference elementAt(size_type i)
const;
253 template<
class T,
int N,
class A>
255 typename A::value_type,
256 typename A::reference,
257 typename A::difference_type>
304 inline void increment();
309 inline void decrement();
315 inline reference elementAt(size_type i)
const;
321 inline reference dereference()
const;
334 inline void eraseToHere();
340 inline void advance(difference_type n);
373 template<
class T,
int N,
class A>
376 const typename A::value_type,
377 typename A::const_reference,
378 typename A::difference_type>
417 inline void increment();
422 inline void decrement();
425 inline void advance(difference_type n);
434 inline const_reference elementAt(size_type i)
const;
440 inline const_reference dereference()
const;
469 template<
class T,
int N,
class A>
471 : capacity_(0), size_(0), start_(0)
473 chunks_.reserve(100);
476 template<
class T,
int N,
class A>
484 template<
class T,
int N,
class A>
490 template<
class T,
int N,
class A>
493 size_t index=start_+size_;
496 chunks_.push_back(shared_ptr<array<MemberType,chunkSize_> >(
new array<MemberType,chunkSize_>()));
499 elementAt(index)=entry;
503 template<
class T,
int N,
class A>
506 return elementAt(start_+i);
510 template<
class T,
int N,
class A>
513 return elementAt(start_+i);
516 template<
class T,
int N,
class A>
523 template<
class T,
int N,
class A>
529 template<
class T,
int N,
class A>
535 template<
class T,
int N,
class A>
541 template<
class T,
int N,
class A>
547 template<
class T,
int N,
class A>
553 template<
class T,
int N,
class A>
563 std::copy(chunks_.begin()+distance,
564 chunks_.begin()+(distance+chunks), chunks_.begin());
572 template<
class T,
int N,
class A>
578 template<
class T,
int N,
class A>
585 template<
class T,
int N,
class A>
589 assert(list_==(other.list_));
590 return position_==other.position_ ;
594 template<
class T,
int N,
class A>
598 assert(list_==(other.list_));
599 return position_==other.position_ ;
603 template<
class T,
int N,
class A>
607 assert(list_==(other.list_));
608 return position_==other.position_ ;
611 template<
class T,
int N,
class A>
617 template<
class T,
int N,
class A>
623 template<
class T,
int N,
class A>
629 template<
class T,
int N,
class A>
635 template<
class T,
int N,
class A>
638 return list_->elementAt(i+position_);
641 template<
class T,
int N,
class A>
644 return list_->elementAt(i+position_);
647 template<
class T,
int N,
class A>
650 return list_->elementAt(position_);
653 template<
class T,
int N,
class A>
656 return list_->elementAt(position_);
659 template<
class T,
int N,
class A>
663 assert(list_==(other.list_));
664 return other.position_ - position_;
667 template<
class T,
int N,
class A>
671 assert(list_==(other.list_));
672 return other.position_ - position_;
675 template<
class T,
int N,
class A>
678 position_=other.position_;
683 template<
class T,
int N,
class A>
686 position_=other.position_;
691 template<
class T,
int N,
class A>
694 list_->size_ -= ++position_ - list_->start_;
696 size_t posChunkStart = position_ /
chunkSize_;
698 size_t chunks = (position_ - list_->start_ + list_->start_ %
chunkSize_)
700 list_->start_ = position_;
703 for(
size_t chunk=0; chunk<chunks; chunk++) {
705 list_->chunks_[posChunkStart].reset();
710 assert(list_->start_+list_->size_<=list_->capacity_);
713 template<
class T,
int N,
class A>
715 : position_(position), list_(&arrayList)
719 template<
class T,
int N,
class A>
722 : position_(position), list_(&arrayList)
725 template<
class T,
int N,
class A>
727 : position_(other.position_), list_(other.list_)
T * pointer
The type of a pointer to the type we store.
Definition: arraylist.hh:87
void clear()
Delete all entries from the list.
Definition: arraylist.hh:477
A::reference reference
Definition: arraylist.hh:394
const_reference elementAt(size_type i) const
Get the value of the list at an arbitrary position.
Definition: arraylist.hh:642
A::size_type size_type
Definition: arraylist.hh:270
reference dereference() const
Access the element at the current position.
Definition: arraylist.hh:648
reference elementAt(size_type i) const
Get the value of the list at an arbitrary position.
Definition: arraylist.hh:636
A::size_type size_type
Definition: arraylist.hh:392
const T & const_reference
The type of a const reference to the type we store.
Definition: arraylist.hh:82
Fallback implementation of the std::array class (a static array)
bool equals(const ArrayListIterator< MemberType, N, A > &other) const
Comares two iterators.
Definition: arraylist.hh:586
void decrement()
decrement the iterator.
Definition: arraylist.hh:630
A::difference_type difference_type
Definition: arraylist.hh:390
ArrayListIterator()
Standard constructor.
Definition: arraylist.hh:349
T value_type
Value type for stl compliance.
Definition: arraylist.hh:72
T & reference
The type of a reference to the type we store.
Definition: arraylist.hh:77
ConstArrayListIterator()
Definition: arraylist.hh:444
A::const_reference const_reference
Definition: arraylist.hh:274
const T * const_pointer
The type of a const pointer to the type we store.
Definition: arraylist.hh:92
void advance(difference_type n)
Definition: arraylist.hh:579
reference operator[](size_type i)
Get the element at specific position.
Definition: arraylist.hh:504
size_type size() const
Get the number of elements in the list.
Definition: arraylist.hh:485
ArrayList()
Constructs an Array list with one chunk.
Definition: arraylist.hh:470
const_reference dereference() const
Access the element at the current position.
Definition: arraylist.hh:654
A::reference reference
Definition: arraylist.hh:272
A::const_reference const_reference
Definition: arraylist.hh:396
size_type position()
Definition: arraylist.hh:337
A::difference_type difference_type
Definition: arraylist.hh:268
This file implements the class shared_ptr (a reference counting pointer), for those systems that don'...
difference_type distanceTo(const ArrayListIterator< T, N, A > &other) const
Definition: arraylist.hh:660
T MemberType
The member type that is stored.
Definition: arraylist.hh:67
Base class for stl conformant forward iterators.
Definition: iteratorfacades.hh:424
A random access iterator for the Dune::ArrayList class.
Definition: arraylist.hh:17
void push_back(const_reference entry)
Append an entry to the list.
Definition: arraylist.hh:491
ArrayListIterator< MemberType, N, A > iterator
A random access iterator.
Definition: arraylist.hh:106
This file implements iterator facade classes for writing stl conformant iterators.
ArrayListIterator< T, N, A > & operator=(const ArrayListIterator< T, N, A > &other)
Definition: arraylist.hh:676
const ConstArrayListIterator< T, N, A > & operator=(const ConstArrayListIterator< T, N, A > &other)
Definition: arraylist.hh:684
bool equals(const ConstArrayListIterator< MemberType, N, A > &other) const
Comares to iterators.
Definition: arraylist.hh:604
iterator end()
Get a random access iterator positioned after the last element.
Definition: arraylist.hh:542
difference_type distanceTo(const ConstArrayListIterator< T, N, A > &other) const
Definition: arraylist.hh:668
void increment()
Increment the iterator.
Definition: arraylist.hh:618
A::value_type MemberType
The member type.
Definition: arraylist.hh:266
A::value_type MemberType
The member type.
Definition: arraylist.hh:388
ConstArrayListIterator< MemberType, N, A > const_iterator
A constant random access iterator.
Definition: arraylist.hh:111
void purge()
Purge the list.
Definition: arraylist.hh:554
The number of elements in one chunk of the list. This has to be at least one. The default is 100...
Definition: arraylist.hh:100
std::size_t size_type
The size type.
Definition: arraylist.hh:116
void advance(difference_type n)
Definition: arraylist.hh:573
A constant random access iterator for the Dune::ArrayList class.
Definition: arraylist.hh:20
std::ptrdiff_t difference_type
The difference type.
Definition: arraylist.hh:121
void eraseToHere()
Erase all entries before the current position and the one at the current position.
Definition: arraylist.hh:692
Dune namespace.
Definition: alignment.hh:9
void increment()
Increment the iterator.
Definition: arraylist.hh:612
A dynamically growing random access list.
Definition: arraylist.hh:59
iterator begin()
Get an iterator that is positioned at the first element.
Definition: arraylist.hh:530
void decrement()
decrement the iterator.
Definition: arraylist.hh:624