76 #ifndef SLIP_BLOCK2D_HPP
77 #define SLIP_BLOCK2D_HPP
92 #include <boost/serialization/access.hpp>
93 #include <boost/serialization/split_member.hpp>
94 #include <boost/serialization/string.hpp>
95 #include <boost/serialization/complex.hpp>
96 #include <boost/serialization/version.hpp>
101 template<
class T,
int NC>
123 template <
typename T, std::
size_t NR, std::
size_t NC>
126 template <
typename T, std::
size_t NR, std::
size_t NC>
130 template <
typename T, std::
size_t NR, std::
size_t NC>
134 template <
typename T, std::
size_t NR, std::
size_t NC>
138 template <
typename T, std::
size_t NR, std::
size_t NC>
139 bool operator<(const slip::block2d<T,NR,NC>& x,
142 template <
typename T, std::
size_t NR, std::
size_t NC>
146 template <
typename T, std::
size_t NR, std::
size_t NC>
147 bool operator<=(const slip::block2d<T,NR,NC>& x,
150 template <
typename T, std::
size_t NR, std::
size_t NC>
174 template <
typename T, std::
size_t NR, std::
size_t NC>
233 static const std::size_t
SIZE = NR * NC;
235 static const std::size_t
DIM = 2;
445 return this->
data + NC * row;
470 return this->
data + NC * row;
652 assert(range.
start() >= 0);
653 assert(range.
stop() >= 0);
654 assert(range.
start() < int(NC));
655 assert(range.
stop() < int(NC));
687 assert(range.
start() < int(NC));
688 assert(range.
stop() < int(NC));
721 assert(range.
start() >= 0);
722 assert(range.
stop() >= 0);
723 assert(range.
start() < int(NC));
724 assert(range.
stop() < int(NC));
757 assert(range.
start() < int(NC));
758 assert(range.
stop() < int(NC));
792 assert(range.
start() >= 0);
793 assert(range.
stop() >= 0);
794 assert(range.
start() < int(NR));
795 assert(range.
stop() < int(NR));
828 assert(range.
start() < int(NR));
829 assert(range.
stop() < int(NR));
865 assert(range.
start() >= 0);
866 assert(range.
stop() >= 0);
867 assert(range.
start() < int(NR));
868 assert(range.
stop() < int(NR));
902 assert(range.
start() < int(NR));
903 assert(range.
stop() < int(NR));
1391 iterator2d it = (*this).upper_left(box) + dp;
2032 friend std::ostream& operator<< <>(std::ostream & out,
2068 template<
typename InputIterator>
2169 return this->
data + NC * i;
2185 return this->
data + NC * i;
2206 return this->
data[i * NC + j];
2226 return this->
data[i * NC + j];
2242 assert(this->
data != 0);
2243 assert(point2d[0] < NR);
2244 assert(point2d[1] < NC);
2245 return this->
data[point2d[0] * NC + point2d[1]];
2261 assert(this->
data != 0);
2262 assert(point2d[0] < NR);
2263 assert(point2d[1] < NC);
2264 return this->
data[point2d[0] * NC + point2d[1]];
2276 std::string
name()
const {
return "block2d";}
2333 template<
class Archive>
2334 void save(Archive & ar,
const unsigned int version)
const
2338 template<
class Archive>
2339 void load(Archive & ar,
const unsigned int version)
2344 BOOST_SERIALIZATION_SPLIT_MEMBER()
2354 template<
typename T,std::
size_t NR, std::
size_t NC>
2359 for(std::size_t i = 0; i < NR; ++i)
2361 for(std::size_t j = 0; j < NC; ++j)
2363 assert( (i * NC + j) < NR*NC);
2364 out<<b.
data[i * NC + j]<<
" ";
2373 template <
typename T, std::
size_t NR, std::
size_t NC>
2382 template <
typename T, std::
size_t NR, std::
size_t NC>
2394 template <
typename T, std::
size_t NR, std::
size_t NC>
2396 bool operator<(const block2d<T,NR,NC>& x,
2399 return std::lexicographical_compare(x.begin(), x.end(),
2400 y.begin(), y.end());
2403 template <
typename T, std::
size_t NR, std::
size_t NC>
2411 template <
typename T, std::
size_t NR, std::
size_t NC>
2413 bool operator<=(const block2d<T,NR,NC>& x,
2419 template <
typename T, std::
size_t NR, std::
size_t NC>
2430 #endif //SLIP_BLOCK2D_HPP
reverse_row_range_iterator row_rend(const size_type row, const slip::Range< int > &range)
Returns a read-write iterator that points one before the first element of the Range range of the row ...
static bool empty()
Returns true if the block is empty. (Thus size == 0)
const_iterator end() const
Returns a read-only (constant) iterator that points one past the last element in the block2d...
std::reverse_iterator< const_iterator2d > const_reverse_iterator2d
bool operator!=(const Array< T > &x, const Array< T > &y)
const_reverse_iterator2d_range rupper_left(const Range< int > &row_range, const Range< int > &col_range) const
Returns a read-only reverse_iterator2d_range that points to the past the bottom right element of the ...
reverse_iterator2d rbottom_right()
Returns a read/write reverse iterator2d. It points to past the upper left element of the block2d...
std::reverse_iterator< const_iterator > const_reverse_row_iterator
std::size_t iterations() const
Rerturns the number of iterations of the range.
const_reverse_iterator rbegin() const
Returns a read-only (constant) reverse iterator that points to the last element in the block2d...
static size_type columns()
Returns the number of columns (second dimension size) in the block2d.
Provides a class to modelize the difference of slip::Point2d.
CoordType height() const
compute the height of the Box2d.
const_reverse_iterator2d rbottom_right(const Box2d< int > &box) const
Returns a read-only reverse iterator2d. It points to one before the element of the bottom right eleme...
const_reverse_row_iterator row_rend(const size_type row) const
Returns a read-only reverse iterator that points one past the first element of the row row in the blo...
row_range_iterator row_end(const size_type row, const slip::Range< int > &range)
Returns a read/write iterator that points one past the end element of the Range range of the row row ...
const_iterator2d_range bottom_right(const Range< int > &row_range, const Range< int > &col_range) const
Returns a read-only iterator2d_range that points to the past the end bottom right element of the rang...
col_range_iterator col_end(const size_type col, const slip::Range< int > &range)
Returns a read-write iterator that points to the past the end element of the Range range of the col c...
const_col_range_iterator col_begin(const size_type col, const slip::Range< int > &range) const
Returns a read-only iterator that points to the first element of the Range range of the col col in th...
const_iterator2d bottom_right() const
Returns a read-only iterator2d that points to the past the end element of the block2d. It points to past the end element of the bottom right element of the block2d.
const_iterator2d bottom_right(const Box2d< int > &box) const
Returns a read only iterator2d that points to the past the end element of the block2d. It points to past the end element of the bottom right element of the Box2d associated to the block2d.
reverse_iterator2d rupper_left(const Box2d< int > &box)
Returns a read/write reverse iterator2d. It points to the bottom right element of the Box2d associate...
pointer operator[](const size_type i)
Subscript access to the row datas contained in the block2d.
Provides a class to manipulate 2d box.
friend class boost::serialization::access
This is some iterator to iterate a 2d container into two Range defined by the indices and strides of ...
ptrdiff_t difference_type
static size_type dim2()
Returns the number of columns (second dimension size) in the block2d.
row_iterator row_end(const size_type row)
Returns a read/write iterator that points one past the end element of the row row in the block2d...
iterator2d default_iterator
reverse_row_iterator row_rend(const size_type row)
Returns a read/write reverse iterator that points one past the first element of the row row in the bl...
col_iterator col_begin(const size_type col)
Returns a read/write iterator that points to the first element of the column column in the block2d...
reverse_col_range_iterator col_rend(const size_type col, const slip::Range< int > &range)
Returns a read-write iterator that points to one before the first element of the Range range of the c...
Provides a class to manipulate iterator2d within a slip::Box2d. It is used to iterate throw 2d contai...
const_reference operator()(const Point2d< size_type > &point2d) const
Subscript access to the data contained in the block2d.
iterator end()
Returns a read/write iterator that points one past the last element in the block2d. Iteration is done in ordinary element order.
slip::stride_iterator< const_pointer > const_row_range_iterator
slip::kstride_iterator< const_pointer, NC > const_col_iterator
const_reference operator()(const size_type i, const size_type j) const
Subscript access to the data contained in the block2d.
This is a two-dimensional static and generic container. This container statisfies the BidirectionnalC...
reverse_col_range_iterator col_rbegin(const size_type col, const slip::Range< int > &range)
Returns a read-write iterator that points to the last element of the Range range of the col col in th...
CoordType width() const
compute the width of the Box2d.
const_reverse_col_iterator col_rend(const size_type col) const
Returns a read-only reverse iterator that points one past the first element of the column column in t...
const_iterator2d_range upper_left(const Range< int > &row_range, const Range< int > &col_range) const
Returns a read-only iterator2d_range that points to the to the upper left element of the ranges row_r...
reverse_row_iterator row_rbegin(const size_type row)
Returns a read/write reverse iterator that points to the last element of the row row in the block2d...
reverse_col_iterator col_rend(const size_type col)
Returns a read/write reverse iterator that points one past the first element of the column column in ...
static size_type max_size()
Returns the maximal size (number of elements) in the block2d.
const_reverse_row_iterator row_rbegin(const size_type row) const
Returns a read-only reverse iterator that points to the last element of the row row in the block2d...
slip::iterator2d_range< self > iterator2d_range
Provides a class to iterate a 1d range according to a constant step.
std::reverse_iterator< const_col_range_iterator > const_reverse_col_range_iterator
reverse_row_range_iterator row_rbegin(const size_type row, const slip::Range< int > &range)
Returns a read-write iterator that points to the last element of the Range range of the row row in th...
iterator2d_range upper_left(const Range< int > &range)
Returns a read/write iterator2d_range that points to the upper left element of the Range range associ...
iterator begin()
Returns a read/write iterator that points to the first element in the block2d. Iteration is done in o...
const_col_iterator col_end(const size_type col) const
Returns a read-only iterator that points one past the end element of the column column in the block2d...
slip::kstride_iterator< pointer, NC > col_iterator
const_reverse_iterator2d rupper_left(const Box2d< int > &box) const
Returns a read only reverse iterator2d. It points to the bottom right element of the Box2d box associ...
void fill(InputIterator first, InputIterator last)
Fills the container range [begin(),begin()+SIZE) with a copy of the range [first,last) ...
bool operator>(const Array< T > &x, const Array< T > &y)
slip::stride_iterator< const_col_iterator > const_col_range_iterator
reverse_iterator2d_range rupper_left(const Range< int > &row_range, const Range< int > &col_range)
Returns a read/write reverse_iterator2d_range that points to the past the bottom right element of the...
void fill(const T *value)
Fills the container range [begin(),begin()+SIZE) with a copy of the value array.
This is a point2d class, a specialized version of Point<CoordType,DIM> with DIM = 2...
self & operator=(const T &value)
Assign all the elments of the block2d by value.
const value_type * const_pointer
std::string name() const
Returns the name of the class.
static size_type rows()
Returns the number of rows (first dimension size) in the block2d.
slip::const_iterator2d_range< const_self > const_iterator2d_range
const value_type & const_reference
iterator2d_range bottom_right(const Range< int > &row_range, const Range< int > &col_range)
Returns a read/write iterator2d_range that points to the past the end bottom right element of the ran...
const_reverse_col_iterator col_rbegin(const size_type col) const
Returns a read-only reverse iterator that points to the last element of the column column in the bloc...
This is some iterator to iterate a 2d container into a Box area defined by the indices of the 2d cont...
std::reverse_iterator< const_iterator > const_reverse_iterator
void swap(block2d< T, NR, NC > &x)
Swaps data with another block.
std::reverse_iterator< row_range_iterator > reverse_row_range_iterator
const_reverse_iterator rend() const
Returns a read-only (constant) reverse iterator that points to one before the first element in the bl...
reverse_iterator2d_range rbottom_right(const Range< int > &range)
Returns a read/write reverse_iterator2d_range that points to one before the upper left element of the...
const_pointer operator[](const size_type i) const
Subscript access to the row datas contained in the block2d.
iterator2d_range bottom_right(const Range< int > &range)
Returns a read/write iterator2d_range that points to the past the end bottom right element of the Ran...
const_pointer const_row_iterator
row_iterator row_begin(const size_type row)
Returns a read/write iterator that points to the first element of the row row in the block2d...
const block2d< T, NR, NC > const_self
std::reverse_iterator< const_row_range_iterator > const_reverse_row_range_iterator
iterator2d bottom_right()
Returns a read/write iterator2d that points to the past the end element of the block2d. It points to past the end element of the bottom right element of the block2d.
const_reverse_row_range_iterator row_rbegin(const size_type row, const slip::Range< int > &range) const
Returns a read-only iterator that points to the last element of the Range range of the row row in the...
void copy(_II first, _II last, _OI output_first)
Copy algorithm optimized for slip iterators.
Difference of Point2D class, specialization of DPoint<CoordType,DIM> with DIM = 2.
bool is_valid() const
Returns true if the range is valid :
SubType start() const
Accessor of the start subscript of the Range.
slip::stride_iterator< pointer > row_range_iterator
const_reverse_col_range_iterator col_rbegin(const size_type col, const slip::Range< int > &range) const
Returns a read_only iterator that points to the last element of the Range & range of the col col in t...
const_row_range_iterator row_begin(const size_type row, const slip::Range< int > &range) const
Returns a read-only iterator that points to the first element of the Range range of the row row in th...
reverse_col_iterator col_rbegin(const size_type col)
Returns a read/write reverse iterator that points to the last element of the column column in the blo...
std::reverse_iterator< const_iterator2d_range > const_reverse_iterator2d_range
reverse_iterator2d rupper_left()
Returns a read/write reverse iterator2d. It points to the bottom right element of the block2d...
const_reverse_iterator2d_range rbottom_right(const Range< int > &range) const
Returns a read_only reverse_iterator2d_range that points to one before the upper left element of the ...
col_iterator col_end(const size_type col)
Returns a read/write iterator that points one past the end element of the column column in the block2...
iterator2d upper_left()
Returns a read/write iterator2d that points to the first element of the block2d. It points to the upp...
reverse_iterator2d_range rbottom_right(const Range< int > &row_range, const Range< int > &col_range)
Returns a read/write reverse_iterator2d_range that points to one before the upper left element of the...
iterator2d_range upper_left(const Range< int > &row_range, const Range< int > &col_range)
Returns a read/write iterator2d_range that points to the upper left element of the ranges row_range a...
const_row_iterator row_end(const size_type row) const
Returns a read-only iterator that points one past the end element of the row row in the block2d...
This is some iterator to iterate a 2d container into a slip::Box2d area defined by the indices of the...
static size_type cols()
Returns the number of columns (second dimension size) in the block2d.
const_reverse_col_range_iterator col_rend(const size_type col, const slip::Range< int > &range) const
Returns a read-only iterator that points to the first element of the Range range of the col col in th...
std::reverse_iterator< const_col_iterator > const_reverse_col_iterator
const_reverse_iterator2d rupper_left() const
Returns a read only reverse iterator2d that points. It points to the bottom right element of the bloc...
slip::stride_iterator< col_iterator > col_range_iterator
static size_type size()
Returns the number of elements in the block2d.
slip::iterator2d_box< self > iterator2d
const_col_range_iterator col_end(const size_type col, const slip::Range< int > &range) const
Returns a read-only iterator that points to the past the end element of the Range range of the col co...
reference operator()(const size_type i, const size_type j)
Subscript access to the data contained in the block2d.
reverse_iterator2d_range rupper_left(const Range< int > &range)
Returns a read/write reverse_iterator2d_range that points to the bottom right element of the Range ra...
std::ostream & operator<<(std::ostream &out, const Array< T > &a)
std::reverse_iterator< iterator2d_range > reverse_iterator2d_range
const_reverse_iterator2d_range rbottom_right(const Range< int > &row_range, const Range< int > &col_range) const
Returns a read-only reverse_iterator2d_range that points to one before the upper left element of the ...
iterator2d upper_left(const Box2d< int > &box)
Returns a read/write iterator2d that points to the first element of the block2d. It points to the upp...
const_iterator2d const_default_iterator
void fill(const T &value)
Fills the container range [begin(),begin()+SIZE) with copies of value.
static const std::size_t DIM
const_iterator2d_range bottom_right(const Range< int > &range) const
Returns a read-only const_iterator2d_range that points to the past the end bottom right element of th...
This is some iterator to iterate a 2d container into two Range defined by the indices and strides of ...
col_range_iterator col_begin(const size_type col, const slip::Range< int > &range)
Returns a read-write iterator that points to the first element of the Range range of the col col in t...
std::reverse_iterator< iterator > reverse_iterator
reverse_iterator rbegin()
Returns a read/write reverse iterator that points to the last element in the block2d. Iteration is done in reverse element order.
iterator2d bottom_right(const Box2d< int > &box)
Returns a read/write iterator2d that points to the past the end element of the block2d. It points to past the end element of the bottom right element of the Box2d associated to the block2d.
const_iterator2d upper_left(const Box2d< int > &box) const
Returns a read only iterator2d that points to the first element of the block2d. It points to the uppe...
std::reverse_iterator< iterator > reverse_row_iterator
int stride() const
Accessor of the stride of the Range.
const_iterator2d_range upper_left(const Range< int > &range) const
Returns a read-only iterator2d_range that points to the to the upper left element of the Range range ...
static const std::size_t SIZE
Size of the block2d.
slip::const_iterator2d_box< const_self > const_iterator2d
const_reverse_iterator2d_range rupper_left(const Range< int > &range) const
Returns a read-only reverse_iterator2d_range that points to the to the bottom right element of the Ra...
Provides a class to modelize 2d points.
std::reverse_iterator< col_range_iterator > reverse_col_range_iterator
Provides a class to iterate a 1d range according to a step.
std::reverse_iterator< iterator2d > reverse_iterator2d
T data[SIZE]
Data array storage of the block2d.
const_iterator begin() const
Returns a read-only (constant) iterator that points to the first element in the block2d. Iteration is done in ordinary element order.
std::reverse_iterator< col_iterator > reverse_col_iterator
const_col_iterator col_begin(const size_type col) const
Returns a read-only iterator that points to the first element of the column column in the block2d...
bool operator==(const Array< T > &x, const Array< T > &y)
const_iterator2d upper_left() const
Returns a read-only iterator2d that points to the first element of the block2d. It points to the uppe...
const_row_range_iterator row_end(const size_type row, const slip::Range< int > &range) const
Returns a read_only iterator that points one past the last element of the Range range of the row row ...
const_reverse_row_range_iterator row_rend(const size_type row, const slip::Range< int > &range) const
Returns a read-only iterator that points one before the first element of the Range range of the row r...
reverse_iterator rend()
Returns a read/write reverse iterator that points to one before the first element in the block2d...
reference operator()(const Point2d< size_type > &point2d)
Subscript access to the data contained in the block2d.
row_range_iterator row_begin(const size_type row, const slip::Range< int > &range)
Returns a read/write iterator that points to the first element of the Range range of the row row in t...
const_pointer const_iterator
Provides a class to manipulate Ranges.
Provides a class to manipulate iterator2d within a slip::Range. It is used to iterate throw 2d contai...
SubType stop() const
Accessor of the stop subscript of the Range.
bool operator>=(const Array< T > &x, const Array< T > &y)
const_row_iterator row_begin(const size_type row) const
Returns a read-only iterator that points to the first element of the row row in the block2d...
const_reverse_iterator2d rbottom_right() const
Returns a read only reverse iterator2d. It points to past the upper left element of the block2d...
static size_type dim1()
Returns the number of rows (first dimension size) in the block2d.
reverse_iterator2d rbottom_right(const Box2d< int > &box)
Returns a read/write reverse iterator2d. It points to one before the upper left element of the Box2d ...