aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Menshakov2009-12-27 14:13:39 +0000
committerVladimir Menshakov2009-12-27 14:13:39 +0000
commit3936861b7c40912123c687ed5999639cb6f00787 (patch)
tree384b911f732b50326547659b45acd32e9b58fc82
parent9f37be314d29189a7709e400b2ded6afd0d1e3fa (diff)
downloadscummvm-rg350-3936861b7c40912123c687ed5999639cb6f00787.tar.gz
scummvm-rg350-3936861b7c40912123c687ed5999639cb6f00787.tar.bz2
scummvm-rg350-3936861b7c40912123c687ed5999639cb6f00787.zip
allowed list to be sorted with default comparator
svn-id: r46644
-rw-r--r--common/algorithm.h6
-rw-r--r--common/list_intern.h1
-rw-r--r--test/common/algorithm.h2
3 files changed, 6 insertions, 3 deletions
diff --git a/common/algorithm.h b/common/algorithm.h
index d730a3ada2..4a2acef7a5 100644
--- a/common/algorithm.h
+++ b/common/algorithm.h
@@ -216,8 +216,10 @@ void sort(T *first, T *last) {
sort(first, last, Common::Less<T>());
}
-///\todo add value_type to all iterators and add default sort variant with Common::Less<T::value_type>()
-
+template<class T>
+void sort(T first, T last) {
+ sort(first, last, Common::Less<typename T::ValueType>());
+}
} // End of namespace Common
#endif
diff --git a/common/list_intern.h b/common/list_intern.h
index 11d03fd6ff..b7fbaffc47 100644
--- a/common/list_intern.h
+++ b/common/list_intern.h
@@ -53,6 +53,7 @@ namespace ListInternal {
typedef Node<T> * NodePtr;
typedef T & ValueRef;
typedef T * ValuePtr;
+ typedef T ValueType;
NodeBase *_node;
diff --git a/test/common/algorithm.h b/test/common/algorithm.h
index bb2932178d..ed87d6850d 100644
--- a/test/common/algorithm.h
+++ b/test/common/algorithm.h
@@ -76,7 +76,7 @@ public:
TS_ASSERT_EQUALS(checkSort(list.begin(), list.end(), Common::Less<Item>()), true);
// already sorted
- Common::sort(list.begin(), list.end(), Common::Less<Item>());
+ Common::sort(list.begin(), list.end());
TS_ASSERT_EQUALS(checkSort(list.begin(), list.end(), Common::Less<Item>()), true);
}
};