SLIP  1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Array2d.hpp
Go to the documentation of this file.
1 /*
2  * Copyright(c):
3  * Signal Image and Communications (SIC) Department
4  * http://www.sic.sp2mi.univ-poitiers.fr/
5  * - University of Poitiers, France http://www.univ-poitiers.fr
6  * - XLIM Institute UMR CNRS 7252 http://www.xlim.fr/
7  *
8  * and
9  *
10  * D2 Fluid, Thermic and Combustion
11  * - University of Poitiers, France http://www.univ-poitiers.fr
12  * - PPRIME Institute - UPR CNRS 3346 http://www.pprime.fr
13  * - ISAE-ENSMA http://www.ensma.fr
14  *
15  * Contributor(s):
16  * The SLIP team,
17  * Benoit Tremblais <tremblais_AT_sic.univ-poitiers.fr>,
18  * Laurent David <laurent.david_AT_lea.univ-poitiers.fr>,
19  * Ludovic Chatellier <ludovic.chatellier_AT_univ-poitiers.fr>,
20  * Lionel Thomas <lionel.thomas_AT_univ-poitiers.fr>,
21  * Denis Arrivault <arrivault_AT_sic.univ-poitiers.fr>,
22  * Julien Dombre <julien.dombre_AT_univ-poitiers.fr>.
23  *
24  * Description:
25  * The Simple Library of Image Processing (SLIP) is a new image processing
26  * library. It is written in the C++ language following as much as possible
27  * the ISO/ANSI C++ standard. It is consequently compatible with any system
28  * satisfying the ANSI C++ complience. It works on different Unix , Linux ,
29  * Mircrosoft Windows and Mac OS X plateforms. SLIP is a research library that
30  * was created by the Signal, Image and Communications (SIC) departement of
31  * the XLIM, UMR 7252 CNRS Institute in collaboration with the Fluids, Thermic
32  * and Combustion departement of the P', UPR 3346 CNRS Institute of the
33  * University of Poitiers.
34  *
35  * The SLIP Library source code has been registered to the APP (French Agency
36  * for the Protection of Programs) by the University of Poitiers and CNRS,
37  * under registration number IDDN.FR.001.300034.000.S.P.2010.000.21000.
38 
39  * http://www.sic.sp2mi.univ-poitiers.fr/slip/
40  *
41  * This software is governed by the CeCILL-C license under French law and
42  * abiding by the rules of distribution of free software. You can use,
43  * modify and/ or redistribute the software under the terms of the CeCILL-C
44  * license as circulated by CEA, CNRS and INRIA at the following URL
45  * http://www.cecill.info.
46  * As a counterpart to the access to the source code and rights to copy,
47  * modify and redistribute granted by the license, users are provided only
48  * with a limited warranty and the software's author, the holder of the
49  * economic rights, and the successive licensors have only limited
50  * liability.
51  *
52  * In this respect, the user's attention is drawn to the risks associated
53  * with loading, using, modifying and/or developing or reproducing the
54  * software by the user in light of its specific status of free software,
55  * that may mean that it is complicated to manipulate, and that also
56  * therefore means that it is reserved for developers and experienced
57  * professionals having in-depth computer knowledge. Users are therefore
58  * encouraged to load and test the software's suitability as regards their
59  * requirements in conditions enabling the security of their systems and/or
60  * data to be ensured and, more generally, to use and operate it in the
61  * same conditions as regards security.
62  *
63  * The fact that you are presently reading this means that you have had
64  * knowledge of the CeCILL-C license and that you accept its terms.
65  */
66 
67 
68 
69 
70 
71 
79 #ifndef SLIP_ARRAY2D_HPP
80 #define SLIP_ARRAY2D_HPP
81 
82 #include <iostream>
83 #include <iterator>
84 #include <cassert>
85 #include <string>
86 #include <cstddef>
87 #include "Box2d.hpp"
88 #include "Point2d.hpp"
89 #include "DPoint2d.hpp"
90 #include "stride_iterator.hpp"
91 #include "iterator2d_box.hpp"
92 #include "Range.hpp"
93 #include "iterator2d_range.hpp"
94 
95 
96 #include <boost/serialization/access.hpp>
97 #include <boost/serialization/split_member.hpp>
98 #include <boost/serialization/string.hpp>
99 #include <boost/serialization/complex.hpp>
100 #include <boost/serialization/version.hpp>
101 
109 namespace slip
110 {
111 
112 template<class T>
114 
115 template<class T>
117 
118 template<class T>
120 
121 template<class T>
123 
124 template<class T>
126 
127 
128 template <class T>
129 class DPoint2d;
130 
131 template <class T>
132 class Point2d;
133 
134 template <typename T>
135 class Array2d;
136 
137 template <typename T>
138 std::ostream& operator<<(std::ostream & out,
139  const slip::Array2d<T>& a);
140 
141 template<typename T>
142 bool operator==(const slip::Array2d<T>& x,
143  const slip::Array2d<T>& y);
144 
145 template<typename T>
146 bool operator!=(const slip::Array2d<T>& x,
147  const slip::Array2d<T>& y);
148 
149 template<typename T>
150 bool operator<(const slip::Array2d<T>& x,
151  const slip::Array2d<T>& y);
152 
153 template<typename T>
154 bool operator>(const slip::Array2d<T>& x,
155  const slip::Array2d<T>& y);
156 
157 template<typename T>
158 bool operator<=(const slip::Array2d<T>& x,
159  const slip::Array2d<T>& y);
160 
161 template<typename T>
162 bool operator>=(const slip::Array2d<T>& x,
163  const slip::Array2d<T>& y);
164 
165 
188 template <typename T>
189 class Array2d
190 {
191 public:
192  typedef T value_type;
193  typedef Array2d<T> self;
194  typedef const Array2d<T> const_self;
195 
197  typedef value_type const& const_reference;
198 
199  typedef value_type* pointer;
200  typedef value_type const* const_pointer;
201 
202 
203  typedef ptrdiff_t difference_type;
204  typedef std::size_t size_type;
205 
206  typedef pointer iterator;
208 
209  typedef std::reverse_iterator<iterator> reverse_iterator;
210  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
211 
214 
217 
220 
225 
228 
229  typedef std::reverse_iterator<iterator> reverse_row_iterator;
230  typedef std::reverse_iterator<const_iterator> const_reverse_row_iterator;
231  typedef std::reverse_iterator<col_iterator> reverse_col_iterator;
232  typedef std::reverse_iterator<const_col_iterator> const_reverse_col_iterator;
233  typedef std::reverse_iterator<iterator2d> reverse_iterator2d;
234  typedef std::reverse_iterator<const_iterator2d> const_reverse_iterator2d;
235  typedef std::reverse_iterator<row_range_iterator> reverse_row_range_iterator;
236  typedef std::reverse_iterator<const_row_range_iterator> const_reverse_row_range_iterator;
237  typedef std::reverse_iterator<col_range_iterator> reverse_col_range_iterator;
238  typedef std::reverse_iterator<const_col_range_iterator> const_reverse_col_range_iterator;
239  typedef std::reverse_iterator<iterator2d_range> reverse_iterator2d_range;
240  typedef std::reverse_iterator<const_iterator2d_range> const_reverse_iterator2d_range;
241 
242  //default iterator of the container
245 
246  static const std::size_t DIM = 2;
251 
255  Array2d();
256 
264  Array2d(const size_type d1,
265  const size_type d2);
266 
273  Array2d(const size_type d1,
274  const size_type d2,
275  const T& val);
276 
283  Array2d(const size_type d1,
284  const size_type d2,
285  const T* val);
286 
297  template<typename InputIterator>
298  Array2d(const size_type d1,
299  const size_type d2,
300  InputIterator first,
301  InputIterator last):
302  d1_(d1),d2_(d2),size_(d1*d2)
303  {
304  this->allocate();
305  std::fill_n(this->begin(),this->size_,T());
306  std::copy(first,last, this->begin());
307  }
308 
312  Array2d(const self& rhs);
313 
317  ~Array2d();
318 
319 
329  void resize(const size_type d1,
330  const size_type d2,
331  const T& val = T());
332 
337 
357  iterator begin();
358 
359 
379  iterator end();
380 
401  const_iterator begin() const;
402 
403 
423  const_iterator end() const;
424 
446 
468 
490 
491 
513 
514 
534  row_iterator row_begin(const size_type row);
535 
536 
556  row_iterator row_end(const size_type row);
557 
558 
578  const_row_iterator row_begin(const size_type row) const;
579 
580 
600  const_row_iterator row_end(const size_type row) const;
601 
621  col_iterator col_begin(const size_type col);
622 
623 
643  col_iterator col_end(const size_type col);
644 
664  const_col_iterator col_begin(const size_type col) const;
665 
666 
667 
687  const_col_iterator col_end(const size_type col) const;
688 
689 
715  const slip::Range<int>& range);
716 
717 
718 
744  const slip::Range<int>& range);
745 
746 
772  const slip::Range<int>& range) const;
773 
774 
799  const slip::Range<int>& range) const;
800 
801 
827  const slip::Range<int>& range);
828 
855  const slip::Range<int>& range);
856 
857 
858 
859 
885  const slip::Range<int>& range) const;
886 
887 
914  const slip::Range<int>& range) const;
915 
916 
917 
930 
931 
944 
957 
970 
984 
985 
999 
1013 
1014 
1028 
1029 
1045  const slip::Range<int>& range);
1046 
1047 
1064  const slip::Range<int>& range);
1065 
1066 
1067 
1081  const slip::Range<int>& range) const;
1082 
1083 
1099  const slip::Range<int>& range) const;
1100 
1101 
1102 
1103 
1119  const slip::Range<int>& range);
1120 
1137  const slip::Range<int>& range);
1138 
1139 
1155  col_rbegin(const size_type col,
1156  const slip::Range<int>& range) const;
1157 
1158 
1174  const slip::Range<int>& range) const;
1175 
1176 
1195 
1196 
1215 
1216 
1234  const_iterator2d upper_left() const;
1235 
1236 
1255 
1279  iterator2d upper_left(const Box2d<int>& box);
1280 
1281 
1306  iterator2d bottom_right(const Box2d<int>& box);
1307 
1308 
1333  const_iterator2d upper_left(const Box2d<int>& box) const;
1334 
1335 
1360  const_iterator2d bottom_right(const Box2d<int>& box) const;
1361 
1362 
1390  iterator2d_range upper_left(const Range<int>& row_range,
1391  const Range<int>& col_range);
1392 
1420  iterator2d_range bottom_right(const Range<int>& row_range,
1421  const Range<int>& col_range);
1422 
1423 
1451  const_iterator2d_range upper_left(const Range<int>& row_range,
1452  const Range<int>& col_range) const;
1453 
1454 
1483  const Range<int>& col_range) const;
1484 
1485 
1486 
1487 
1488 
1513  iterator2d_range upper_left(const Range<int>& range);
1514 
1515 
1542 
1543 
1544 
1545 
1570  const_iterator2d_range upper_left(const Range<int>& range) const;
1571 
1572 
1573 
1599  const_iterator2d_range bottom_right(const Range<int>& range) const;
1600 
1601 
1612 
1623 
1634 
1635 
1646 
1647 
1663 
1679 
1695 
1696 
1712 
1713 
1731  const Range<int>& col_range);
1732 
1733 
1734 
1752  const Range<int>& col_range);
1753 
1754 
1755 
1773  const Range<int>& col_range) const;
1774 
1792  const Range<int>& col_range) const;
1793 
1794 
1795 
1812 
1813 
1814 
1832 
1833 
1851 
1852 
1870 
1871 
1884  friend std::ostream& operator<< <>(std::ostream & out,
1885  const self& a);
1886 
1901  self& operator=(const self & rhs);
1902 
1903 
1911  self& operator=(const T& value)
1912  {
1913  this->fill(value);
1914  return *this;
1915  }
1916 
1917 
1923  void fill(const T& value)
1924  {
1925  std::fill_n(this->begin(),this->size_,value);
1926  }
1927 
1934  void fill(const T* value)
1935  {
1936  std::copy(value,value + this->size_, this->begin());
1937  }
1938 
1947  template<typename InputIterator>
1948  void fill(InputIterator first,
1949  InputIterator last)
1950  {
1951  std::copy(first,last, this->begin());
1952  }
1965  friend bool operator== <>(const Array2d<T>& x,
1966  const Array2d<T>& y);
1967 
1974  friend bool operator!= <>(const Array2d<T>& x,
1975  const Array2d<T>& y);
1976 
1983  friend bool operator< <>(const Array2d<T>& x,
1984  const Array2d<T>& y);
1985 
1992  friend bool operator> <>(const Array2d<T>& x,
1993  const Array2d<T>& y);
1994 
2001  friend bool operator<= <>(const Array2d<T>& x,
2002  const Array2d<T>& y);
2003 
2010  friend bool operator>= <>(const Array2d<T>& x,
2011  const Array2d<T>& y);
2012 
2013 
2031  pointer operator[](const size_type i);
2032 
2043  const_pointer operator[](const size_type i) const;
2044 
2045 
2058  reference operator()(const size_type i,
2059  const size_type j);
2060 
2074  const size_type j) const;
2075 
2087  reference operator()(const Point2d<size_type>& point2d);
2088 
2100  const_reference operator()(const Point2d<size_type>& point2d) const;
2101 
2102 
2115  self operator()(const Range<int>& row_range,
2116  const Range<int>& col_range);
2117 
2118 
2125  std::string name() const;
2126 
2127 
2132  size_type dim1() const;
2133 
2138  size_type rows() const;
2139 
2144  size_type dim2() const;
2145 
2150  size_type columns() const;
2151 
2156  size_type cols() const;
2157 
2161  size_type size() const;
2162 
2166  size_type max_size() const;
2167 
2171  bool empty()const;
2172 
2180  void swap(self& M);
2181 
2182 private:
2183  size_type d1_;
2184  size_type d2_;
2185  size_type size_;
2186  T** data_;
2187 
2189  void allocate();
2191  void desallocate();
2196  void copy_attributes(const self& rhs);
2197 
2198 
2200  template<class Archive>
2201  void save(Archive & ar, const unsigned int version) const
2202  {
2203  ar & this->d1_ & this->d2_ & this->size_ ;
2204  for(std::size_t i = 0; i < this->size_; ++i)
2205  {
2206  ar & data_[0][i];
2207  }
2208  }
2209  template<class Archive>
2210  void load(Archive & ar, const unsigned int version)
2211  {
2212  ar & this->d1_ & this->d2_ & this->size_ ;
2213  this->desallocate();
2214  this->allocate();
2215  for(std::size_t i = 0; i < this->size_; ++i)
2216  {
2217  ar & data_[0][i];
2218  }
2219  }
2220  BOOST_SERIALIZATION_SPLIT_MEMBER();
2221 };
2222  // end of Containers2d group
2224 
2245 
2246 
2247 }//slip::
2248 
2249 namespace slip
2250 {
2251  template<typename T>
2252  inline
2254  d1_(0),d2_(0),size_(0),data_(0)
2255  {}
2256 
2257  template<typename T>
2258  inline
2260  const typename Array2d<T>::size_type d2):
2261  d1_(d1),d2_(d2),size_(d1*d2)
2262  {
2263  this->allocate();
2264  std::fill_n(this->data_[0],this->size_,T());
2265  }
2266 
2267  template<typename T>
2268  inline
2270  const typename Array2d<T>::size_type d2,
2271  const T& val):
2272  d1_(d1),d2_(d2),size_(d1*d2)
2273  {
2274  this->allocate();
2275  std::fill_n(this->data_[0],this->size_,val);
2276  }
2277 
2278  template<typename T>
2279  inline
2281  const typename Array2d<T>::size_type d2,
2282  const T* val):
2283  d1_(d1),d2_(d2),size_(d1*d2)
2284  {
2285  this->allocate();
2286  std::copy(val,val + this->size_, this->data_[0]);
2287  }
2288 
2289  template<typename T>
2290  inline
2292  d1_(rhs.d1_),d2_(rhs.d2_),size_(rhs.size_)
2293  {
2294  this->allocate();
2295  if(this->size_ != 0)
2296  {
2297  std::copy(rhs.data_[0],rhs.data_[0] + this->size_,this->data_[0]);
2298  }
2299  }
2300 
2301  template<typename T>
2302  inline
2304  {
2305  if(this != &rhs)
2306  {
2307  if( this->d1_ != rhs.d1_ || this->d2_ != rhs.d2_)
2308  {
2309  this->desallocate();
2310  this->copy_attributes(rhs);
2311  this->allocate();
2312  }
2313  if(rhs.size_ != 0)
2314  {
2315  std::copy(rhs.data_[0],rhs.data_[0] + this->size_,this->data_[0]);
2316  }
2317  }
2318  return *this;
2319  }
2320 
2321  template<typename T>
2322  inline
2324  const typename Array2d<T>::size_type d2,
2325  const T& val)
2326  {
2327  if( this->d1_ != d1 || this->d2_ != d2 )
2328  {
2329  this->desallocate();
2330  this->d1_ = d1;
2331  this->d2_ = d2;
2332  this->size_ = d1 * d2;
2333  this->allocate();
2334  }
2335  if((this->d1_ != 0) && (this->d2_ != 0))
2336  {
2337  std::fill_n(this->data_[0],this->size_,val);
2338  }
2339 
2340  }
2341 
2342 
2343  template<typename T>
2344  inline
2346  {
2347  return this->data_[0];
2348  }
2349 
2350  template<typename T>
2351  inline
2353  {
2354  return this->data_[0] + this->size_;
2355  }
2356 
2357  template<typename T>
2358  inline
2360  {
2361  return this->data_[0];
2362  }
2363 
2364  template<typename T>
2365  inline
2367  {
2368  return this->data_[0] + this->size_;
2369  }
2370 
2371 
2372  template<typename T>
2373  inline
2375  {
2376  return typename Array2d<T>::reverse_iterator(this->end());
2377  }
2378 
2379  template<typename T>
2380  inline
2382  {
2383  return typename Array2d<T>::const_reverse_iterator(this->end());
2384  }
2385 
2386  template<typename T>
2387  inline
2389  {
2390  return typename Array2d<T>::reverse_iterator(this->begin());
2391  }
2392 
2393 
2394  template<typename T>
2395  inline
2397  {
2398  return typename Array2d<T>::const_reverse_iterator(this->begin());
2399  }
2400 
2401  template<typename T>
2402  inline
2403  typename Array2d<T>::row_iterator
2404  Array2d<T>::row_begin(const typename Array2d<T>::size_type row)
2405  {
2406  assert(row < this->d1_);
2407  return this->data_[row];
2408  }
2409 
2410  template<typename T>
2411  inline
2412  typename Array2d<T>::const_row_iterator
2413  Array2d<T>::row_begin(const typename Array2d<T>::size_type row) const
2414  {
2415  assert(row < this->d1_);
2416  return this->data_[row];
2417  }
2418 
2419  template<typename T>
2420  inline
2421  typename Array2d<T>::row_range_iterator
2422  Array2d<T>::row_begin(const typename Array2d<T>::size_type row,
2423  const slip::Range<int>& range)
2424  {
2425  assert(row < this->d1_);
2426  assert(range.is_valid());
2427  assert(range.start() >= 0);
2428  assert(range.stop() >= 0);
2429  assert(range.start() < (int)this->d2_);
2430  assert(range.stop() < (int)this->d2_);
2431  return slip::stride_iterator<typename Array2d<T>::row_iterator>(this->row_begin(row) + range.start(),range.stride());
2432  }
2433 
2434  template<typename T>
2435  inline
2436  typename Array2d<T>::const_row_range_iterator
2437  Array2d<T>::row_begin(const typename Array2d<T>::size_type row,
2438  const slip::Range<int>& range) const
2439  {
2440  assert(row < this->d1_);
2441  assert(range.is_valid());
2442  assert(range.start() >= 0);
2443  assert(range.stop() >= 0);
2444  assert(range.start() < (int)this->d2_);
2445  assert(range.stop() < (int)this->d2_);
2446  return slip::stride_iterator<typename Array2d<T>::const_row_iterator>(this->row_begin(row) + range.start(),range.stride());
2447  }
2448 
2449  template<typename T>
2450  inline
2451  typename Array2d<T>::col_range_iterator
2452  Array2d<T>::col_begin(const typename Array2d<T>::size_type col,
2453  const slip::Range<int>& range)
2454  {
2455  assert(col < this->d2_);
2456  assert(range.is_valid());
2457  assert(range.start() >= 0);
2458  assert(range.stop() >= 0);
2459  assert(range.start() < (int)this->d1_);
2460  assert(range.stop() < (int)this->d1_);
2461  return slip::stride_iterator<typename Array2d<T>::col_iterator>(this->col_begin(col) + range.start(),range.stride());
2462  }
2463 
2464  template<typename T>
2465  inline
2466  typename Array2d<T>::const_col_range_iterator
2467  Array2d<T>::col_begin(const typename Array2d<T>::size_type col,
2468  const slip::Range<int>& range) const
2469  {
2470  assert(col < this->d2_);
2471  assert(range.is_valid());
2472  assert(range.start() >= 0);
2473  assert(range.stop() >= 0);
2474  assert(range.start() < (int)this->d1_);
2475  assert(range.stop() < (int)this->d1_);
2476  return slip::stride_iterator<typename Array2d<T>::const_col_iterator>(this->col_begin(col) + range.start(),range.stride());
2477  }
2478 
2479  template<typename T>
2480  inline
2481  typename Array2d<T>::row_iterator
2482  Array2d<T>::row_end(const typename Array2d<T>::size_type row)
2483  {
2484  assert(row < this->d1_);
2485  return this->data_[row] + this->d2_;
2486  }
2487 
2488  template<typename T>
2489  inline
2490  typename Array2d<T>::const_row_iterator
2491  Array2d<T>::row_end(const typename Array2d<T>::size_type row) const
2492  {
2493  assert(row < this->d1_);
2494  return this->data_[row] + this->d2_;
2495  }
2496 
2497  template<typename T>
2498  inline
2499  typename Array2d<T>::row_range_iterator
2500  Array2d<T>::row_end(const typename Array2d<T>::size_type row,
2501  const slip::Range<int>& range)
2502  {
2503  assert(row < this->d1_);
2504  assert(range.start() < (int)this->d2_);
2505  assert(range.stop() < (int)this->d2_);
2506  // return ++(slip::stride_iterator<typename Array2d<T>::row_iterator>(this->data_[row] + range.stop(),range.stride()));
2507  return ++(this->row_begin(row,range) + range.iterations());
2508  }
2509 
2510  template<typename T>
2511  inline
2512  typename Array2d<T>::const_row_range_iterator
2513  Array2d<T>::row_end(const typename Array2d<T>::size_type row,
2514  const slip::Range<int>& range) const
2515  {
2516  assert(row < this->d1_);
2517  assert(range.start() < (int)this->d2_);
2518  assert(range.stop() < (int)this->d2_);
2519  // return ++(slip::stride_iterator<typename Array2d<T>::const_row_iterator>(this->data_[row] + range.stop(),range.stride()));
2520  return ++(this->row_begin(row,range) + range.iterations());
2521  }
2522 
2523  template<typename T>
2524  inline
2525  typename Array2d<T>::col_range_iterator
2526  Array2d<T>::col_end(const typename Array2d<T>::size_type col,
2527  const slip::Range<int>& range)
2528  {
2529  assert(col < this->d2_);
2530  assert(range.start() < (int)this->d1_);
2531  assert(range.stop() < (int)this->d1_);
2532  // return ++(slip::stride_iterator<typename Array2d<T>::col_iterator>(this->col_begin(col) + range.stop(),range.stride()));
2533  return ++(this->col_begin(col,range) + range.iterations());
2534  }
2535 
2536  template<typename T>
2537  inline
2538  typename Array2d<T>::const_col_range_iterator
2539  Array2d<T>::col_end(const typename Array2d<T>::size_type col,
2540  const slip::Range<int>& range) const
2541  {
2542  assert(col < this->d2_);
2543  assert(range.start() < (int)this->d1_);
2544  assert(range.stop() < (int)this->d1_);
2545  // return ++(slip::stride_iterator<typename Array2d<T>::const_col_iterator>(this->col_begin(col) + range.stop(),range.stride()));
2546  return ++(this->col_begin(col,range) + range.iterations());
2547  }
2548 
2549  template<typename T>
2550  inline
2551  typename Array2d<T>::col_iterator
2552  Array2d<T>::col_begin(const typename Array2d<T>::size_type col)
2553  {
2554  assert(col < this->d2_);
2555  return typename Array2d<T>::col_iterator(this->data_[0] + col,this->d2_);
2556  }
2557 
2558  template<typename T>
2559  inline
2560  typename Array2d<T>::const_col_iterator
2561  Array2d<T>::col_begin(const typename Array2d<T>::size_type col) const
2562  {
2563  assert(col < this->d2_);
2564  return typename Array2d<T>::const_col_iterator(this->data_[0] + col,this->d2_);
2565  }
2566 
2567  template<typename T>
2568  inline
2569  typename Array2d<T>::col_iterator
2570  Array2d<T>::col_end(const typename Array2d<T>::size_type col)
2571  {
2572  assert(col < this->d2_);
2573  return ++(typename Array2d<T>::col_iterator(this->data_[this->d1_- 1] + col,this->d2_));
2574  }
2575 
2576  template<typename T>
2577  inline
2578  typename Array2d<T>::const_col_iterator
2579  Array2d<T>::col_end(const typename Array2d<T>::size_type col) const
2580  {
2581  assert(col < this->d2_);
2582  return ++(typename Array2d<T>::const_col_iterator(this->data_[this->d1_- 1] + col,this->d2_));
2583  }
2584 
2585 
2586  template<typename T>
2587  inline
2588  typename Array2d<T>::reverse_row_iterator
2589  Array2d<T>::row_rbegin(const typename Array2d<T>::size_type row)
2590  {
2591  return typename Array2d<T>::reverse_row_iterator(this->row_end(row));
2592  }
2593 
2594  template<typename T>
2595  inline
2596  typename Array2d<T>::const_reverse_row_iterator
2597  Array2d<T>::row_rbegin(const typename Array2d<T>::size_type row) const
2598  {
2599  return typename Array2d<T>::const_reverse_row_iterator(this->row_end(row));
2600  }
2601 
2602  template<typename T>
2603  inline
2604  typename Array2d<T>::reverse_row_iterator
2605  Array2d<T>::row_rend(const typename Array2d<T>::size_type row)
2606  {
2607  return typename Array2d<T>::reverse_row_iterator(this->row_begin(row));
2608  }
2609 
2610  template<typename T>
2611  inline
2612  typename Array2d<T>::const_reverse_row_iterator
2613  Array2d<T>::row_rend(const typename Array2d<T>::size_type row) const
2614  {
2615  return typename Array2d<T>::const_reverse_row_iterator(this->row_begin(row));
2616  }
2617 
2618 
2619  template<typename T>
2620  inline
2621  typename Array2d<T>::reverse_col_iterator
2622  Array2d<T>::col_rbegin(const typename Array2d<T>::size_type col)
2623  {
2624  return typename Array2d<T>::reverse_col_iterator(this->col_end(col));
2625  }
2626 
2627  template<typename T>
2628  inline
2629  typename Array2d<T>::const_reverse_col_iterator
2630  Array2d<T>::col_rbegin(const typename Array2d<T>::size_type col) const
2631  {
2632  return typename Array2d<T>::const_reverse_col_iterator(this->col_end(col));
2633  }
2634 
2635  template<typename T>
2636  inline
2637  typename Array2d<T>::reverse_col_iterator
2638  Array2d<T>::col_rend(const typename Array2d<T>::size_type col)
2639  {
2640  return typename Array2d<T>::reverse_col_iterator(this->col_begin(col));
2641  }
2642 
2643  template<typename T>
2644  inline
2645  typename Array2d<T>::const_reverse_col_iterator
2646  Array2d<T>::col_rend(const typename Array2d<T>::size_type col) const
2647  {
2648  return typename Array2d<T>::const_reverse_col_iterator(this->col_begin(col));
2649  }
2650  //------------
2651  template<typename T>
2652  inline
2653  typename Array2d<T>::reverse_row_range_iterator
2654  Array2d<T>::row_rbegin(const typename Array2d<T>::size_type row,
2655  const slip::Range<int>& range)
2656  {
2657  assert(row < this->d1_);
2658  assert(range.start() < (int)this->d2_);
2659  return typename Array2d<T>::reverse_row_range_iterator(this->row_end(row,range));
2660  }
2661 
2662  template<typename T>
2663  inline
2664  typename Array2d<T>::const_reverse_row_range_iterator
2665  Array2d<T>::row_rbegin(const typename Array2d<T>::size_type row,
2666  const slip::Range<int>& range) const
2667  {
2668  assert(row < this->d1_);
2669  assert(range.start() < (int)this->d2_);
2670  return typename Array2d<T>::const_reverse_row_range_iterator(this->row_end(row,range));
2671  }
2672 
2673 
2674  template<typename T>
2675  inline
2676  typename Array2d<T>::reverse_col_range_iterator
2677  Array2d<T>::col_rbegin(const typename Array2d<T>::size_type col,
2678  const slip::Range<int>& range)
2679  {
2680  assert(col < this->d2_);
2681  assert(range.start() < (int)this->d1_);
2682  return typename Array2d<T>::reverse_col_range_iterator(this->col_end(col,range));
2683  }
2684 
2685  template<typename T>
2686  inline
2687  typename Array2d<T>::const_reverse_col_range_iterator
2688  Array2d<T>::col_rbegin(const typename Array2d<T>::size_type col,
2689  const slip::Range<int>& range) const
2690  {
2691  assert(col < this->d2_);
2692  assert(range.start() < (int)this->d1_);
2693  return typename Array2d<T>::const_reverse_col_range_iterator(this->col_end(col,range));
2694  }
2695 
2696  template<typename T>
2697  inline
2698  typename Array2d<T>::reverse_row_range_iterator
2699  Array2d<T>::row_rend(const typename Array2d<T>::size_type row,
2700  const slip::Range<int>& range)
2701  {
2702  assert(row < this->d1_);
2703  assert(range.start() < (int)this->d2_);
2704  return typename Array2d<T>::reverse_row_range_iterator(this->row_begin(row,range));
2705  }
2706 
2707  template<typename T>
2708  inline
2709  typename Array2d<T>::const_reverse_row_range_iterator
2710  Array2d<T>::row_rend(const typename Array2d<T>::size_type row,
2711  const slip::Range<int>& range) const
2712  {
2713  assert(row < this->d1_);
2714  assert(range.start() < (int)this->d2_);
2715  return typename Array2d<T>::const_reverse_row_range_iterator(this->row_begin(row,range));
2716  }
2717 
2718 
2719  template<typename T>
2720  inline
2721  typename Array2d<T>::reverse_col_range_iterator
2722  Array2d<T>::col_rend(const typename Array2d<T>::size_type col,
2723  const slip::Range<int>& range)
2724  {
2725  assert(col < this->d2_);
2726  assert(range.start() < (int)this->d1_);
2727  return typename Array2d<T>::reverse_col_range_iterator(this->col_begin(col,range));
2728  }
2729 
2730  template<typename T>
2731  inline
2732  typename Array2d<T>::const_reverse_col_range_iterator
2733  Array2d<T>::col_rend(const typename Array2d<T>::size_type col,
2734  const slip::Range<int>& range) const
2735  {
2736  assert(col < this->d2_);
2737  assert(range.start() < (int)this->d1_);
2738  return typename Array2d<T>::const_reverse_col_range_iterator(this->col_begin(col,range));
2739  }
2740 
2741 
2742  template<typename T>
2743  inline
2745  {
2746  return typename Array2d<T>::iterator2d(this,Box2d<int>(0,0,this->d1_-1,this->d2_-1));
2747  }
2748 
2749  template<typename T>
2750  inline
2752  {
2753  return typename Array2d<T>::const_iterator2d(this,Box2d<int>(0,0,this->d1_-1,this->d2_-1));
2754  }
2755 
2756 
2757  template<typename T>
2758  inline
2760  {
2761  DPoint2d<int> dp(this->d1_,this->d2_);
2762  typename Array2d<T>::iterator2d it = (*this).upper_left() + dp;
2763  return it;
2764  }
2765 
2766  template<typename T>
2767  inline
2769  {
2770  DPoint2d<int> dp(this->d1_,this->d2_);
2771  typename Array2d<T>::const_iterator2d it = (*this).upper_left() + dp;
2772  return it;
2773  }
2774 
2775  template<typename T>
2776  inline
2778  {
2779  return typename Array2d<T>::iterator2d(this,box);
2780  }
2781 
2782  template<typename T>
2783  inline
2785  {
2786  return typename Array2d<T>::const_iterator2d(this,box);
2787  }
2788 
2789 
2790  template<typename T>
2791  inline
2792  typename Array2d<T>::iterator2d
2794  {
2795  DPoint2d<int> dp(box.height(),box.width());
2796  typename Array2d<T>::iterator2d it = (*this).upper_left(box) + dp;
2797  return it;
2798  }
2799 
2800  template<typename T>
2801  inline
2804  {
2805  DPoint2d<int> dp(box.height(),box.width());
2806  typename Array2d<T>::const_iterator2d it = (*this).upper_left(box) + dp;
2807  return it;
2808  }
2809 
2810  template<typename T>
2811  inline
2814  const Range<int>& col_range)
2815  {
2816  return typename Array2d<T>::iterator2d_range(this,row_range,col_range);
2817  }
2818 
2819  template<typename T>
2820  inline
2823  const Range<int>& col_range) const
2824  {
2825  return typename Array2d<T>::const_iterator2d_range(this,row_range,col_range);
2826  }
2827 
2828  template<typename T>
2829  inline
2832  const Range<int>& col_range)
2833  {
2834  DPoint2d<int> dp(row_range.iterations()+1,col_range.iterations()+1);
2835  return typename Array2d<T>::iterator2d_range((*this).upper_left(row_range,col_range) + dp);
2836  }
2837 
2838  template<typename T>
2839  inline
2842  const Range<int>& col_range) const
2843  {
2844  DPoint2d<int> dp(row_range.iterations()+1,col_range.iterations()+1);
2845  return typename Array2d<T>::const_iterator2d_range ((*this).upper_left(row_range,col_range) + dp);
2846  }
2847 
2848 
2849  template<typename T>
2850  inline
2853  {
2854  return this->upper_left(range,range);
2855  }
2856 
2857  template<typename T>
2858  inline
2861  {
2862  return this->upper_left(range,range);
2863  }
2864 
2865  template<typename T>
2866  inline
2869  {
2870  return this->bottom_right(range,range);
2871  }
2872 
2873  template<typename T>
2874  inline
2877  {
2878  return this->bottom_right(range,range);
2879  }
2880  //--
2881  template<typename T>
2882  inline
2885  {
2886  return typename Array2d<T>::reverse_iterator2d(this->upper_left());
2887  }
2888 
2889  template<typename T>
2890  inline
2893  {
2894  return typename Array2d<T>::const_reverse_iterator2d(this->upper_left());
2895  }
2896 
2897  template<typename T>
2898  inline
2901  {
2902  slip::DPoint2d<int> dp(1,0);
2903  return typename Array2d<T>::reverse_iterator2d(this->bottom_right() - dp);
2904  }
2905 
2906  template<typename T>
2907  inline
2910  {
2911  slip::DPoint2d<int> dp(1,0);
2912  return typename Array2d<T>::const_reverse_iterator2d(this->bottom_right()-dp);
2913  }
2914 
2915  template<typename T>
2916  inline
2919  {
2920  return typename Array2d<T>::reverse_iterator2d(this->upper_left(box));
2921  }
2922 
2923  template<typename T>
2924  inline
2927  {
2928  return typename Array2d<T>::const_reverse_iterator2d(this->upper_left(box));
2929  }
2930 
2931  template<typename T>
2932  inline
2935  {
2936  slip::DPoint2d<int> dp(1,0);
2937  return typename Array2d<T>::reverse_iterator2d(this->bottom_right(box) - dp);
2938  }
2939 
2940  template<typename T>
2941  inline
2944  {
2945  slip::DPoint2d<int> dp(1,0);
2946  return typename Array2d<T>::const_reverse_iterator2d(this->bottom_right(box) - dp);
2947  }
2948 
2949  template<typename T>
2950  inline
2953  const Range<int>& col_range)
2954  {
2955  slip::DPoint2d<int> dp(1,0);
2956  return typename Array2d<T>::reverse_iterator2d_range(this->bottom_right(row_range,col_range) - dp);
2957  }
2958 
2959  template<typename T>
2960  inline
2963  const Range<int>& col_range) const
2964  {
2965  slip::DPoint2d<int> dp(1,0);
2966  return typename Array2d<T>::const_reverse_iterator2d_range(this->bottom_right(row_range,col_range)- dp);
2967  }
2968 
2969  template<typename T>
2970  inline
2973  const Range<int>& col_range)
2974  {
2975  return typename Array2d<T>::reverse_iterator2d_range(this->upper_left(row_range,col_range));
2976  }
2977 
2978  template<typename T>
2979  inline
2982  const Range<int>& col_range) const
2983  {
2984  return typename Array2d<T>::const_reverse_iterator2d_range(this->upper_left(row_range,col_range));
2985  }
2986 
2987  template<typename T>
2988  inline
2991  {
2992  return this->rupper_left(range,range);
2993  }
2994 
2995  template<typename T>
2996  inline
2999  {
3000  return this->rupper_left(range,range);
3001  }
3002 
3003  template<typename T>
3004  inline
3007  {
3008  return this->rbottom_right(range,range);
3009  }
3010 
3011  template<typename T>
3012  inline
3015  {
3016  return this->rbottom_right(range,range);
3017  }
3018 
3020  /* @{ */
3021  template <typename T>
3022  inline
3023  std::ostream& operator<<(std::ostream & out, const Array2d<T>& a)
3024  {
3025  for(std::size_t i = 0; i < a.d1_; ++i)
3026  {
3027  for(std::size_t j = 0; j < a.d2_; ++j)
3028  {
3029  out<<a[i][j]<<" ";
3030  }
3031  out<<std::endl;
3032  }
3033  // out<<std::endl;
3034  return out;
3035  }
3036  /* @} */
3037 
3038  template<typename T>
3039  inline
3040  typename Array2d<T>::pointer
3041  Array2d<T>::operator[](const typename Array2d<T>::size_type i)
3042  {
3043  assert(this->data_ != 0);
3044  assert(i < this->size_);
3045  return this->data_[i];
3046  }
3047 
3048  template<typename T>
3049  inline
3050  typename Array2d<T>::const_pointer
3051  Array2d<T>::operator[](const typename Array2d<T>::size_type i) const
3052  {
3053  assert(this->data_ != 0);
3054  assert(i < this->size_);
3055  return this->data_[i];
3056  }
3057 
3058  template<typename T>
3059  inline
3060  typename Array2d<T>::reference
3061  Array2d<T>::operator()(const typename Array2d<T>::size_type i,
3062  const typename Array2d<T>::size_type j)
3063  {
3064  assert(this->data_ != 0);
3065  assert(i < this->d1_);
3066  assert(j < this->d2_);
3067  return this->data_[i][j];
3068  }
3069 
3070  template<typename T>
3071  inline
3072  typename Array2d<T>::const_reference
3073  Array2d<T>::operator()(const typename Array2d<T>::size_type i,
3074  const typename Array2d<T>::size_type j) const
3075  {
3076  assert(this->data_ != 0);
3077  assert(i < this->d1_);
3078  assert(j < this->d2_);
3079  return this->data_[i][j];
3080  }
3081 
3082  template<typename T>
3083  inline
3084  typename Array2d<T>::reference
3085  Array2d<T>::operator()(const Point2d<typename Array2d<T>::size_type>& point2d)
3086  {
3087  assert(this->data_ != 0);
3088  assert(point2d[0] < this->d1_);
3089  assert(point2d[1] < this->d2_);
3090  return this->data_[point2d[0]][point2d[1]];
3091  }
3092 
3093  template<typename T>
3094  inline
3095  typename Array2d<T>::const_reference
3096  Array2d<T>::operator()(const Point2d<typename Array2d<T>::size_type>& point2d) const
3097  {
3098  assert(this->data_ != 0);
3099  assert(point2d[0] < this->d1_);
3100  assert(point2d[1] < this->d2_);
3101  return this->data_[point2d[0]][point2d[1]];
3102  }
3103 
3104 
3105  template<typename T>
3106  inline
3107  Array2d<T>
3109  const Range<int>& col_range)
3110  {
3111  assert(this->data_ != 0);
3112  assert(row_range.is_valid());
3113  assert(row_range.start() < (int)this->d2_);
3114  assert(row_range.stop() < (int)this->d2_);
3115  assert(col_range.is_valid());
3116  assert(col_range.start() < (int)this->d1_);
3117  assert(col_range.stop() < (int)this->d1_);
3118  std::size_t rows = row_range.iterations() + 1;
3119  std::size_t cols = col_range.iterations() + 1;
3120  return Array2d<T>(rows,cols,this->upper_left(row_range,col_range),
3121  this->bottom_right(row_range,col_range));
3122  }
3123 
3124 
3125  template<typename T>
3126  inline
3127  std::string
3128  Array2d<T>::name() const {return "Array2d";}
3129 
3130 
3131  template<typename T>
3132  inline
3133  typename Array2d<T>::size_type
3134  Array2d<T>::dim1() const {return this->d1_;}
3135 
3136  template<typename T>
3137  inline
3138  typename Array2d<T>::size_type
3139  Array2d<T>::rows() const {return this->dim1();}
3140 
3141 
3142  template<typename T>
3143  inline
3144  typename Array2d<T>::size_type
3145  Array2d<T>::dim2() const {return this->d2_;}
3146 
3147  template<typename T>
3148  inline
3149  typename Array2d<T>::size_type
3150  Array2d<T>::columns() const {return this->dim2();}
3151 
3152  template<typename T>
3153  inline
3154  typename Array2d<T>::size_type
3155  Array2d<T>::cols() const {return this->dim2();}
3156 
3157  template<typename T>
3158  inline
3159  typename Array2d<T>::size_type
3160  Array2d<T>::size() const {return this->size_;}
3161 
3162  template<typename T>
3163  inline
3164  typename Array2d<T>::size_type
3166  {
3167  return typename Array2d<T>::size_type(-1)/sizeof(T);
3168  }
3169 
3170 
3171  template<typename T>
3172  inline
3173  bool Array2d<T>::empty()const {return this->size_ == 0;}
3174 
3175  template<typename T>
3176  inline
3178  {
3179  assert(this->d1_ == M.d1_);
3180  assert(this->d2_ == M.d2_);
3181  std::swap_ranges(this->begin(),this->end(),M.begin());
3182  }
3183 
3184  template<typename T>
3185  inline
3187  {
3188  this->desallocate();
3189  }
3190 
3191  template<typename T>
3192  inline
3193  void Array2d<T>::allocate()
3194  {
3195  if((this->d1_ != 0) && (this->d2_ != 0))
3196  {
3197  this->data_ = new T*[this->d1_];
3198  //the first row of data_ "contains" all the elements
3199  //of the 2D array
3200  this->data_[0] = new T[this->d1_ * this->d2_];
3201  //the other elements of the data_ array contains pointers to the
3202  //other rows of the 2D array
3203  for(typename Array2d<T>::size_type i = 1; i < this->d1_; ++i)
3204  {
3205  this->data_[i] = this->data_[i - 1] + this->d2_;
3206  }
3207  }
3208  else
3209  {
3210  this->data_ = 0;
3211  }
3212  }
3213 
3214  template<typename T>
3215  inline
3216  void Array2d<T>::desallocate()
3217  {
3218  if(this->data_ != 0)
3219  {
3220  delete[] (this->data_[0]);
3221  delete[] (this->data_);
3222  }
3223  }
3224 
3225  template<typename T>
3226  inline
3227  void Array2d<T>::copy_attributes(const Array2d<T>& rhs)
3228  {
3229  this->d1_ = rhs.d1_;
3230  this->d2_ = rhs.d2_;
3231  this->size_ = rhs.d1_ * rhs.d2_;
3232  }
3233 
3235  /* @{ */
3236 template<typename T>
3237 inline
3238 bool operator==(const Array2d<T>& x,
3239  const Array2d<T>& y)
3240 {
3241  return ( x.size() == y.size()
3242  && std::equal(x.begin(),x.end(),y.begin()));
3243 }
3244 
3245 template<typename T>
3246 inline
3247 bool operator!=(const Array2d<T>& x,
3248  const Array2d<T>& y)
3249 {
3250  return !(x == y);
3251 }
3252 
3253 /* @} */
3254 
3256  /* @{ */
3257 template<typename T>
3258 inline
3259 bool operator<(const Array2d<T>& x,
3260  const Array2d<T>& y)
3261 {
3262  return std::lexicographical_compare(x.begin(), x.end(),
3263  y.begin(), y.end());
3264 }
3265 
3266 
3267 template<typename T>
3268 inline
3269 bool operator>(const Array2d<T>& x,
3270  const Array2d<T>& y)
3271 {
3272  return (y < x);
3273 }
3274 
3275 template<typename T>
3276 inline
3277 bool operator<=(const Array2d<T>& x,
3278  const Array2d<T>& y)
3279 {
3280  return !(y < x);
3281 }
3282 
3283 template<typename T>
3284 inline
3285 bool operator>=(const Array2d<T>& x,
3286  const Array2d<T>& y)
3287 {
3288  return !(x < y);
3289 }
3290 /* @} */
3291 
3292 }//slip::
3293 
3294 #endif //SLIP_ARRAY2D_HPP
bool operator!=(const Array< T > &x, const Array< T > &y)
Definition: Array.hpp:1448
std::size_t iterations() const
Rerturns the number of iterations of the range.
Definition: Range.hpp:305
iterator2d upper_left()
Returns a read/write iterator2d that points to the first element of the Array2d. It points to the upp...
Definition: Array2d.hpp:2744
Provides a class to modelize the difference of slip::Point2d.
void fill(const T *value)
Fills the container range [begin(),begin()+size()) with a copy of the value array.
Definition: Array2d.hpp:1934
CoordType height() const
compute the height of the Box2d.
Definition: Box2d.hpp:378
std::reverse_iterator< const_iterator2d > const_reverse_iterator2d
Definition: Array2d.hpp:234
std::reverse_iterator< const_col_iterator > const_reverse_col_iterator
Definition: Array2d.hpp:232
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: Array2d.hpp:210
Provides a class to manipulate 2d box.
slip::iterator2d_box< self > iterator2d
Definition: Array2d.hpp:218
This is some iterator to iterate a 2d container into two Range defined by the indices and strides of ...
Definition: Array2d.hpp:119
std::size_t size_type
Definition: Array2d.hpp:204
Array2d(const size_type d1, const size_type d2, InputIterator first, InputIterator last)
Contructs a Array2d from a range.
Definition: Array2d.hpp:298
Provides a class to manipulate iterator2d within a slip::Box2d. It is used to iterate throw 2d contai...
pointer row_iterator
Definition: Array2d.hpp:212
reverse_iterator2d rupper_left()
Returns a read/write reverse iterator2d. It points to the bottom right element of the Array2d...
Definition: Array2d.hpp:2900
iterator2d bottom_right()
Returns a read/write iterator2d that points to the past the end element of the Array2d. It points to past the end element of the bottom right element of the Array2d.
Definition: Array2d.hpp:2759
CoordType width() const
compute the width of the Box2d.
Definition: Box2d.hpp:374
reference operator()(const size_type i, const size_type j)
Subscript access to the data contained in the Array2d.
slip::stride_iterator< const_pointer > const_col_iterator
Definition: Array2d.hpp:216
ptrdiff_t difference_type
Definition: Array2d.hpp:203
slip::Array2d< unsigned int > Array2d_ui
unsigned int alias
Definition: Array2d.hpp:2240
slip::const_iterator2d_box< const_self > const_iterator2d
Definition: Array2d.hpp:219
size_type max_size() const
Returns the maximal size (number of elements) in the Array2d.
Definition: Array2d.hpp:3165
value_type const & const_reference
Definition: Array2d.hpp:197
reverse_iterator2d rbottom_right()
Returns a read/write reverse iterator2d. It points to past the upper left element of the Array2d...
Definition: Array2d.hpp:2884
slip::Array2d< short > Array2d_s
short alias
Definition: Array2d.hpp:2234
size_type size() const
Returns the number of elements in the Array2d.
Definition: Array2d.hpp:3160
friend class boost::serialization::access
Definition: Array2d.hpp:2199
bool operator>(const Array< T > &x, const Array< T > &y)
Definition: Array.hpp:1469
std::reverse_iterator< col_iterator > reverse_col_iterator
Definition: Array2d.hpp:231
slip::stride_iterator< const_pointer > const_row_range_iterator
Definition: Array2d.hpp:222
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 Arr...
value_type * pointer
Definition: Array2d.hpp:199
This is a point2d class, a specialized version of Point<CoordType,DIM> with DIM = 2...
Definition: Array2d.hpp:132
~Array2d()
Destructor of the Array2d.
Definition: Array2d.hpp:3186
pointer operator[](const size_type i)
Subscript access to the row datas contained in the Array2d.
This is some iterator to iterate a 2d container into a Box area defined by the indices of the 2d cont...
Definition: Array2d.hpp:122
size_type columns() const
Returns the number of columns (second dimension size) in the Array2d.
Definition: Array2d.hpp:3150
pointer iterator
Definition: Array2d.hpp:206
void resize(const size_type d1, const size_type d2, const T &val=T())
Resizes a Array2d.
Definition: Array2d.hpp:2323
slip::Array2d< unsigned long > Array2d_ul
unsigned long alias
Definition: Array2d.hpp:2232
slip::Array2d< int > Array2d_i
int alias
Definition: Array2d.hpp:2238
size_type dim2() const
Returns the number of columns (second dimension size) in the Array2d.
Definition: Array2d.hpp:3145
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 Ar...
self & operator=(const self &rhs)
Assign a Array2d.
Definition: Array2d.hpp:2303
reverse_iterator rbegin()
Returns a read/write reverse iterator that points to the last element in the Array2d. Iteration is done in reverse element order.
Definition: Array2d.hpp:2374
void copy(_II first, _II last, _OI output_first)
Copy algorithm optimized for slip iterators.
Definition: copy_ext.hpp:177
Difference of Point2D class, specialization of DPoint<CoordType,DIM> with DIM = 2.
Definition: Array2d.hpp:129
bool is_valid() const
Returns true if the range is valid :
Definition: Range.hpp:322
SubType start() const
Accessor of the start subscript of the Range.
Definition: Range.hpp:284
const Array2d< T > const_self
Definition: Array2d.hpp:194
size_type rows() const
Returns the number of rows (first dimension size) in the Array2d.
Definition: Array2d.hpp:3139
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 Array2d...
slip::Array2d< double > Array2d_d
double alias
Definition: Array2d.hpp:2226
reverse_iterator rend()
Returns a read/write reverse iterator that points to one before the first element in the Array2d...
Definition: Array2d.hpp:2388
slip::Array2d< long > Array2d_l
long alias
Definition: Array2d.hpp:2230
iterator end()
Returns a read/write iterator that points one past the last element in the Array2d. Iteration is done in ordinary element order.
Definition: Array2d.hpp:2352
This is some iterator to iterate a 2d container into a slip::Box2d area defined by the indices of the...
Definition: Array2d.hpp:116
slip::stride_iterator< col_iterator > col_range_iterator
Definition: Array2d.hpp:223
std::reverse_iterator< col_range_iterator > reverse_col_range_iterator
Definition: Array2d.hpp:237
void swap(self &M)
Swaps data with another Array.
Definition: Array2d.hpp:3177
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 Array2d...
std::string name() const
Returns the name of the class.
Definition: Array2d.hpp:3128
std::reverse_iterator< iterator2d_range > reverse_iterator2d_range
Definition: Array2d.hpp:239
std::ostream & operator<<(std::ostream &out, const Array< T > &a)
Definition: Array.hpp:1282
iterator2d default_iterator
Definition: Array2d.hpp:243
std::reverse_iterator< const_iterator > const_reverse_row_iterator
Definition: Array2d.hpp:230
slip::Array2d< float > Array2d_f
float alias
Definition: Array2d.hpp:2228
std::reverse_iterator< const_col_range_iterator > const_reverse_col_range_iterator
Definition: Array2d.hpp:238
slip::iterator2d_range< self > iterator2d_range
Definition: Array2d.hpp:226
std::reverse_iterator< iterator > reverse_iterator
Definition: Array2d.hpp:209
size_type cols() const
Returns the number of columns (second dimension size) in the Array2d.
Definition: Array2d.hpp:3155
const_pointer const_row_iterator
Definition: Array2d.hpp:213
void fill(const T &value)
Fills the container range [begin(),begin()+size()) with copies of value.
Definition: Array2d.hpp:1923
bool empty() const
Returns true if the Array2d is empty. (Thus size() == 0)
Definition: Array2d.hpp:3173
This is some iterator to iterate a 2d container into two Range defined by the indices and strides of ...
Definition: Array2d.hpp:125
slip::stride_iterator< pointer > row_range_iterator
Definition: Array2d.hpp:221
Array2d()
Constructs a Array2d.
Definition: Array2d.hpp:2253
std::reverse_iterator< row_range_iterator > reverse_row_range_iterator
Definition: Array2d.hpp:235
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 Array2...
const_iterator2d const_default_iterator
Definition: Array2d.hpp:244
slip::stride_iterator< const_col_iterator > const_col_range_iterator
Definition: Array2d.hpp:224
slip::Array2d< char > Array2d_c
char alias
Definition: Array2d.hpp:2242
int stride() const
Accessor of the stride of the Range.
Definition: Range.hpp:298
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 Array2d...
slip::const_iterator2d_range< const_self > const_iterator2d_range
Definition: Array2d.hpp:227
Provides a class to modelize 2d points.
Provides a class to iterate a 1d range according to a step.
value_type & reference
Definition: Array2d.hpp:196
const_pointer const_iterator
Definition: Array2d.hpp:207
iterator begin()
Returns a read/write iterator that points to the first element in the Array2d. Iteration is done in o...
Definition: Array2d.hpp:2345
void fill(InputIterator first, InputIterator last)
Fills the container range [begin(),begin()+size()) with a copy of the range [first,last)
Definition: Array2d.hpp:1948
value_type const * const_pointer
Definition: Array2d.hpp:200
std::reverse_iterator< iterator2d > reverse_iterator2d
Definition: Array2d.hpp:233
bool operator==(const Array< T > &x, const Array< T > &y)
Definition: Array.hpp:1439
slip::Array2d< unsigned short > Array2d_us
unsigned long alias
Definition: Array2d.hpp:2236
static const std::size_t DIM
Definition: Array2d.hpp:246
slip::Array2d< unsigned char > Array2d_uc
unsigned char alias
Definition: Array2d.hpp:2244
std::reverse_iterator< iterator > reverse_row_iterator
Definition: Array2d.hpp:229
std::reverse_iterator< const_iterator2d_range > const_reverse_iterator2d_range
Definition: Array2d.hpp:240
std::reverse_iterator< const_row_range_iterator > const_reverse_row_range_iterator
Definition: Array2d.hpp:236
Provides a class to manipulate Ranges.
Provides a class to manipulate iterator2d within a slip::Range. It is used to iterate throw 2d contai...
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 Array2d...
This is a two-dimensional dynamic and generic container. This container statisfies the Bidirectionnal...
Definition: Array2d.hpp:135
SubType stop() const
Accessor of the stop subscript of the Range.
Definition: Range.hpp:291
bool operator>=(const Array< T > &x, const Array< T > &y)
Definition: Array.hpp:1485
self & operator=(const T &value)
Assign all the elments of the Array2d by value.
Definition: Array2d.hpp:1911
size_type dim1() const
Returns the number of rows (first dimension size) in the Array2d.
Definition: Array2d.hpp:3134
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 ...
slip::stride_iterator< pointer > col_iterator
Definition: Array2d.hpp:215