1#ifndef __vector_Iterator_HPP
2#define __vector_Iterator_HPP "Created 21.05.2006 12:12:12 by werner"
5#include <eagle/FixedArray.hpp>
9#include "HyperslabParameters.hpp"
11#include <memcore/Verbose.hpp>
13#if defined(__GNUC__) && defined(_GLIBCXX_USE_NOEXCEPT)
14#define USE_NOEXCEPT _GLIBCXX_USE_NOEXCEPT
16#define USE_NOEXCEPT throw()
43 const char* what()
const USE_NOEXCEPT
override
45 return "Range check error";
62 const char* what()
const USE_NOEXCEPT
override
64 return "Range check error";
73 const char* what()
const USE_NOEXCEPT
override
75 return "Range check error";
90 const char* what()
const USE_NOEXCEPT
override
92 return "Range check error";
108 const char*what()
const USE_NOEXCEPT
override
110 return "Range check error";
115#ifndef FIBER_VECTOR_RANGE_FAILURE_ACTION
117#define FIBER_VECTOR_RANGE_FAILURE_ACTION 0
119#define FIBER_VECTOR_RANGE_FAILURE_ACTION 1
128template <
int Components,
class T>
156 using HyperslabParameters::stride;
157 using HyperslabParameters::offset;
158 using HyperslabParameters::shift;
159 using HyperslabParameters::cropped;
177#ifdef FIBER_ITERATOR_NULLPTR_ASSERTION
179#elif defined(FIBER_ITERATOR_NULLPTR_WARNING)
182 Verbose(0) <<
"ElementIterator constructed with NULL pointer, provided length is " << Length;
192#ifdef FIBER_ITERATOR_NULLPTR_ASSERTION
194#elif defined(FIBER_ITERATOR_NULLPTR_WARNING)
197 Verbose(0) <<
"ElementIterator constructed with NULL pointer, provided length is " << Length;
207#ifdef FIBER_ITERATOR_NULLPTR_ASSERTION
209#elif defined(FIBER_ITERATOR_NULLPTR_WARNING)
212 Verbose(0) <<
"ElementIterator constructed with NULL pointer, provided length is " << Length;
222#ifdef FIBER_ITERATOR_NULLPTR_ASSERTION
224#elif defined(FIBER_ITERATOR_NULLPTR_WARNING)
227 Verbose(0) <<
"ElementIterator constructed with NULL pointer, provided length is " << Length;
238#ifdef FIBER_ITERATOR_NULLPTR_ASSERTION
240#elif defined(FIBER_ITERATOR_NULLPTR_WARNING)
243 Verbose(0) <<
"ElementIterator setNew Data with NULL pointer, provided length is " << Length;
271 return data+c*offset;
309#if defined(_IOSTREAM_) || defined(_GLIBCXX_OSTREAM) || defined(_CPP_IOSTREAM) || defined(__SGI_STL_IOSTREAM) || defined(__clang__)
310#define ITERATOR_OSTREAM
313 os <<
'(' << It.shift <<
" + i)*" << It.stride <<
" + c*" << It.offset
314 <<
" ; " << It.
length <<
" elements of type "
315 <<
typeid (T).name() <<
", " << It.
count() <<
" iterable.\n"
368template <
int C,
class T>
369 class Iterator<FixedArray<T, C> >;
371template <
class T,
int C>
380 public:
typedef T array_t;
406 return myIndex !=
RFI.myIndex;
414 const T&operator*()
const
416 return myContainer[ myIndex ];
434 return myIndex !=
RFI.myIndex;
445 return &myContainer[ myIndex ];
450 return myContainer[ myIndex ];
453 T& operator=(
const T&value)
const
455 return myContainer[ myIndex ] = value;
464 operator T&()
const {
return t; }
485 return { myContainer[ myIndex ], myIndex };
497 return myContainer[ myIndex ];
557 Iterator(T*Ptr, index_t howmany)
580 template <
int Components>
587 assert(component<Components);
590 template <
int Components>
597 assert(component<Components);
604 this->offset = nElements;
606 this->incPtr( nElements );
607 this->shift = It.getShift();
608 this->cropped= It.getCropped();
614 this->incPtr( component );
617 this->shift = It.getShift();
619 this->cropped= It.getCropped();
630 template <
int Components>
637 assert(component<Components);
664 friend Iterator operator+(
const Iterator&P, uint64_t i)
666 return Iterator(i, P,
Add() );
669 friend Iterator operator+(uint64_t i,
const Iterator&P)
676 friend Iterator operator+(
const Iterator&P, int32_t i)
681 friend Iterator operator+(int32_t i,
const Iterator&P)
686 friend Iterator operator+(
const Iterator&P, int64_t i)
691 friend Iterator operator+(int64_t i,
const Iterator&P)
697 friend Iterator operator+(
const Iterator&P,
long long i)
702 friend Iterator operator+(
long long i,
const Iterator&P)
737 const_ranged_for_iterator<T> end()
const
739 return const_ranged_for_iterator<T>(
count(), *
this);
742 ranged_for_iterator<T> begin()
744 return ranged_for_iterator<T>(0, *
this);
747 ranged_for_iterator<T> end()
749 return ranged_for_iterator<T>(
count(), *
this);
755 return (*
this)[I.myIndex];
759 const T&
operator[](
const ranged_for_iterator<S>&I)
const
761 return (*
this)[I.myIndex];
765 T&
operator[](
const const_ranged_for_iterator<S>&I)
767 return (*
this)[I.myIndex];
771 const T&
operator[](
const const_ranged_for_iterator<S>&I)
const
773 return (*
this)[I.myIndex];
780 class constViewPtr<const T> :
public ViewPtrBase<const T, 1>
786 using ViewPtrBase<T, 1>::data;
787 using ViewPtrBase<T, 1>::stride;
788 using ViewPtrBase<T, 1>::offset;
794 : ViewPtrBase<const T, 1>(
ptr, 1, 0)
798 ViewPtr(
const ViewPtr&P)
799 : ViewPtrBase<const T, 1>(P.data, P.
stride, P.offset)
805 template <
int Components>
806 ViewPtr(
const FixedArray<Components, T>*
ptr,
int component)
807 : ViewPtrBase<const T, 1>(
ptr->
ptr(0),
808 sizeof(FixedArray<Components, T>)/sizeof(T) ,
811 assert(component<Components);
818 template <
int Components>
819 ViewPtr(
const VVector<Components, T>*
ptr,
int component)
820 : ViewPtrBase<const T,1>(
ptr->
ptr(0),
821 stride(sizeof(VVector<Components, T>)/sizeof(T) ),
829 ViewPtr(
const ViewPtr&P, index_t ElementShift)
830 : ViewPtrBase<const T,1>(P.data + P.
stride*ElementShift, P.
stride, P.offset)
839 void setOffset(
int o)
846 return data[i*
stride + offset];
864template <
class Iterator>
868 enum { Components = Iterator::Components };
869 typedef typename Iterator::element_value_t element_value_t;
881 : owner(Owner), idx(
Idx)
891 for(
int c=0; c<Components; c++)
901 for(
int c=0; c<Components; c++)
912 for(
int c=0; c<Components; c++)
919 typedef element_value_t value_type;
920 enum { SIZE = Components };
935 for(
int c=0; c<Components; c++)
945 for(
int c=0; c<Components; c++)
962template <
int C,
class T>
986 return myIndex !=
RFI.myIndex;
994#ifndef NON_INDEXABLE_ITERATOR
995 const ranged_for_iterator&operator*()
const
1000 operator Proxy()
const
1002 return myContainer[ myIndex ];
1012 Proxy operator*()
const
1014 return myContainer[ myIndex ];
1018 index_t getIndex()
const
1038template <
int C,
class T>
1051 enum { Components = C };
1109 friend Iterator<FixedArray<T,C> > operator+(int32_t i,
const Iterator<FixedArray<T,C> >&P)
1111 return Iterator<FixedArray<T,C> >(i, P,
Add() );
1115 friend Iterator<FixedArray<T,C> > operator+(
const Iterator<FixedArray<T,C> >&P, int64_t i)
1117 return Iterator<FixedArray<T,C> >(i, P,
Add() );
1120 friend Iterator<FixedArray<T,C> > operator+(int64_t i,
const Iterator<FixedArray<T,C> >&P)
1122 return Iterator<FixedArray<T,C> >(i, P,
Add() );
1127 friend Iterator<FixedArray<T, C> > operator+(
const Iterator<FixedArray<T, C> >&P, uint32_t i)
1129 return Iterator<FixedArray<T,C> >(i, P,
Add() );
1132 friend Iterator<FixedArray<T,C> > operator+(uint32_t i,
const Iterator<FixedArray<T,C> >&P)
1134 return Iterator<FixedArray<T,C> >(i, P,
Add() );
1137 friend Iterator<FixedArray<T,C> > operator+(
const Iterator<FixedArray<T,C> >&P, uint64_t i)
1139 return Iterator<FixedArray<T,C> >(i, P,
Add() );
1142 friend Iterator<FixedArray<T,C> > operator+(uint64_t i,
const Iterator<FixedArray<T,C> >&P)
1144 return Iterator<FixedArray<T,C> >(i, P,
Add() );
1148 friend Iterator<FixedArray<T,C> > operator+(
const Iterator<FixedArray<T,C> >&P,
long long i)
1150 return Iterator<FixedArray<T,C> >(i, P,
Add() );
1153 friend Iterator<FixedArray<T,C> > operator+(
long long i,
const Iterator<FixedArray<T,C> >&P)
1155 return Iterator<FixedArray<T,C> >(i, P,
Add() );
1161 return Iterator<T>(*
this, i);
1167 assert(c<Components);
1176 return Proxy(*
this, i);
1183 for(
int c=0; c<Components; c++)
1196 const_ranged_for_iterator<array_t> end()
const
1198 return const_ranged_for_iterator<array_t>(
count(), *
this);
1201 ranged_for_iterator<array_t> begin()
1203 return ranged_for_iterator<array_t>(0, *
this);
1206 ranged_for_iterator<array_t> end()
1208 return ranged_for_iterator<array_t>(
count(), *
this);
1214 return (*
this)[I.myIndex];
1218 const T&
operator[](
const ranged_for_iterator<S>&I)
const
1220 return (*
this)[I.myIndex];
1224 T&
operator[](
const const_ranged_for_iterator<S>&I)
1226 return (*
this)[I.myIndex];
1230 const T&
operator[](
const const_ranged_for_iterator<S>&I)
const
1232 return (*
this)[I.myIndex];
1247template <
class VectorType>
1255array_t*data = V.
ptr();
1267template <
class Type>
1281template <
class Type>
1282inline Iterator<Type>
array_iterator(
const Iterator<FixedArray<Type, 1> >&It)
1284Type*data = It.
ptr();
1286Iterator<Type> retval( It.
getLength(), data );
1287 retval.setCount( It.
count() );
1293template <
int N,
class Type>
1296 return Iterator<Eagle::Vector<Type,N> >( It, &It.
ptr()->vec() );
constexpr complex< _Tp > & operator=(const _Tp &)
basic_ostream< char > ostream
valarray< size_t > stride() const
valarray< size_t > size() const
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)
Vectorized vector.
Definition VVector.hpp:288
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
An iterator which allows to access each component element type of an array of vectors,...
Definition vector/Iterator.hpp:149
index_t length
The length (number of elements) of the data array.
Definition HyperslabParameters.hpp:37
ElementIterator(const ElementIterator &It)
Copy Constructor.
Definition vector/Iterator.hpp:188
ElementIterator(index_t Length, T *Data, index_t Stride, index_t Offset)
Construct an element iterator.
Definition vector/Iterator.hpp:173
ElementIterator(index_t i, const ElementIterator &It, const Add &)
Addition Constructor.
Definition vector/Iterator.hpp:218
void SetNewData(T *newData, index_t newLength)
Change the stored data chunk to a new location and length.
Definition vector/Iterator.hpp:233
T & getElement(index_t i, int c) const
Element access (no range check!).
Definition vector/Iterator.hpp:285
ElementIterator(const HyperslabParameters &It, T *newData)
Constructor compatible iterator with new data.
Definition vector/Iterator.hpp:203
T * ptr(int c=0) const
Return pointer to data, which is good for C interface, but otherwise, avoid that.
Definition vector/Iterator.hpp:266
A proxy for Iterators, such that an Iterator's element looks like an Iterator's element (!...
Definition vector/Iterator.hpp:866
element_value_t & operator[](int c) const
access a component of the element
Definition vector/Iterator.hpp:953
ElementProxy & operator-=(const array_t &v)
Self-substraction operator.
Definition vector/Iterator.hpp:943
Eagle::Assignment< ElementProxy, 0 > operator=(const element_value_t &x)
Overloading of the assignment operator such that the comma operator may be used to assign components ...
Definition vector/Iterator.hpp:926
ElementProxy(const Iterator &Owner, index_t Idx)
Construct an ElementProxy as a reference to a specific element in a given array, which is accessed vi...
Definition vector/Iterator.hpp:880
ElementProxy & operator=(const array_t &v)
Assign an array element.
Definition vector/Iterator.hpp:899
ElementProxy & operator+=(const array_t &v)
Self-addition operator.
Definition vector/Iterator.hpp:933
ElementProxy & operator=(const ElementProxy &in)
Assign an array element from another element proxy.
Definition vector/Iterator.hpp:910
Definition vector/Iterator.hpp:373
A set of integer values which describes how to iterate over a certain set of values.
Definition HyperslabParameters.hpp:34
index_t getIndex(index_t i, int c) const
Given a major and a minor index, compute the overall index in the dataset according to.
Definition HyperslabParameters.hpp:176
bool isSeparatedCompound() const
Tell if the iterator refers to a data set which is built from arrays of structure members,...
Definition HyperslabParameters.hpp:108
index_t getLength() const
Return the number of elements which can be accessed through this ElementIterator.
Definition HyperslabParameters.hpp:76
index_t length
The length (number of elements) of the data array.
Definition HyperslabParameters.hpp:37
void setCount(index_t size)
Set the maximally allowed count, i.e.
Definition HyperslabParameters.hpp:156
index_t count() const
Return the number of steps which can be traversed through this ElementIterator.
Definition HyperslabParameters.hpp:147
Intermediate base class for generic iterators.
Definition vector/Iterator.hpp:329
IteratorBase(const HyperslabParameters &IB, T *d)
Construct compatible iterator with different data.
Definition vector/Iterator.hpp:355
Iterator(index_t Length, FixedArray< T, C > *Ptr)
Construct a pointer to a field of arrays from a native pointer to arrays.
Definition vector/Iterator.hpp:1070
Iterator< array_t > Iterator_t
Shortcut type definition to this iterator itself.
Definition vector/Iterator.hpp:1060
T element_value_t
Export the type of each element.
Definition vector/Iterator.hpp:1057
FixedArray< T, Components > array_t
Export the type of the fixed array.
Definition vector/Iterator.hpp:1054
array_t getValue(index_t i) const
The copy-by-value version of retrieving an element.
Definition vector/Iterator.hpp:1180
Iterator(index_t size, T *Ptr)
Construct a pointer to a field of arrays from an array of fields which reside consecutive in memory.
Definition vector/Iterator.hpp:1082
Proxy operator[](index_t i) const
Access an element of the array.
Definition vector/Iterator.hpp:1174
ElementProxy< Iterator_t > Proxy
The associated proxy type for element access.
Definition vector/Iterator.hpp:1063
Iterator(index_t ishift, const Iterator &P, const Add &)
Addition Constructor.
Definition vector/Iterator.hpp:1089
Implementation of an Iterator to a sequence of elements, which might be contiguous or a projection of...
Definition vector/Iterator.hpp:525
Iterator(index_t howmany, T *Ptr)
Construct view pointer from contiguous storage.
Definition vector/Iterator.hpp:551
T & operator[](index_t i) const
Access an element of the array, writeable.
Definition vector/Iterator.hpp:712
Iterator(index_t howmany, FixedArray< T, Components > *Ptr, int component)
Construct view pointer to a single component within a contiguous storage of array objects.
Definition vector/Iterator.hpp:581
Iterator(index_t Length, Eagle::VVector< Components, T > *Ptr, int component)
Construct view pointer to a single component within a contigous storage of array objects.
Definition vector/Iterator.hpp:631
T & reference_t
The reference type.
Definition vector/Iterator.hpp:709
const T & getValue(index_t i) const
Get the value, readonly.
Definition vector/Iterator.hpp:718
Iterator< array_t > getArrayIterator() const
Get an iterator that operates on associated FixedArray<> subjects.
Definition vector/Iterator.hpp:1300
Iterator(const Iterator &P)
Copy Constructor.
Definition vector/Iterator.hpp:568
Iterator< component_t > getComponent(int n) const
Get an iterator that operates on the nth component.
Definition vector/Iterator.hpp:1307
Iterator(const Iterator &P, int)
Copy Constructor with irrelevant member selection2.
Definition vector/Iterator.hpp:573
Iterator(index_t ishift, const Iterator &P, const Add &)
Addition Constructor.
Definition vector/Iterator.hpp:641
void set(const T &Value)
Set all elements to the same value.
Definition vector/Iterator.hpp:724
Iterator(const Iterator< FixedArray< T, Components > > &It, int component)
Definition vector/Iterator.hpp:591
Iterator(const HyperslabParameters &P, T *Ptr)
Construct iterator with alternative data, but otherwise compatible properties.
Definition vector/Iterator.hpp:563
Column< R, value > operator*(const Matrix< R, C, value > &A, const Column< C, value > &V)
Anemone_Context_t operator<<(Anemone &A, VRenderContext &VC)
Iterator< typename FixedArrayTrait< typename Eagle::MetaInfo< VectorType >::element_t, Eagle::MetaInfo< VectorType >::MULTIPLICITY >::array_t > farray_iterator(const Iterator< VectorType > &V)
Convert an iterator to a contiguous array of vectors into an iterator over elements which are FixedAr...
Definition vector/Iterator.hpp:1249
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
Iterator< Type > array_iterator(const Iterator< Type > &It)
Specialization of the array_iterator() function for Iterators on what is already a FixedArray.
Definition vector/Iterator.hpp:1268
IndexTypeConfig< sizeof(void *)>::index_t index_t
Define the index type as according to the size of a pointer, i.e.
Definition Index.hpp:22
string to_string(const Eagle::FixedArray< ElementType, N > &A, const char *OpenBrace="{", const char *CloseBrace="}", const char *Separator=",")
Definition vector/Iterator.hpp:386
Definition vector/Iterator.hpp:35
Definition vector/Iterator.hpp:395
element_value_t & operator[](int c) const
access a component of the element
Definition vector/Iterator.hpp:1006
ElementProxy< Iterator_t > Proxy
The associated proxy type for element access.
Definition vector/Iterator.hpp:974
T element_value_t
Export the type of each element.
Definition vector/Iterator.hpp:968
Iterator< array_t > Iterator_t
Shortcut type definition to this iterator itself.
Definition vector/Iterator.hpp:971
Definition vector/Iterator.hpp:423