---
milena/ChangeLog | 4 ++++
milena/mln/util/array.hh | 25 +++++++++++++++++++++++--
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index e03d35c..c4bed2c 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,9 @@
2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr>
+ * mln/util/array.hh: Add last() method.
+
+2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add an optional base index for debug::iota.
* mln/debug/iota.hh,
diff --git a/milena/mln/util/array.hh b/milena/mln/util/array.hh
index 0fe34e7..c7febfe 100644
--- a/milena/mln/util/array.hh
+++ b/milena/mln/util/array.hh
@@ -1,5 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2008, 2009, 2011 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -187,6 +187,11 @@ namespace mln
/// \pre i < nelements()
mutable_result operator[](unsigned i);
+ /// \brief Return the last element.
+ ro_result last() const;
+
+ /// \brief Return the last element.
+ mutable_result last();
/// Empty the array. All elements contained in the array are
/// destroyed. \post is_empty() == true
@@ -553,6 +558,22 @@ namespace mln
template <typename T>
inline
+ typename array<T>::ro_result
+ array<T>::last() const
+ {
+ return v_[nelements() - 1];
+ }
+
+ template <typename T>
+ inline
+ typename array<T>::mutable_result
+ array<T>::last()
+ {
+ return v_[nelements() - 1];
+ }
+
+ template <typename T>
+ inline
bool
array<T>::is_empty() const
{
--
1.5.6.5