Hot Door CORE  0.7.0
Adobe® Illustrator® Plug-in Library
hdicoreMemory.h
1 #ifndef __HDI_CORE_MEMORY__
2 #define __HDI_CORE_MEMORY__
3 
4 #include <list>
5 #include <map>
6 #include <set>
7 #include <vector>
8 
9 namespace hdi
10 {
11  namespace core
12  {
20  template <typename Contained>
21  void cleanupList(std::list< Contained* >& l_)
22  {
23  for(typename std::list< Contained* >::iterator iter = l_.begin(); iter != l_.end(); ++iter)
24  {
25  delete (*iter);
26  (*iter) = NULL;
27  }
28 
29  l_.clear();
30  }
31 
39  template <typename Contained>
40  void cleanupSet(std::set< Contained* >& s_)
41  {
42  for(typename std::set< Contained* >::iterator iter = s_.begin(); iter != s_.end(); ++iter)
43  {
44  delete (*iter);
45  (*iter) = NULL;
46  }
47 
48  s_.clear();
49  }
50 
58  template <typename Contained>
59  void cleanupVector(std::vector< Contained* >& v_)
60  {
61  for(typename std::vector< Contained* >::iterator iter = v_.begin(); iter != v_.end(); ++iter)
62  {
63  delete (*iter);
64  (*iter) = NULL;
65  }
66 
67  v_.clear();
68  }
69 
77  template <typename Contained1, typename Contained2>
78  void cleanupMap(std::map< Contained1, Contained2* >& m_)
79  {
80  for(typename std::map< Contained1, Contained2* >::iterator iter = m_.begin(); iter != m_.end(); ++iter)
81  {
82  delete iter->second;
83  iter->second = NULL;
84  }
85 
86  m_.clear();
87  }
88 
96  template <typename Contained1, typename Contained2>
97  void cleanupMap(std::map< Contained1*, Contained2 >& m_)
98  {
99  for(typename std::map< Contained1*, Contained2 >::iterator iter = m_.begin(); iter != m_.end(); ++iter)
100  {
101  delete iter->first;
102  // iter->first = NULL;
103  }
104 
105  m_.clear();
106  }
107 
115  template <typename Contained1, typename Contained2>
116  void cleanupMap(std::map< Contained1*, Contained2* >& m_)
117  {
118  for(typename std::map< Contained1*, Contained2* >::iterator iter = m_.begin(); iter != m_.end(); ++iter)
119  {
120  delete iter->first;
121  // iter->first = NULL;
122 
123  delete iter->second;
124  iter->second = NULL;
125  }
126 
127  m_.clear();
128  }
129  }
130 }
131 
132 #endif
133 // __HDI_CORE_MEMORY__
Definition: hdicoreaiArray.h:12