10 #ifndef ecl_containers_SPECIALISATIONS_HPP_
11 #define ecl_containers_SPECIALISATIONS_HPP_
47 typedef const unsigned char* const_iterator;
49 typedef const unsigned char& const_reference;
73 array(underlying_array),
95 Stencil(iterator underlying_array,
const unsigned int& length,
const unsigned int& start_index = 0,
const unsigned int &n = 0) :
96 array(underlying_array),
98 b_iter(array+start_index),
99 e_iter(array+start_index+n)
120 Stencil<unsigned char*> stencil(
const unsigned int& start_index,
const unsigned int& n)
const
122 ecl_assert_throw( b_iter+start_index <= array+length, StandardException(LOC,
OutOfRangeError,
"Start index provided is larger than the underlying stencil size."));
123 ecl_assert_throw( b_iter+start_index+n <= array+length, StandardException(LOC,
OutOfRangeError,
"Finish index provided is larger than the underlying stencil size."));
125 return Stencil<unsigned char*>(array,length,b_iter+start_index,b_iter+start_index+n);
139 void resettle(
const unsigned int& start_index,
const unsigned int& n)
142 b_iter = array+start_index;
143 e_iter = array+start_index+n;
164 containers::BoundedListInitialiser<value_type,iterator>
operator<< (
const value_type &value)
166 return containers::BoundedListInitialiser<value_type,iterator>(value, begin(), size());
181 Stencil<unsigned char*>& operator=(
const Stencil<unsigned char*> &s)
208 const_iterator begin()
const
228 const_iterator end()
const
238 reverse_iterator rbegin()
241 return reverse_iterator(end());
248 const_reverse_iterator rbegin()
const
251 return const_reverse_iterator(end());
258 reverse_iterator rend()
261 return reverse_iterator(begin());
268 const_reverse_iterator rend()
const
271 return const_reverse_iterator(begin());
292 const_reference front()
const
312 const_reference back()
const
330 reference operator[](size_type i)
347 const_reference operator[](size_type i)
const
363 reference at(size_type i)
365 if ( b_iter+i <= array )
369 if ( b_iter+i >= array+length )
387 const_reference at(size_type i)
const
389 if ( b_iter+i <= array )
393 if ( b_iter+i >= array+length )
409 {
return e_iter-b_iter;}
429 template <
typename OutputStream>
435 iterator b_iter, e_iter;
453 class ECL_PUBLIC Stencil<const unsigned char*>
460 typedef const unsigned char* iterator;
461 typedef const unsigned char* const_iterator;
462 typedef const unsigned char& reference;
463 typedef const unsigned char& const_reference;
486 Stencil(const_iterator underlying_array,
const unsigned int& length, const_iterator begin_iter, const_iterator end_iter) :
487 array(underlying_array),
509 Stencil(const_iterator underlying_array,
const unsigned int& length,
const unsigned int& start_index = 0,
const unsigned int &n = 0) :
510 array(underlying_array),
512 b_iter(array+start_index),
513 e_iter(array+start_index+n)
534 Stencil<const unsigned char*> stencil(
const unsigned int& start_index,
const unsigned int& n)
const
536 ecl_assert_throw( b_iter+start_index <= array+length, StandardException(LOC,
OutOfRangeError,
"Start index provided is larger than the underlying stencil size."));
537 ecl_assert_throw( b_iter+start_index+n <= array+length, StandardException(LOC,
OutOfRangeError,
"Finish index provided is larger than the underlying stencil size."));
539 return Stencil<const unsigned char*>(array,length,b_iter+start_index,b_iter+start_index+n);
553 void resettle(
const unsigned int& start_index,
const unsigned int& n)
556 b_iter = array+start_index;
557 e_iter = array+start_index+n;
574 Stencil<const unsigned char*>& operator=(
const Stencil<const unsigned char*> &s)
601 const_iterator begin()
const
621 const_iterator end()
const
631 reverse_iterator rbegin()
634 return reverse_iterator(end());
641 const_reverse_iterator rbegin()
const
644 return const_reverse_iterator(end());
651 reverse_iterator rend()
654 return reverse_iterator(begin());
661 const_reverse_iterator rend()
const
664 return const_reverse_iterator(begin());
685 const_reference front()
const
705 const_reference back()
const
740 const_reference operator[](size_type i)
const
756 reference at(size_type i)
758 if ( b_iter+i <= array )
762 if ( b_iter+i >= array+length )
780 const_reference at(size_type i)
const
782 if ( b_iter+i <= array )
786 if ( b_iter+i >= array+length )
801 size_type size()
const
802 {
return e_iter-b_iter;}
822 template <
typename OutputStream>
823 friend OutputStream&
operator<<(OutputStream &ostream ,
const Stencil<const unsigned char*> &stencil);
826 const_iterator array;
828 const_iterator b_iter, e_iter;