--- a/sources/list.h Tue Dec 16 00:05:27 2014 +0200 +++ b/sources/list.h Tue Dec 16 00:15:44 2014 +0200 @@ -68,9 +68,11 @@ auto find (const T& needle) const -> ConstIterator; auto find (Function<bool (T const&)> func) -> Iterator; auto find (Function<bool (T const&)> func) const -> ConstIterator; + auto first() -> T&; auto first() const -> const T&; auto insert (int pos, const T& value) -> void; auto is_empty() const -> bool; + auto last() -> T&; auto last() const -> const T&; auto merge (const Self& other) -> void; auto pop (T& val) -> bool; @@ -484,6 +486,14 @@ // ------------------------------------------------------------------------------------------------- // template<typename T, typename C> +auto Container<T, C>::first() -> T& +{ + return *m_container.begin(); +} + +// ------------------------------------------------------------------------------------------------- +// +template<typename T, typename C> auto Container<T, C>::first() const -> const T& { return *m_container.cbegin(); @@ -492,6 +502,14 @@ // ------------------------------------------------------------------------------------------------- // template<typename T, typename C> +auto Container<T, C>::last() -> T& +{ + return *(m_container.end() - 1); +} + +// ------------------------------------------------------------------------------------------------- +// +template<typename T, typename C> auto Container<T, C>::last() const -> const T& { return *(m_container.cend() - 1);