* mln/convert/from_to.hxx: Add a new overload.
* mln/fun/i2v/array.hh: Fix buggy from_to overloads.
* mln/util/array.hh: Fix buggy from_to overloads and add a new
one.
---
milena/ChangeLog | 11 +++++++++++
milena/mln/convert/from_to.hxx | 4 ++++
milena/mln/fun/i2v/array.hh | 8 ++++----
milena/mln/util/array.hh | 19 +++++++++++++++++--
4 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 31f5d3d..bf1e791 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,16 @@
2009-08-21 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Fix buggy from_to overloads and add a missing one.
+
+ * mln/convert/from_to.hxx: Add a new overload.
+
+ * mln/fun/i2v/array.hh: Fix buggy from_to overloads.
+
+ * mln/util/array.hh: Fix buggy from_to overloads and add a new
+ one.
+
+2009-08-21 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Add blobs_and_compute.
* mln/canvas/labeling/blobs.hh: New. Make labeling blobs a canvas.
diff --git a/milena/mln/convert/from_to.hxx b/milena/mln/convert/from_to.hxx
index 6a10923..ebc30cd 100644
--- a/milena/mln/convert/from_to.hxx
+++ b/milena/mln/convert/from_to.hxx
@@ -376,6 +376,10 @@ namespace mln
void
from_to_(const util::array<T1>& from, util::array<T2>& to);
+ // fun::i2v::array<T1> -> util::array<T2>
+ template <typename T1, typename T2>
+ void
+ from_to_(const fun::i2v::array<T1>& from, util::array<T2>&
to);
// Accumulator<A> -> mln_result(A)
diff --git a/milena/mln/fun/i2v/array.hh b/milena/mln/fun/i2v/array.hh
index f60629d..ed4a379 100644
--- a/milena/mln/fun/i2v/array.hh
+++ b/milena/mln/fun/i2v/array.hh
@@ -191,9 +191,9 @@ namespace mln
void
from_to_(const util::array<T>& from, fun::i2v::array<U>& to)
{
- to.reserve(from.nelements());
+ to.resize(from.nelements());
for (unsigned i = 0; i < from.nelements(); ++i)
- to.append(convert::to<U>(from[i]));
+ to(i) = convert::to<U>(from[i]);
}
template <typename T>
@@ -209,9 +209,9 @@ namespace mln
void
from_to_(const std::vector<T>& from, fun::i2v::array<U>& to)
{
- to.reserve(from.nelements());
+ to.resize(from.nelements());
for (unsigned i = 0; i < from.size(); ++i)
- to.append(convert::to<U>(from[i]));
+ to(i) = convert::to<U>(from[i]);
}
diff --git a/milena/mln/util/array.hh b/milena/mln/util/array.hh
index b9f4798..b64511e 100644
--- a/milena/mln/util/array.hh
+++ b/milena/mln/util/array.hh
@@ -68,6 +68,10 @@ namespace mln
void
from_to_(const util::array<T1>& from, util::array<T2>& to);
+ template <typename T1, typename T2>
+ void
+ from_to_(const fun::i2v::array<T1>& from, util::array<T2>&
to);
+
} // end of namespace mln::convert::over_load
} // end of namespace mln::convert
@@ -385,12 +389,23 @@ namespace mln
void
from_to_(const util::array<T1>& from, util::array<T2>& to)
{
- to.reserve(from.nelements());
+ to.resize(from.nelements());
for (unsigned i = 0; i < from.nelements(); ++i)
- to.append(convert::to<T2>(from[i]));
+ to[i] = convert::to<T2>(from[i]);
+ }
+
+ template <typename T1, typename T2>
+ void
+ from_to_(const fun::i2v::array<T1>& from, util::array<T2>& to)
+ {
+ to.resize(from.size());
+
+ for (unsigned i = 0; i < from.size(); ++i)
+ to[i] = convert::to<T2>(from(i));
}
+
} // end of namespace mln::convert::over_load
} // end of namespace mln::convert
--
1.5.6.5