[Scummvm-cvs-logs] SF.net SVN: scummvm:[40154] scummvm/trunk/common

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Apr 27 13:11:43 CEST 2009


Revision: 40154
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40154&view=rev
Author:   fingolfin
Date:     2009-04-27 11:11:42 +0000 (Mon, 27 Apr 2009)

Log Message:
-----------
COMMON: Added Common::List::front() and back() method (similar to std::list)

Modified Paths:
--------------
    scummvm/trunk/common/list.h
    scummvm/trunk/common/queue.h

Modified: scummvm/trunk/common/list.h
===================================================================
--- scummvm/trunk/common/list.h	2009-04-26 19:40:50 UTC (rev 40153)
+++ scummvm/trunk/common/list.h	2009-04-27 11:11:42 UTC (rev 40154)
@@ -132,7 +132,23 @@
 		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) {
 			iterator i;

Modified: scummvm/trunk/common/queue.h
===================================================================
--- scummvm/trunk/common/queue.h	2009-04-26 19:40:50 UTC (rev 40153)
+++ scummvm/trunk/common/queue.h	2009-04-27 11:11:42 UTC (rev 40154)
@@ -55,19 +55,19 @@
 	}
 
 	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() {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list