76 #ifndef SLIP_ITERATOR2D_RANGE_HPP
77 #define SLIP_ITERATOR2D_RANGE_HPP
118 template <
class Container2D>
119 class iterator2d_range
126 typedef typename Container2D::pointer
pointer;
142 cont2d_(0),pos_(0),x1_(0),x2_(0),range_x1_(0,0),range_x2_(0,0)
158 cont2d_(c),pos_((*c)[r1.start()] + r2.start()),x1_(r1.start()),x2_(r2.start()),range_x1_(r1),range_x2_(r2)
167 cont2d_(o.cont2d_),pos_(o.pos_),x1_(o.x1_),x2_(o.x2_),
168 range_x1_(o.range_x1_), range_x2_(o.range_x2_)
189 this->cont2d_ = o.cont2d_;
193 this->range_x1_ = o.range_x1_;
194 this->range_x2_ = o.range_x2_;
236 this->x2_+= range_x2_.
stride();
237 this->pos_+= range_x2_.
stride();
241 this->x1_+= range_x1_.
stride();
242 this->x2_ = range_x2_.
start();
243 this->pos_ = cont2d_->begin() + (this->x1_ * int(cont2d_->cols())) + this->x2_;
248 this->x1_ = int(range_x1_.
start()
250 this->x2_ = int(range_x2_.
start()
252 this->pos_ = cont2d_->begin() + (this->x1_ * int(cont2d_->cols())) + this->x2_;
289 this->x2_ -= range_x2_.
stride();
290 this->pos_ -= range_x2_.
stride();
294 this->x1_-= range_x1_.
stride();
296 this->pos_ = cont2d_->begin() + (this->x1_ * int(cont2d_->cols())) + this->x2_;
303 this->pos_ = cont2d_->begin() + (this->x1_ * int(cont2d_->cols())) + this->x2_;
340 return ( (i1.cont2d_ == i2.cont2d_) && (i1.pos_ == i2.pos_)
341 && (i1.x1_ == i2.x1_) && (i1.x2_ == i2.x2_) );
354 return ( (i1.cont2d_ != i2.cont2d_) || (i1.pos_ != i2.pos_)
355 || (i1.x1_ != i2.x1_) || (i1.x2_ != i2.x2_) );
374 return ( i1.pos_ < i2.pos_);
435 this->x1_ += this->range_x1_.
stride() * d.
dx1();
436 this->x2_ += this->range_x2_.
stride() * d.
dx2();
437 this->pos_ = cont2d_->begin() + (this->x1_ * int(cont2d_->cols())) + this->x2_;
451 this->x1_ -= this->range_x1_.
stride() * d.
dx1();
452 this->x2_ -= this->range_x2_.
stride() * d.
dx2();
453 this->pos_ = cont2d_->begin() + (this->x1_ * int(cont2d_->cols())) + this->x2_;
499 assert(i1.range_x1_.stride() == i2.range_x1_.stride());
500 assert(i1.range_x2_.stride() == i2.range_x2_.stride());
501 return difference_type(
int((i1.x1_ - i2.x1_)/i1.range_x1_.stride()),
int((i1.x2_ - i2.x2_))/i1.range_x2_.stride());
516 assert( (
int(this->x1_)+ range_x1_.
stride() * d.
dx1()) <
int(cont2d_->dim1() ));
517 assert( (
int(this->x2_)+ range_x2_.
stride() * d.
dx2()) <
int(cont2d_->dim2() ));
518 return (*cont2d_)[this->x1_+ range_x1_.
stride() * d.
dx1()][this->x2_+ range_x2_.
stride() * d.
dx2()];
532 return cont2d_->row_begin(range_x1_.
start() + row * range_x1_.
stride(), range_x2_);
559 return cont2d_->col_begin(range_x2_.
start() + col * range_x2_.
stride(), range_x1_);
624 Container2D* cont2d_;
661 template <
class Container2D>
662 class const_iterator2d_range
669 typedef typename Container2D::const_pointer
pointer;
670 typedef typename Container2D::const_reference
reference;
685 cont2d_(0),pos_(0),x1_(0),x2_(0),range_x1_(0,0),range_x2_(0,0)
701 cont2d_(c),pos_((*c)[r1.start()] + r2.start()),x1_(r1.start()),x2_(r2.start()),range_x1_(r1),range_x2_(r2)
710 cont2d_(o.cont2d_),pos_(o.pos_),x1_(o.x1_),x2_(o.x2_),
711 range_x1_(o.range_x1_), range_x2_(o.range_x2_)
732 this->cont2d_ = o.cont2d_;
736 this->range_x1_ = o.range_x1_;
737 this->range_x2_ = o.range_x2_;
783 this->x2_+= range_x2_.
stride();
784 this->pos_+= range_x2_.
stride();
788 this->x1_+= range_x1_.
stride();
789 this->x2_ = range_x2_.
start();
790 this->pos_ = cont2d_->begin() + (this->x1_ * int(cont2d_->cols())) + this->x2_;
795 this->x1_ = int(range_x1_.
start()
797 this->x2_ = int(range_x2_.
start()
799 this->pos_ = cont2d_->begin() + (this->x1_ * int(cont2d_->cols())) + this->x2_;
836 this->x2_ -= range_x2_.
stride();
837 this->pos_ -= range_x2_.
stride();
841 this->x1_-= range_x1_.
stride();
843 this->pos_ = cont2d_->begin() + (this->x1_ * int(cont2d_->cols())) + this->x2_;
850 this->pos_ = cont2d_->begin() + (this->x1_ * int(cont2d_->cols())) + this->x2_;
887 return ( (i1.cont2d_ == i2.cont2d_) && (i1.pos_ == i2.pos_)
888 && (i1.x1_ == i2.x1_) && (i1.x2_ == i2.x2_) );
901 return ( (i1.cont2d_ != i2.cont2d_) || (i1.pos_ != i2.pos_)
902 || (i1.x1_ != i2.x1_) || (i1.x2_ != i2.x2_) );
921 return ( i1.pos_ < i2.pos_);
987 this->x1_ += this->range_x1_.
stride() * d.
dx1();
988 this->x2_ += this->range_x2_.
stride() * d.
dx2();
989 this->pos_ = cont2d_->begin() + (this->x1_ * int(cont2d_->cols())) + this->x2_;
1007 this->x1_ -= this->range_x1_.
stride() * d.
dx1();
1008 this->x2_ -= this->range_x2_.
stride() * d.
dx2();
1009 this->pos_ = cont2d_->begin() + (this->x1_ * int(cont2d_->cols())) + this->x2_;
1055 assert(i1.range_x1_.stride() == i2.range_x1_.stride());
1056 assert(i1.range_x2_.stride() == i2.range_x2_.stride());
1057 return difference_type(
int((i1.x1_ - i2.x1_)/i1.range_x1_.stride()),
int((i1.x2_ - i2.x2_))/i1.range_x2_.stride());
1075 assert( (this->x1_+ range_x1_.
stride() * d.
dx1()) < cont2d_->dim1() );
1076 assert( (this->x2_+ range_x2_.
stride() * d.
dx2()) < cont2d_->dim2() );
1077 return (*cont2d_)[this->x1_+ range_x1_.
stride() * d.
dx1()][this->x2_+ range_x2_.
stride() * d.
dx2()];
1092 return cont2d_->row_begin(range_x1_.
start() + row * range_x1_.
stride(), range_x2_);
1120 return cont2d_->col_begin(range_x2_.
start() + col * range_x2_.
stride(), range_x1_);
1189 Container2D* cont2d_;
1202 #endif //SLIP_ITERATOR2D_RANGE_HPP
std::size_t iterations() const
Rerturns the number of iterations of the range.
self & operator-=(const difference_type &d)
iterator2d_range substraction.
friend bool operator!=(const self &i1, const self &i2)
Inequality operator.
friend bool operator<=(const self &i1, const self &i2)
<= operator.
Provides a class to modelize the difference of slip::Point2d.
friend bool operator==(const self &i1, const self &i2)
Equality operator.
pointer operator->() const
Container2D::const_pointer pointer
Container2D::value_type value_type
friend bool operator<(const self &i1, const self &i2)
< operator.
friend bool operator>=(const self &i1, const self &i2)
>= operator.
void dx2(const CoordType &dx)
Accessor of the second coordinate of DPoint2d.
const_iterator2d_range(const self &o)
Constructs a copy of the const_iterator2d_range o.
Container2D::col_range_iterator col_end(size_type col)
iterator2d_range element assignment operator.
reference operator*() const
Dereference operator. Returns the element that the current const_iterator2d_range i point to...
friend bool operator>(const self &i1, const self &i2)
operator.
self & operator--()
Predecrement a const_iterator2d_range. Iterate to the previous location inside the Range2d...
iterator2d_range(Container2D *c, const slip::Range< int > &r1, const slip::Range< int > &r2)
Constructs a iterator2d_range.
self operator--(int)
Postdecrement a const_iterator2d_range. Iterate to the previous location inside the Range2d...
This is some iterator to iterate a 2d container into two Range defined by the indices and strides of ...
Container2D::row_range_iterator row_begin(size_type row)
iterator2d_range element assignment operator.
self operator++(int)
Postincrement a const_iterator2d_range. Iterate to the next location inside the Range2d.
Container2D::const_reference reference
friend bool operator<(const self &i1, const self &i2)
< operator.
self operator-(const difference_type &d)
iterator2d_range substraction.
Provides a class to tag SLIP iterators.
Container2D::const_row_range_iterator row_begin(size_type row) const
const_iterator2d_range element assignment operator.
iterator2d_range()
Constructs a iterator2d_range.
friend bool operator<=(const self &i1, const self &i2)
<= operator.
int i() const
Access to the first index of the current iterator2d_range.
int j() const
Access to the second index of the current const_iterator2d_range.
self operator--(int)
Postdecrement a iterator2d_range. Iterate to the previous location inside the Range2d.
friend difference_type operator-(const self &i1, const self &i2)
iterator2d_range difference operator.
self & operator++()
Preincrement a const_iterator2d_range. Iterate to the next location inside the Range.
int x2() const
Access to the second index of the current iterator2d_range.
friend bool operator==(const self &i1, const self &i2)
Equality operator.
Container2D::value_type value_type
self operator++(int)
Postincrement a iterator2d_range. Iterate to the next location inside the Range2d.
Container2D::reference reference
void dx1(const CoordType &dx)
Accessor of the first coordinate of DPoint2d.
DPoint2d< int > difference_type
self operator-(const difference_type &d)
const_iterator2d_range substraction.
friend bool operator>=(const self &i1, const self &i2)
>= operator.
int x2() const
Access to the second index of the current const_iterator2d_range.
Container2D::const_col_range_iterator col_end(size_type col) const
const_iterator2d_range element assignment operator.
Container2D::pointer pointer
DPoint2d< int > difference_type
self operator+(const difference_type &d)
iterator2d_range addition.
Difference of Point2D class, specialization of DPoint<CoordType,DIM> with DIM = 2.
SubType start() const
Accessor of the start subscript of the Range.
std::random_access_iterator2d_tag iterator_category
self & operator-=(const difference_type &d)
const_iterator2d_range substraction.
reference operator[](difference_type d)
iterator2d_range element assignment operator. Equivalent to *(i + d) = t.
self operator+(const difference_type &d)
const_iterator2d_range addition.
int j() const
Access to the second index of the current iterator2d_range.
Container2D::const_col_range_iterator col_begin(size_type col) const
const_iterator2d_range element assignment operator.
self & operator+=(const difference_type &d)
const_iterator2d_range addition.
self & operator+=(const difference_type &d)
iterator2d_range addition.
const_iterator2d_range(Container2D *c, const slip::Range< int > &r1, const slip::Range< int > &r2)
Constructs a const_iterator2d_range.
self & operator--()
Predecrement a iterator2d_range. Iterate to the previous location inside the Range2d.
int i() const
Access to the first index of the current const_iterator2d_range.
Container2D::size_type size_type
reference operator*()
Dereference assignment operator. Returns the element that the current iterator2d_range i point to...
This is some iterator to iterate a 2d container into two Range defined by the indices and strides of ...
const_iterator2d_range()
Constructs a const_iterator2d_range.
int stride() const
Accessor of the stride of the Range.
Container2D::col_range_iterator col_begin(size_type col)
iterator2d_range element assignment operator.
int x1() const
Access to the first index of the current const_iterator2d_range.
Provides a class to modelize 2d points.
Container2D::size_type size_type
iterator2d_range(const self &o)
Constructs a copy of the iterator2d_range o.
Container2D::const_row_range_iterator row_end(size_type row) const
const_iterator2d_range element assignment operator.
self & operator=(const self &o)
Assign a const_iterator2d_range.
friend difference_type operator-(const self &i1, const self &i2)
const_iterator2d_range difference operator.
friend bool operator>(const self &i1, const self &i2)
operator.
Container2D::row_range_iterator row_end(size_type row)
iterator2d_range element assignment operator.
int x1() const
Access to the first index of the current iterator2d_range.
self & operator++()
Preincrement a iterator2d_range. Iterate to the next location inside the Range.
Provides a class to manipulate Ranges.
friend bool operator!=(const self &i1, const self &i2)
Inequality operator.
self & operator=(const self &o)
Assign a iterator2d_range.
SubType stop() const
Accessor of the stop subscript of the Range.
std::random_access_iterator2d_tag iterator_category
reference operator[](difference_type d) const
const_iterator2d_range element assignment operator. Equivalent to *(i + d).