27 #ifndef SCHNEK_RANGE_HPP_ 28 #define SCHNEK_RANGE_HPP_ 31 #include "boost/concept/assert.hpp" 32 #include "boost/concept_check.hpp" 41 template<
int>
class CheckingPolicy = ArrayNoArgCheck
55 template<
template<
int>
class ArrayCheckingPolicy>
60 template<
template<
int>
class ArrayCheckingPolicy>
73 const LimitType &
getLo()
const {
77 const LimitType &
getHi()
const {
89 for (
int i=0; i<rank; ++i)
90 if ((p[i]<lo[i]) || (p[i]>hi[i]))
return false;
95 template<
int destLength>
101 Range<T,rank-1,CheckingPolicy> projectDim(
int dim)
const 103 return Range<T,rank-1,CheckingPolicy>(lo.projectDim(dim), hi.projectDim(dim));
106 void grow(
const T &s)
108 for (
int i=0; i<rank; ++i)
115 void grow(
const T &d0,
const T &d1)
117 BOOST_STATIC_ASSERT(2==rank);
124 void grow(
const T &d0,
const T &d1,
const T &d2)
126 BOOST_STATIC_ASSERT(3==rank);
135 void grow(
const T &d0,
const T &d1,
const T &d2,
const T &d3)
137 BOOST_STATIC_ASSERT(4==rank);
148 void grow(
const T &d0,
const T &d1,
const T &d2,
const T &d3,
const T &d4)
150 BOOST_STATIC_ASSERT(5==rank);
163 void grow(
const T &d0,
const T &d1,
const T &d2,
const T &d3,
const T &d4,
166 BOOST_STATIC_ASSERT(6==rank);
181 void grow(
const T &d0,
const T &d1,
const T &d2,
const T &d3,
const T &d4,
182 const T &d5,
const T &d6)
184 BOOST_STATIC_ASSERT(7==rank);
201 void grow(
const T &d0,
const T &d1,
const T &d2,
const T &d3,
const T &d4,
202 const T &d5,
const T &d6,
const T &d7)
204 BOOST_STATIC_ASSERT(8==rank);
223 void grow(
const T &d0,
const T &d1,
const T &d2,
const T &d3,
const T &d4,
224 const T &d5,
const T &d6,
const T &d7,
const T &d8)
226 BOOST_STATIC_ASSERT(9==rank);
247 void grow(
const T &d0,
const T &d1,
const T &d2,
const T &d3,
const T &d4,
248 const T &d5,
const T &d6,
const T &d7,
const T &d8,
const T &d9)
250 BOOST_STATIC_ASSERT(10==rank);
276 class iterator :
public std::iterator<std::forward_iterator_tag, LimitType> {
278 BOOST_CONCEPT_ASSERT((boost::Integer<T>));
288 iterator(
const Range &domain_,
const LimitType &pos_,
bool atEnd_=
false)
289 : pos(pos_), domain(domain_), atEnd(atEnd_) {}
300 if (++pos[d] > domain.
getHi()[d])
302 pos[d] = domain.
getLo()[d];
329 return (atEnd==it.atEnd) && (pos==it.pos);
339 const LimitType&
getPos() {
return pos; }
344 return iterator(*
this, this->
getLo());
349 return iterator(*
this, this->
getLo(),
true);
const iterator operator++(int)
Postfix increment. Increments the iterator by one position.
Definition: range.hpp:320
bool operator==(const iterator &it)
Equality test.
Definition: range.hpp:327
iterator(const iterator &it)
Copy constructor.
Definition: range.hpp:311
Definition: range.hpp:276
const LimitType & getHi() const
Return rectangle maximum.
Definition: range.hpp:77
iterator & operator++()
Prefix increment. Increments the iterator by one position.
Definition: range.hpp:314
LimitType & getLo()
Return rectangle minimum.
Definition: range.hpp:82
const LimitType & getPos()
Returns the current iterator position.
Definition: range.hpp:339
bool inside(const LimitType &p)
Returns true if the argument lies within the range.
Definition: range.hpp:87
LimitType & getHi()
Return rectangle maximum.
Definition: range.hpp:84
Range(const Array< T, rank, ArrayCheckingPolicy > &lo_, const Array< T, rank, ArrayCheckingPolicy > &hi_)
Construct with rectangle minimum and maximum.
Definition: range.hpp:56
Range()
Default constructor.
Definition: range.hpp:51
iterator end()
Creates an iterator pointing to a position after the end of the rectangle.
Definition: range.hpp:348
const LimitType & operator*()
Returns the current iterator position.
Definition: range.hpp:336
Range< T, destLength, CheckingPolicy > project() const
projects the Array onto an Array of shorter length
Definition: range.hpp:96
Range & operator=(const Range &domain)
Assignment operator.
Definition: range.hpp:65
bool operator!=(const iterator &it)
Equality test.
Definition: range.hpp:333
iterator begin()
Creates an iterator pointing to the beginning of the rectangle.
Definition: range.hpp:343
const LimitType & getLo() const
Return rectangle minimum.
Definition: range.hpp:73
Range(const Range< T, rank, ArrayCheckingPolicy > &domain)
Copy constructor.
Definition: range.hpp:61