18 #if !defined( BOLT_AMP_CONSTANT_ITERATOR_H )
19 #define BOLT_AMP_CONSTANT_ITERATOR_H
71 template<
typename value_type >
72 class constant_iterator:
public std::iterator< constant_iterator_tag, typename value_type, int>
75 typedef typename std::iterator< constant_iterator_tag, typename value_type, int>::difference_type
78 typedef concurrency::array_view< value_type > arrayview_type;
89 m_constValue( init ), m_Index( 0 ){}
92 template<
typename OtherType >
94 m_Index( rhs.m_Index ), m_constValue( rhs.m_constValue ){}
97 constant_iterator< value_type >& operator= (
const constant_iterator< value_type >& rhs )
102 m_constValue = rhs.m_constValue;
103 m_Index = rhs.m_Index;
107 constant_iterator< value_type >& operator+= (
const difference_type & n )
113 const constant_iterator< value_type > operator+ (
const difference_type & n )
const
115 constant_iterator< value_type > result( *
this );
120 const constant_iterator< value_type > operator- (
const difference_type & n )
const
122 constant_iterator< value_type > result( *
this );
123 result.advance( -n );
127 const constant_iterator< value_type > & getBuffer( const_iterator itr )
const
133 const constant_iterator< value_type > & getContainer( )
const
138 difference_type operator- (
const constant_iterator< value_type >& rhs )
const
141 return m_Index - rhs.m_Index;
145 difference_type m_Index;
149 template <
typename >
friend class constant_iterator;
152 void advance( difference_type n )
157 value_type* getPointer()
159 return &m_constValue;
162 const value_type* getPointer()
const
164 return &m_constValue;
168 constant_iterator< value_type > operator++ ( )
171 constant_iterator< value_type > result( *
this );
176 constant_iterator< value_type > operator++ (
int )
const
178 constant_iterator< value_type > result( *
this );
184 constant_iterator< value_type > operator--( )
const
186 constant_iterator< value_type > result( *
this );
187 result.advance( -1 );
192 constant_iterator< value_type > operator--(
int )
const
194 constant_iterator< value_type > result( *
this );
195 result.advance( -1 );
199 difference_type getIndex()
const
204 template<
typename OtherType >
205 bool operator== (
const constant_iterator< OtherType >& rhs )
const
207 bool sameIndex = (rhs.m_constValue == m_constValue) && (rhs.m_Index == m_Index);
212 template<
typename OtherType >
213 bool operator!= (
const constant_iterator< OtherType >& rhs )
const
215 bool sameIndex = (rhs.m_constValue != m_constValue) || (rhs.m_Index != m_Index);
220 template<
typename OtherType >
221 bool operator< ( const constant_iterator< OtherType >& rhs )
const
223 bool sameIndex = (m_Index < rhs.m_Index);
228 value_type operator*() const restrict(cpu,amp)
230 value_type xy = m_constValue;
234 value_type operator[](
int x)
const restrict(cpu,amp)
236 value_type xy = m_constValue;
241 value_type m_constValue;
245 template<
typename Type >
246 constant_iterator< Type > make_constant_iterator( Type constValue )
248 constant_iterator< Type > tmp( constValue );