diff options
author | phintuka <phintuka> | 2010-02-03 13:58:05 +0000 |
---|---|---|
committer | phintuka <phintuka> | 2010-02-03 13:58:05 +0000 |
commit | 3bd0ab8f7516cf9e1c37481f1904f0d1e4b684dc (patch) | |
tree | c28e1304ca85fe406ff7c83350089be3e7942d05 | |
parent | bb14f94a312d0e6814cfc7cd74ce8f57e2e60431 (diff) | |
download | xineliboutput-3bd0ab8f7516cf9e1c37481f1904f0d1e4b684dc.tar.gz xineliboutput-3bd0ab8f7516cf9e1c37481f1904f0d1e4b684dc.tar.bz2 |
Added template for functions with four arguments
-rw-r--r-- | tools/listiter.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tools/listiter.h b/tools/listiter.h index 9c88940e..e16353cb 100644 --- a/tools/listiter.h +++ b/tools/listiter.h @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: listiter.h,v 1.1 2006-06-03 10:04:27 phintuka Exp $ + * $Id: listiter.h,v 1.2 2010-02-03 13:58:05 phintuka Exp $ * */ @@ -68,6 +68,18 @@ RESULT ForEach(LIST& List, RESULT (ITEM::*f)(ARG1,ARG2,ARG3), return result; } +template <class LIST, class ITEM, class ARG1, class ARG2, class ARG3, class ARG4, + class RESULT> + RESULT ForEach(LIST& List, RESULT (ITEM::*f)(ARG1,ARG2,ARG3,ARG4), + ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, + RESULT (*combiner)(RESULT,RESULT), RESULT def) +{ + RESULT result = def; + for(ITEM *it = List.First(); it; it = List.Next(it)) + result = (*combiner)((*it.*f)(arg1,arg2,arg3,arg4),result); + return result; +} + template<class T> T mmin(T a, T b) {return a<b ? a : b;} |