[Scummvm-cvs-logs] SF.net SVN: scummvm: [31323] scummvm/trunk/common/list.h
tramboi at users.sourceforge.net
tramboi at users.sourceforge.net
Sun Mar 30 08:37:46 CEST 2008
Revision: 31323
http://scummvm.svn.sourceforge.net/scummvm/?rev=31323&view=rev
Author: tramboi
Date: 2008-03-29 23:37:46 -0700 (Sat, 29 Mar 2008)
Log Message:
-----------
The "anchor" (root) of the linked list is now constructed inplace in the List instead of being newed (it has the same lifetime as the List itself anyway)
Modified Paths:
--------------
scummvm/trunk/common/list.h
Modified: scummvm/trunk/common/list.h
===================================================================
--- scummvm/trunk/common/list.h 2008-03-30 06:12:16 UTC (rev 31322)
+++ scummvm/trunk/common/list.h 2008-03-30 06:37:46 UTC (rev 31323)
@@ -111,7 +111,7 @@
}
};
- NodeBase *_anchor;
+ NodeBase _anchor;
public:
typedef Iterator<t_T> iterator;
@@ -121,21 +121,18 @@
public:
List() {
- _anchor = new NodeBase;
- _anchor->_prev = _anchor;
- _anchor->_next = _anchor;
+ _anchor._prev = &_anchor;
+ _anchor._next = &_anchor;
}
List(const List<t_T>& list) {
- _anchor = new NodeBase;
- _anchor->_prev = _anchor;
- _anchor->_next = _anchor;
+ _anchor._prev = &_anchor;
+ _anchor._next = &_anchor;
insert(begin(), list.begin(), list.end());
}
~List() {
clear();
- delete _anchor;
}
void push_front(const t_T& element) {
@@ -232,32 +229,32 @@
}
bool empty() const {
- return (_anchor == _anchor->_next);
+ return (&_anchor == _anchor._next);
}
iterator begin() {
- return iterator(_anchor->_next);
+ return iterator(_anchor._next);
}
iterator reverse_begin() {
- return iterator(_anchor->_prev);
+ return iterator(_anchor._prev);
}
iterator end() {
- return iterator(_anchor);
+ return iterator(&_anchor);
}
const_iterator begin() const {
- return const_iterator(_anchor->_next);
+ return const_iterator(_anchor._next);
}
const_iterator reverse_begin() const {
- return const_iterator(_anchor->_prev);
+ return const_iterator(_anchor._prev);
}
const_iterator end() const {
- return const_iterator(_anchor);
+ return const_iterator(const_cast<NodeBase*>(&_anchor));
}
};
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