aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/STLUtil.hh
diff options
context:
space:
mode:
authorMark Tiefenbruck <mark@fluxbox.org>2007-12-28 06:22:38 (GMT)
committerMark Tiefenbruck <mark@fluxbox.org>2007-12-28 06:22:38 (GMT)
commit0ec165e85b313588d43dbdc2450da9838c4c528f (patch)
treeaee798a6f8f108908e3e6932bef11b8eb564aa2a /src/FbTk/STLUtil.hh
parent32eb2a148ea7a257a058658af36e9f8c801a524a (diff)
downloadfluxbox-0ec165e85b313588d43dbdc2450da9838c4c528f.zip
fluxbox-0ec165e85b313588d43dbdc2450da9838c4c528f.tar.bz2
move STLUtil to FbTk
Diffstat (limited to 'src/FbTk/STLUtil.hh')
-rw-r--r--src/FbTk/STLUtil.hh55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/FbTk/STLUtil.hh b/src/FbTk/STLUtil.hh
new file mode 100644
index 0000000..ec783d9
--- /dev/null
+++ b/src/FbTk/STLUtil.hh
@@ -0,0 +1,55 @@
1// STLUtil.cc for FbTk
2// Copyright (c) 2006 Fluxbox Team (fluxgen at fluxbox dot org)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22#ifndef FBTK_STLUTIL_HH
23#define FBTK_STLUTIL_HH
24
25/// contains useful utilities for STL
26namespace FbTk {
27namespace STLUtil {
28
29/// calls delete on each item in the container and then clears the container
30template <typename A>
31void destroyAndClear(A &a) {
32 typedef typename A::iterator iterator;
33 iterator it = a.begin();
34 iterator it_end = a.end();
35 for (; it != it_end; ++it)
36 delete (*it);
37
38 a.clear();
39}
40
41/// calls delete on each item value in the map and then clears the map
42template <typename A>
43void destroyAndClearSecond(A &a) {
44 typedef typename A::iterator iterator;
45 iterator it = a.begin();
46 iterator it_end = a.end();
47 for (; it != it_end; ++it)
48 delete it->second;
49 a.clear();
50}
51
52}; // end namespace STLUtil
53}; // end namespace FbTk
54
55#endif // STLUTIL_Hh