SST/macro
delete.h
Go to the documentation of this file.
1 #ifndef sprockit_common_DELETE_H
2 #define sprockit_common_DELETE_H
3 
4 namespace sprockit {
5 
6 template <class Container>
7 void
8 delete_all(const Container& ctr){
9  typedef typename Container::value_type T;
10  typename Container::const_iterator it, end = ctr.end();
11  for (it=ctr.begin(); it != end; ++it){
12  delete *it;
13  }
14 }
15 
16 template <class Container>
17 void
18 delete_arrs(const Container& ctr){
19  typedef typename Container::value_type T;
20  typename Container::const_iterator it, end = ctr.end();
21  for (it=ctr.begin(); it != end; ++it){
22  delete[] *it;
23  }
24 }
25 
26 template <class MapType>
27 void
28 delete_vals_arrs(const MapType& ctr){
29  typedef typename MapType::key_type T;
30  typedef typename MapType::mapped_type Val;
31  typename MapType::const_iterator it, end = ctr.end();
32  for (it=ctr.begin(); it != end; ++it){
33  delete[] it->second;
34  }
35 }
36 
37 template <class MapType>
38 void
39 delete_vals(const MapType& ctr){
40  typedef typename MapType::key_type T;
41  typedef typename MapType::mapped_type Val;
42  typename MapType::const_iterator it, end = ctr.end();
43  for (it=ctr.begin(); it != end; ++it){
44  delete it->second;
45  }
46 }
47 
48 template <class MapType>
49 void
50 delete_keys(const MapType& ctr){
51  typedef typename MapType::key_type T;
52  typedef typename MapType::mapped_type Val;
53  typename MapType::const_iterator it, end = ctr.end();
54  for (it=ctr.begin(); it != end; ++it){
55  delete it->first;
56  }
57 }
58 
59 template <class MapType>
60 void
61 delete_keys_and_vals(const MapType& ctr){
62  typedef typename MapType::key_type T;
63  typedef typename MapType::mapped_type Val;
64  typename MapType::const_iterator it, end = ctr.end();
65  for (it=ctr.begin(); it != end; ++it){
66  delete it->first;
67  delete it->second;
68  }
69 }
70 
71 }
72 
73 #endif // DELETE_H
void delete_keys_and_vals(const MapType &ctr)
Definition: delete.h:61
void delete_vals(const MapType &ctr)
Definition: delete.h:39
void delete_keys(const MapType &ctr)
Definition: delete.h:50
void delete_vals_arrs(const MapType &ctr)
Definition: delete.h:28
void delete_arrs(const Container &ctr)
Definition: delete.h:18
void delete_all(const Container &ctr)
Definition: delete.h:8