[Olena] #175: Use std::vector to store data of mln::image[123]d<T>

#175: Use std::vector to store data of mln::image[123]d<T> ----------------------+----------------------------------------------------- Reporter: levill_r | Owner: Olena Team Type: proposal | Status: new Priority: minor | Milestone: Olena 1.0 Component: Milena | Version: 1.0 Keywords: | ----------------------+----------------------------------------------------- Currently, the following classes use plain dynamically-allocated memory to store their data (values): * source:trunk/milena/mln/core/image/image1d.hh * source:trunk/milena/mln/core/image/image2d.hh * source:trunk/milena/mln/core/image/image2d_h.hh * source:trunk/milena/mln/core/image/image3d.hh We could try to replace these arrays with `std::vectors`. Pros: * Automatic memory management. * Direct access (using pointers) is still possible, thanks to the ISO/IEC C++ Standard; see paragraph 23.2.4.1: "(...) The elements of a vector are stored contiguously, meaning that if `v` is a `vector<T, Allocator>` where `T` is some type other than `bool`, then it obeys the identity `&v[n] == &v[0] + n` for all `0 <= n < v.size()`". * Optimized storage for boolean values, thanks to the `std::vector<bool>` specialization. Cons: * We can't iterate on an `std::vector<bool>` using a pointer; but we can provide optimized specialization for that very case, that could as fast as pointer iterations (IMHO). -- Ticket URL: <https://trac.lrde.org/olena/ticket/175> Olena <http://olena.lrde.epita.fr> Olena, a generic and efficient C++ image processing library.

#175: Use std::vector to store data of mln::image[123]d<T> -----------------------+---------------------------------------------------- Reporter: levill_r | Owner: Olena Team Type: proposal | Status: new Priority: minor | Milestone: Olena 1.1 Component: Milena | Version: 1.0 Resolution: | Keywords: -----------------------+---------------------------------------------------- Changes (by levill_r): * milestone: Olena 1.0 => Olena 1.1 Comment: This is just a proposal, not required for the release of [milestone:"Olena 1.0" Olena 1.0]; postponing. -- Ticket URL: <https://trac.lrde.org/olena/ticket/175#comment:1> Olena <http://olena.lrde.epita.fr> Olena, a generic and efficient C++ image processing library.

#175: Use std::vector to store data of mln::image[123]d<T> -----------------------+---------------------------------------------------- Reporter: levill_r | Owner: Olena Team Type: proposal | Status: new Priority: minor | Milestone: Olena 1.1 Component: Milena | Version: 1.0 Resolution: | Keywords: -----------------------+---------------------------------------------------- Old description:
Currently, the following classes use plain dynamically-allocated memory to store their data (values):
* source:trunk/milena/mln/core/image/image1d.hh * source:trunk/milena/mln/core/image/image2d.hh * source:trunk/milena/mln/core/image/image2d_h.hh * source:trunk/milena/mln/core/image/image3d.hh
We could try to replace these arrays with `std::vectors`.
Pros: * Automatic memory management. * Direct access (using pointers) is still possible, thanks to the ISO/IEC C++ Standard; see paragraph 23.2.4.1:
"(...) The elements of a vector are stored contiguously, meaning that if `v` is a `vector<T, Allocator>` where `T` is some type other than `bool`, then it obeys the identity `&v[n] == &v[0] + n` for all `0 <= n < v.size()`".
* Optimized storage for boolean values, thanks to the `std::vector<bool>` specialization.
Cons: * We can't iterate on an `std::vector<bool>` using a pointer; but we can provide optimized specialization for that very case, that could as fast as pointer iterations (IMHO).
New description: Currently, the following classes use plain dynamically-allocated memory to store their data (values): * source:trunk/milena/mln/core/image/image1d.hh * source:trunk/milena/mln/core/image/image2d.hh * source:trunk/milena/mln/core/image/image2d_h.hh * source:trunk/milena/mln/core/image/image3d.hh We could try to replace these arrays with `std::vectors`. Pros: * Automatic memory management. * Direct access (using pointers) is still possible, thanks to the ISO/IEC C++ Standard; see paragraph 23.2.4.1: "(...) The elements of a vector are stored contiguously, meaning that if `v` is a `vector<T, Allocator>` where `T` is some type other than `bool`, then it obeys the identity `&v[n] == &v[0] + n` for all `0 <= n < v.size()`". * Optimized storage for boolean values, thanks to the `std::vector<bool>` specialization. * Room for runtime optimization (e.g. `fill`), since data are about an eighth of the original size. Cons: * We can't iterate on an `std::vector<bool>` using a pointer; but we can provide optimized specialization for that very case, that could as fast as pointer iterations (IMHO). -- Comment(by levill_r): More pros. -- Ticket URL: <https://trac.lrde.org/olena/ticket/175#comment:2> Olena <http://olena.lrde.epita.fr> Olena, a generic and efficient C++ image processing library.
participants (2)
-
Olena
-
Olena Trac