Commit 9a494f38 authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

mln/util/array.hh: Add last() method.

parent 5717b0cf
2011-02-17 Guillaume Lazzara <z@lrde.epita.fr>
* mln/util/array.hh: Add last() method.
2011-02-17 Guillaume Lazzara <z@lrde.epita.fr>
 
Add an optional base index for debug::iota.
// 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
......@@ -551,6 +556,22 @@ namespace mln
return v_[i];
}
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment