added last() member function

This commit is contained in:
mattijs
2009-11-23 12:55:20 +00:00
parent 5bb620de10
commit 968f0bbd57
2 changed files with 20 additions and 0 deletions

View File

@ -184,6 +184,12 @@ public:
// an out-of-range element returns false without any ill-effects
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>&
inline operator const Foam::List<T>&() const;

View File

@ -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>
inline const T* Foam::UList<T>::cdata() const
{