aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/STLUtil.hh
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2010-09-15 00:07:09 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2010-09-15 00:07:09 (GMT)
commit12e1ef78265a621dc51f7b9af245d81431835dcc (patch)
treeb1e7c9ec99f24c89989a34cb994119319184abb7 /src/FbTk/STLUtil.hh
parentba316aa18a8813958cedea1cc4d54452e40c4b59 (diff)
downloadfluxbox-12e1ef78265a621dc51f7b9af245d81431835dcc.zip
fluxbox-12e1ef78265a621dc51f7b9af245d81431835dcc.tar.bz2
code deduplication by using <algorithm> and FbTk/STLUtil.hh
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