Commit 968f0bbd authored by mattijs's avatar mattijs
Browse files

added last() member function

parent 5bb620de
...@@ -184,6 +184,12 @@ public: ...@@ -184,6 +184,12 @@ public:
// an out-of-range element returns false without any ill-effects // an out-of-range element returns false without any ill-effects
inline const T& operator[](const label) const; inline const T& operator[](const label) const;
//- Return last element of UList.
inline T& last();
//- Return last element of UList.
inline const T& last() const;
//- Allow cast to a const List<T>& //- Allow cast to a const List<T>&
inline operator const Foam::List<T>&() const; inline operator const Foam::List<T>&() const;
......
...@@ -114,6 +114,20 @@ inline void Foam::UList<T>::checkIndex(const label i) const ...@@ -114,6 +114,20 @@ inline void Foam::UList<T>::checkIndex(const label i) const
} }
template<class T>
inline T& Foam::UList<T>::last()
{
return this->operator[](this->size()-1);
}
template<class T>
inline const T& Foam::UList<T>::last() const
{
return this->operator[](this->size()-1);
}
template<class T> template<class T>
inline const T* Foam::UList<T>::cdata() const inline const T* Foam::UList<T>::cdata() const
{ {
......
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