aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/STLUtil.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/STLUtil.hh')
-rw-r--r--src/FbTk/STLUtil.hh27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/FbTk/STLUtil.hh b/src/FbTk/STLUtil.hh
index e08036a..b1007f7 100644
--- a/src/FbTk/STLUtil.hh
+++ b/src/FbTk/STLUtil.hh
@@ -68,6 +68,33 @@ void destroyAndClearSecond(A &a) {
68 a.clear(); 68 a.clear();
69} 69}
70 70
71
72template <typename C, typename F>
73F forAll(C& c, F f) {
74 typedef typename C::iterator iterator;
75 iterator i = c.begin();
76 iterator e = c.end();
77 for (; i != e; i++) {
78 f(*i);
79 }
80 return f;
81}
82
83template <typename C, typename I, typename F>
84F forAllIf(C& c, I i, F f) {
85 typedef typename C::iterator iterator;
86 iterator it = c.begin();
87 iterator end = c.end();
88 for (; it != end; it++) {
89 if (i(*it))
90 f(*it);
91 }
92 return f;
93}
94
95
96
97
71} // end namespace STLUtil 98} // end namespace STLUtil
72} // end namespace FbTk 99} // end namespace FbTk
73 100