[Scummvm-cvs-logs] CVS: scummvm/saga list.h,1.2,1.3
Andrew Kurushin
h00ligan at users.sourceforge.net
Thu Dec 16 12:50:15 CET 2004
Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3650
Modified Files:
list.h
Log Message:
reorderUp and reorderDown should return new item position
Index: list.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/list.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- list.h 15 Dec 2004 20:22:52 -0000 1.2
+++ list.h 16 Dec 2004 20:49:17 -0000 1.3
@@ -19,23 +19,23 @@
*
*/
-#ifndef SAGA_LIST_H__
-#define SAGA_LIST_H__
-
+#ifndef SAGA_LIST_H__
+#define SAGA_LIST_H__
+
#include "common/list.h"
-
-namespace Saga {
+
+namespace Saga {
template <class T>
class SortedList : public Common::List<T> {
-public:
- typedef int ( CompareFunction ) (const T& , const T&);
-
+public:
+ typedef int ( CompareFunction ) (const T& , const T&);
+
typedef typename Common::List<T>::iterator iterator;
typedef typename Common::List<T>::const_iterator const_iterator;
-
-public:
+
+public:
iterator pushFront(const T& element) {
return insert(Common::List<T>::begin(), element);
@@ -76,48 +76,48 @@
for (iterator i = Common::List<T>::begin(); i != Common::List<T>::end(); ++i) {
res = compareFunction(element, i.operator*());
- if (res < 0) {
- return insert(i, element);
+ if (res < 0) {
+ return insert(i, element);
}
}
return pushBack(element);
}
- void reorderUp(iterator pos, CompareFunction* compareFunction) {
+ iterator reorderUp(iterator pos, CompareFunction* compareFunction) {
iterator i(pos);
int res;
--i;
while (i != Common::List<T>::end()) {
res = compareFunction(i.operator*(), pos.operator*());
- if (res <= 0) {
-
- T temp(*pos);
- erase(pos);
- ++i;
- Common::List<T>::insert(i, temp);
- return;
+ if (res <= 0) {
+
+ T temp(*pos);
+ erase(pos);
+ ++i;
+ return insert(i, temp);
}
--i;
}
+ return pos;
}
- void reorderDown(iterator pos, CompareFunction* compareFunction) {
+ iterator reorderDown(iterator pos, CompareFunction* compareFunction) {
iterator i(pos);
int res;
++i;
while (i != Common::List<T>::end()) {
res = compareFunction(i.operator*(), pos.operator*());
- if (res >= 0) {
-
- T temp(*pos);
- erase(pos);
- Common::List<T>::insert(i, temp);
- return;
+ if (res >= 0) {
+
+ T temp(*pos);
+ erase(pos);
+ return insert(i, temp);
}
++i;
}
+ return pos;
}
iterator eraseAndPrev(iterator pos) {
@@ -148,7 +148,7 @@
return false;
}
-};
-
-} // End of namespace Saga
-#endif
+};
+
+} // End of namespace Saga
+#endif
\ No newline at end of file
More information about the Scummvm-git-logs
mailing list