aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorJohannes Schickel2007-09-24 00:07:28 +0000
committerJohannes Schickel2007-09-24 00:07:28 +0000
commit89edc3c7ebb44f0c46b336e8db21840d1514b61a (patch)
tree9bd3f192f6c4a27bca5f3a9473117c4c48a104de /common
parent6ee45acf9e529efe9eb51e327d4c212d0ffc9293 (diff)
downloadscummvm-rg350-89edc3c7ebb44f0c46b336e8db21840d1514b61a.tar.gz
scummvm-rg350-89edc3c7ebb44f0c46b336e8db21840d1514b61a.tar.bz2
scummvm-rg350-89edc3c7ebb44f0c46b336e8db21840d1514b61a.zip
Adds Common::set_to which sets elements from the range [first, last) to value.
svn-id: r29080
Diffstat (limited to 'common')
-rw-r--r--common/algorithm.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/common/algorithm.h b/common/algorithm.h
index 19fb397fd8..fccc815b36 100644
--- a/common/algorithm.h
+++ b/common/algorithm.h
@@ -53,6 +53,15 @@ Out copy_if(In first, In last, Out dst, Op op) {
return dst;
}
+// TODO: this is can be slower than memset for most normal data
+// maybe specialize the template for char, short, int, long, long long
+template<class In, class Value>
+In set_to(In first, In last, Value val) {
+ while (first != last)
+ *first++ = val;
+ return first;
+}
+
template<class In, class T>
In find(In first, In last, const T &v) {
while (first != last) {