14 #ifndef ECL_CONTAINERS_STENCIL_STENCIL_HPP_
15 #define ECL_CONTAINERS_STENCIL_STENCIL_HPP_
26 #include "../initialiser.hpp"
71 template <
typename Array>
89 typedef std::size_t size_type;
90 typedef std::ptrdiff_t difference_type;
91 typedef std::reverse_iterator<iterator> reverse_iterator;
113 Stencil(
Array& underlying_array, iterator begin_iter, iterator end_iter) :
114 array(underlying_array),
138 Stencil(
Array& underlying_array,
const unsigned int& start_index = 0,
const unsigned int &n = 0) :
139 array(underlying_array),
140 b_iter(array.begin()+start_index),
141 e_iter(array.begin()+start_index+n)
163 Stencil<Array> stencil(
const unsigned int& start_index,
const unsigned int& n)
const
165 ecl_assert_throw( b_iter+start_index < array.end(), StandardException(LOC,
OutOfRangeError,
"Start index provided is larger than the underlying stencil size."));
166 ecl_assert_throw( b_iter+start_index+n <= array.end(), StandardException(LOC,
OutOfRangeError,
"Finish index provided is larger than the underlying stencil size."));
167 return Stencil<Array>(array,b_iter+start_index,b_iter+start_index+n);
181 void resettle(
const unsigned int& start_index,
const unsigned int& n)
184 b_iter = array.begin()+start_index;
185 e_iter = array.begin()+start_index+n;
206 containers::BoundedListInitialiser<value_type,value_type*>
operator<< (
const value_type &value)
208 return containers::BoundedListInitialiser<value_type,iterator>(value, begin, size());
240 Stencil<Array>& operator=(
const Stencil<Array> &s)
242 if ( &array == &(s.array) )
250 for (
unsigned int i = 0; i < s.size(); ++i )
252 *(b_iter+i) = *(s.b_iter+i);
276 const_iterator begin()
const
296 const_iterator end()
const
306 reverse_iterator rbegin()
309 return reverse_iterator(end());
316 const_reverse_iterator rbegin()
const
319 return const_reverse_iterator(end());
326 reverse_iterator rend()
329 return reverse_iterator(begin());
336 const_reverse_iterator rend()
const
339 return const_reverse_iterator(begin());
360 const_reference front()
const
380 const_reference back()
const
398 reference operator[](size_type i)
415 const_reference operator[](size_type i)
const
431 reference at(size_type i)
433 if ( b_iter+i <= array.begin() )
437 if ( b_iter+i >= array.end() )
455 const_reference at(size_type i)
const
457 if ( b_iter+i <= array.begin() )
461 if ( b_iter+i >= array.end() )
477 {
return e_iter-b_iter;}
497 template <
typename OutputStream,
typename ArrayType>
502 iterator b_iter, e_iter;
509 template<
typename OutputStream,
typename ArrayType>
510 OutputStream&
operator<<(OutputStream &ostream,
const Stencil<ArrayType> &stencil)
516 for (std::size_t i = 0; i < stencil.size(); ++i)
518 ostream << stencil[i] <<
" ";