28 #ifndef __TERRALIB_COMMON_INTERNAL_STLUTILS_H 29 #define __TERRALIB_COMMON_INTERNAL_STLUTILS_H 49 template<
class T>
inline void FreeContents(
const std::vector<T*>& v)
51 std::size_t size = v.size();
53 for(std::size_t i = 0; i < size; ++i)
66 for(
typename std::list<T*>::const_iterator it = l.begin(); it != l.end(); ++it)
77 template<
class K,
class V>
inline void FreeContents(std::map<K, V*>& m)
79 typename std::map<K, V*>::const_iterator it = m.begin();
80 typename std::map<K, V*>::const_iterator itend = m.end();
96 template<
class V,
class C>
inline void FreeContents(std::set<V*, C>& m)
98 typename std::set<V*, C>::const_iterator it = m.begin();
99 typename std::set<V*, C>::const_iterator itend = m.end();
131 template<
class T>
inline void Free(std::vector<T*>* v)
136 std::size_t size = v->size();
138 for(std::size_t i = 0; i < size; ++i)
149 inline void Free(
char** carray)
151 for(
char** aux = carray; *aux; ++aux)
163 template<
class T>
inline void Free(T** a, std::size_t s)
165 for(std::size_t i = 0; i < s; ++i)
179 template<
class K,
class V>
inline V*
GetPValue(
const std::map<K, V*>& m,
const K& k)
181 typename std::map<K, V*>::const_iterator it = m.find(k);
197 template<
class K,
class C>
inline K*
GetPValue(
const std::set<K*, C>& m, K* k)
199 typename std::set<K*, C>::const_iterator it = m.find(k);
217 template<
class K,
class V>
inline V**
GetPPValue(std::map<K, V*>& m,
const K& k)
219 typename std::map<K, V*>::iterator it = m.find(k);
222 return &(it->second);
237 template<
class T>
inline void Clone(
const std::vector<T*>& src, std::vector<T*>& dst)
239 std::size_t size = src.size();
243 for(std::size_t i = 0; i < size; ++i)
244 dst.push_back(static_cast<T*>(src[i]->clone()));
255 template<
class T>
inline void Copy(
const std::vector<T*>& src, std::vector<T*>& dst)
257 std::size_t size = src.size();
261 for(std::size_t i = 0; i < size; ++i)
262 dst.push_back(
new T(*src[i]));
265 template<
class T>
inline bool Contains(
const std::vector<T>& src,
const T& value)
267 return std::find(src.begin(), src.end(), value) != src.end();
273 #endif // __TERRALIB_COMMON_INTERNAL_STLUTILS_H V * GetPValue(const std::map< K, V * > &m, const K &k)
It finds for a given key in the map and returns a pointer if something is found or NULL otherwise...
bool Contains(const std::vector< T > &src, const T &value)
void Copy(const std::vector< T * > &src, std::vector< T * > &dst)
This function can be applied to a vector of pointers. It will copy element by element through its cop...
V ** GetPPValue(std::map< K, V * > &m, const K &k)
It finds for a given key in the map and returns a pointer if something is found or NULL otherwise...
void Free(std::vector< T * > *v)
This function can be applied to a pointer to a vector of pointers.
void Clone(const std::vector< T * > &src, std::vector< T * > &dst)
This function can be applied to a vector of pointers.
void FreeContents(boost::unordered_map< K, V * > &m)
This function can be applied to a map of pointers. It will delete each pointer in the map...