diff -r 874bbfa55da8 -r 481073b016a9 sources/list.h --- 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 func) -> Iterator; auto find (Function 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 +auto Container::first() -> T& +{ + return *m_container.begin(); +} + +// ------------------------------------------------------------------------------------------------- +// +template auto Container::first() const -> const T& { return *m_container.cbegin(); @@ -492,6 +502,14 @@ // ------------------------------------------------------------------------------------------------- // template +auto Container::last() -> T& +{ + return *(m_container.end() - 1); +} + +// ------------------------------------------------------------------------------------------------- +// +template auto Container::last() const -> const T& { return *(m_container.cend() - 1);