Nicolas Ballas <ballas(a)lrde.epita.fr> writes:
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Fix bug on sparse image.
* oln/core/encode/sparse_encode.hh: New.
* oln/core/sparse/sparse_image.hh: sparse_image class working
now
ChangeLogs descriptions should use an imperative form (see what the
guidelines say at
https://www.lrde.epita.fr/dload/guide/guide.html#htoc59). For
instance,
* oln/core/sparse/sparse_image.hh (sparse_image): Fix this class.
is preferred.
Index: oln/core/encode/sparse_encode.hh
--- oln/core/encode/sparse_encode.hh (revision 0)
+++ oln/core/encode/sparse_encode.hh (revision 0)
@@ -0,0 +1,58 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 EPITA
+// Research and Development Laboratory
This file is new, so it should not mention years other than 2007.
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef SPARSE_ENCODE_HH_
+# define SPARSE_ENCODE_HH_
Guards should be named without a trailing underscore, and prefixed by
the directories containing the files. In this case, it would have
been:
#ifndef OLN_CORE_ENCODE_SPARSE_ENCODE_HH
# define OLN_CORE_ENCODE_SPARSE_ENCODE_HH
(See also my comments on Ugo's patches.)
+
+# include <oln/core/concept/image.hh>
+
+# include <oln/core/sparse/sparse_image.hh>
+
+namespace oln
+{
+
+ /*!
+ ** encode a generic image to a sparse image format
+ **
+ ** @param input an Image
+ **
+ ** @return a sparse image
+ */
+ template <typename I>
+ sparse_image<typename I::point, typename I::value>
+ sparse_encode(const Image<I> input)
+ {
+ sparse_image<typename I::point, typename I::value> output;
+ typename I::piter p (input.points());
+ // typename I::coord len = 1;
+ typename I::point rstart; /*!< range pointstart */
+ typename I::value rvalue; /*!< range value */
When it is possible, try to stay under the 80 columns. It eases the
reading and allows one to print the code with no pain.
Also, we don't follow the EPITA coding style standard at LRDE, so you
should not align variables or argument vertically, unless there's a
good reason for this.
+ }
+}
+
+#endif /* !SPARSE_ENCODE_HH_ */
Prefer this:
#endif // ! OLN_CORE_ENCODE_SPARSE_ENCODE_HH
Index: oln/core/sparse/sparse_image.hh
--- oln/core/sparse/sparse_image.hh (revision 878)
+++ oln/core/sparse/sparse_image.hh (working copy)
@@ -133,9 +133,9 @@
typename sparse_image<P, T>::rvalue
sparse_image<P, T>::impl_read(const sparse_image<P, T>::psite& ps)
const
{
- typename std::map<point, value>::const_iterator irun;
+ typename std::map<point, std::vector<value> >::const_iterator irun;
- irun = this->data_->second.find(ps.start_);
+ irun.operator= (this->data_->second.find(ps.start_));
assert(irun != this->data_->second.end() && ps.index_ <
this->data_->first.range_len_(ps.start_));
return irun->second[ps.index_];
}
@@ -144,9 +144,9 @@
typename sparse_image<P, T>::lvalue
sparse_image<P, T>::impl_read_write(const sparse_image<P, T>::psite&
ps)
{
- typename std::map<point, value>::const_iterator irun;
+ typename std::map<point, std::vector<value> >::iterator irun;
- irun = this->data_->second.find(ps.start_);
+ irun.operator= (this->data_->second.find(ps.start_));
assert(irun != this->data_->second.end() && ps.index_ <
this->data_->first.range_len_(ps.start_));
return irun->second[ps.index_];
}
Good!
Don't forget to take the comments into account. Thanks in advance!