aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2009-04-27 11:11:42 +0000
committerMax Horn2009-04-27 11:11:42 +0000
commit84f0e1d986c5b650f3d91e1ef1be4039694e64f6 (patch)
tree40faf58187b72a25d0a106f321e6404d469c290d
parented87cbab9080fa80beddc1edb3b45fdd43443216 (diff)
downloadscummvm-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.h16
-rw-r--r--common/queue.h8
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() {