Commit b5988db6 authored by Davis King's avatar Davis King

Added .begin() and .end() to array2d.

parent 30101dff
...@@ -60,6 +60,9 @@ namespace dlib ...@@ -60,6 +60,9 @@ namespace dlib
typedef T type; typedef T type;
typedef mem_manager mem_manager_type; typedef mem_manager mem_manager_type;
typedef T* iterator;
typedef const T* const_iterator;
// ----------------------------------- // -----------------------------------
...@@ -321,6 +324,27 @@ namespace dlib ...@@ -321,6 +324,27 @@ namespace dlib
return nc_*sizeof(T); return nc_*sizeof(T);
} }
iterator begin()
{
return data;
}
iterator end()
{
return data+size();
}
const_iterator begin() const
{
return data;
}
const_iterator end() const
{
return data+size();
}
private: private:
......
...@@ -64,6 +64,8 @@ namespace dlib ...@@ -64,6 +64,8 @@ namespace dlib
typedef T type; typedef T type;
typedef mem_manager mem_manager_type; typedef mem_manager mem_manager_type;
typedef T* iterator;
typedef const T* const_iterator;
// ---------------------------------------- // ----------------------------------------
...@@ -255,6 +257,42 @@ namespace dlib ...@@ -255,6 +257,42 @@ namespace dlib
An example of such an object is the dlib::cv_image. An example of such an object is the dlib::cv_image.
!*/ !*/
iterator begin(
);
/*!
ensures
- returns a random access iterator pointing to the first element in this
object.
- The iterator will iterate over the elements of the object in row major
order.
!*/
iterator end(
);
/*!
ensures
- returns a random access iterator pointing to one past the end of the last
element in this object.
!*/
const_iterator begin(
) const;
/*!
ensures
- returns a random access iterator pointing to the first element in this
object.
- The iterator will iterate over the elements of the object in row major
order.
!*/
const_iterator end(
) const;
/*!
ensures
- returns a random access iterator pointing to one past the end of the last
element in this object.
!*/
}; };
template < template <
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment