stlutils.h

来自「java实现的简单的分形树。简单易学!是学习分形知识的很好的例子。其java语法」· C头文件 代码 · 共 52 行

H
52
字号
// --------------------------------------------------------------------------
// Dingus project - a collection of subsystems for game/graphics applications
// --------------------------------------------------------------------------

#ifndef __STL_UTILS_H__
#define __STL_UTILS_H__

namespace dingus {

namespace stl_utils {

/** Deletes items in pointer container. */
template<class T>
void wipe( T& cont )
{
	for( T::iterator it = cont.begin(); it != cont.end(); ++it )
		delete *it;
	cont.clear();
};

/** Deletes values in map (values by pointers). */
template<class T>
void wipe_map( T& cont )
{
	for( T::iterator it = cont.begin(); it != cont.end(); ++it )
		delete it->second;
	cont.clear();
};

/** Same as "for_each", but for the whole container at once. */
template<typename _T, typename _O>
void for_all( _T& cont, _O& op )
{
	for( _T::iterator it = cont.begin(); it != cont.end(); ++it )
		op( *it );
};

/** Same as "for_each", but for the whole container at once. */
template<typename _T, typename _O>
void for_all( _T const& cont, _O& op )
{
	for( _T::const_iterator it = cont.begin(); it != cont.end(); ++it )
		op( *it );
};

}; // namespace stl_utils


}; // namespace

#endif 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?