diff options
author | Max Horn | 2009-04-27 11:11:42 +0000 |
---|---|---|
committer | Max Horn | 2009-04-27 11:11:42 +0000 |
commit | 84f0e1d986c5b650f3d91e1ef1be4039694e64f6 (patch) | |
tree | 40faf58187b72a25d0a106f321e6404d469c290d | |
parent | ed87cbab9080fa80beddc1edb3b45fdd43443216 (diff) | |
download | scummvm-rg350-84f0e1d986c5b650f3d91e1ef1be4039694e64f6.tar.gz scummvm-rg350-84f0e1d986c5b650f3d91e1ef1be4039694e64f6.tar.bz2 scummvm-rg350-84f0e1d986c5b650f3d91e1ef1be4039694e64f6.zip |
COMMON: Added Common::List::front() and back() method (similar to std::list)
svn-id: r40154
-rw-r--r-- | common/list.h | 16 | ||||
-rw-r--r-- | common/queue.h | 8 |
2 files changed, 20 insertions, 4 deletions
diff --git a/common/list.h b/common/list.h index b2ad3fbc18..1685843e8e 100644 --- a/common/list.h +++ b/common/list.h @@ -132,6 +132,22 @@ public: i = erase(i); } + t_T &front() { + return static_cast<Node *>(_anchor._next)->_data; + } + + const t_T &front() const { + return static_cast<Node *>(_anchor._next)->_data; + } + + t_T &back() { + return static_cast<Node *>(_anchor._prev)->_data; + } + + const t_T &back() const { + return static_cast<Node *>(_anchor._prev)->_data; + } + List<t_T> &operator=(const List<t_T> &list) { if (this != &list) { diff --git a/common/queue.h b/common/queue.h index cfe7f4e596..df8dcfe04c 100644 --- a/common/queue.h +++ b/common/queue.h @@ -55,19 +55,19 @@ public: } T &front() { - return *_impl.begin(); + return _impl.front(); } const T &front() const { - return *_impl.begin(); + return _impl.front(); } T &back() { - return *_impl.reverse_begin(); + return _impl.back(); } const T &back() const { - return *_impl.reverse_begin(); + return _impl.back(); } T pop() { |