URL:
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
ChangeLog:
2008-09-12 Guillaume Lazzara <z(a)lrde.epita.fr>
Add at() and remove operator[] from image1d.
* milena/mln/core/image/image1d.hh: add at() and remove operator[].
---
image1d.hh | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
Index: branches/cleanup-2008/milena/mln/core/image/image1d.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/image/image1d.hh (revision 2227)
+++ branches/cleanup-2008/milena/mln/core/image/image1d.hh (revision 2228)
@@ -175,11 +175,15 @@
/// Read-write access to the image value located at point \p p.
T& operator()(const point1d& p);
- /// Read-only access to the image value located at offset \p o.
- const T& operator[](unsigned i) const;
- /// Read-write access to the image value located at offset \p o.
- T& operator[](unsigned i);
+ // Specific methods:
+ // -----------------
+
+ /// Read-only access to the image value located at (\p index).
+ const T& at(int index) const;
+
+ /// Read-write access to the image value located at (\p index).
+ T& at(int index);
/// Fast Image method
@@ -419,21 +423,22 @@
template <typename T>
inline
const T&
- image1d<T>::operator[](unsigned o) const
+ image1d<T>::at(int index) const
{
- mln_precondition(o < nelements());
- return *(this->data_->buffer_ + o);
+ mln_precondition(this->has(make::point1d(index)));
+ return this->data_->array_[index];
}
template <typename T>
inline
T&
- image1d<T>::operator[](unsigned o)
+ image1d<T>::at(int index)
{
- mln_precondition(o < nelements());
- return *(this->data_->buffer_ + o);
+ mln_precondition(this->has(make::point1d(index)));
+ return this->data_->array_[index];
}
+
template <typename T>
inline
const T&