* mln/fun/internal/array_base.hh: add accessor to the underlying std
vector.
* mln/value/lut_vec.hh: Use directly fun::i2v::array and
fun::l2l::relabel as lut.
---
milena/ChangeLog | 10 +++++++
milena/mln/fun/internal/array_base.hh | 11 ++++++++
milena/mln/value/lut_vec.hh | 44 +++++++++++++++++++++++++++++++-
3 files changed, 63 insertions(+), 2 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 87e74e0..5d91084 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,13 @@
+2009-04-08 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Improve and fix lut_vec with fun::i2v::array and fun::l2l::relabel.
+
+ * mln/fun/internal/array_base.hh: add accessor to the underlying std
+ vector.
+
+ * mln/value/lut_vec.hh: Use directly fun::i2v::array and
+ fun::l2l::relabel as lut.
+
2009-04-08 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
Remove debug in io::tiff::load.
diff --git a/milena/mln/fun/internal/array_base.hh
b/milena/mln/fun/internal/array_base.hh
index d288c53..577b36f 100644
--- a/milena/mln/fun/internal/array_base.hh
+++ b/milena/mln/fun/internal/array_base.hh
@@ -80,6 +80,9 @@ namespace mln
/// Initialize an empty function.
void init_(unsigned n);
+ /// Return the underlying std::vector.
+ const std::vector<T>& std_vector() const;
+
protected:
std::vector<T> v_;
@@ -222,6 +225,14 @@ namespace mln
v_.resize(n);
}
+ template <typename T>
+ inline
+ const std::vector<T>&
+ array_base<T>::std_vector() const
+ {
+ return v_;
+ }
+
} // end of namespace mln::fun::internal
} // end of namespace mln::fun
diff --git a/milena/mln/value/lut_vec.hh b/milena/mln/value/lut_vec.hh
index 914eb78..6aa2e32 100644
--- a/milena/mln/value/lut_vec.hh
+++ b/milena/mln/value/lut_vec.hh
@@ -45,6 +45,16 @@
namespace mln
{
+ /// Forward declarations.
+ namespace fun {
+ namespace i2v {
+ template <typename T> class array;
+ } // end of namespace mln::fun::i2v
+ namespace l2l {
+ template <typename L> class relabel;
+ } // end of namespace mln::fun::l2l
+ } // end of namespace mln::fun
+
namespace value
{
@@ -53,8 +63,8 @@ namespace mln
template <typename S> struct bkd_viter_;
- /*! \brief Class that defines FIXME
- *
+ /// Class that defines FIXME
+ /*!
* \warning This is a multi-set!!!
* FIXME
*
@@ -90,6 +100,14 @@ namespace mln
template <typename F>
lut_vec(const S& vset, const Function_v2v<F>& f);
+ /// Ctor. FIXME!
+ template <typename V>
+ lut_vec(const S& vset, const Function_v2v< fun::i2v::array<V>
>& f);
+
+ /// Ctor. FIXME!
+ template <typename V>
+ lut_vec(const S& vset, const Function_v2v< fun::l2l::relabel<V>
>& f);
+
protected:
const S& vset_;
@@ -137,6 +155,28 @@ namespace mln
}
template <typename S, typename T>
+ template <typename V>
+ inline
+ lut_vec<S,T>::lut_vec(const S& vset, const Function_v2v<
fun::i2v::array<V> >& f)
+ : vset_(vset)
+ {
+ const fun::i2v::array<V>& f_ = exact(f);
+ n_ = f_.size();
+ vec_ = f_.std_vector();
+ }
+
+ template <typename S, typename T>
+ template <typename V>
+ inline
+ lut_vec<S,T>::lut_vec(const S& vset, const Function_v2v<
fun::l2l::relabel<V> >& f)
+ : vset_(vset)
+ {
+ const fun::l2l::relabel<V>& f_ = exact(f);
+ n_ = f_.size();
+ vec_ = f_.std_vector();
+ }
+
+ template <typename S, typename T>
inline
T
lut_vec<S,T>::operator()(const mln_value(S)& val) const
--
1.5.6.5