panthema / 2006 / SDIOS06 / sdios06 / testapps / stltest / algorithm (Download File)
#ifndef ALGORITHM_
#define ALGORITHM_

namespace std {

	template<typename T>
	T min(T v1, T v2)
	{
		if(v1 < v2)
			return v1;
		return v2;
	}
	
	template<typename T>
	T max(T v1, T v2)
	{
		if(v2 < v1)
			return v1;
		return v2;
	}
	
	template<typename T>
	void swap(T& v1, T& v2)
	{
		T t(v1);
		v1 = v2;
		v2 = t;
	}

	template<typename Iter, typename Val>
	Iter find(Iter first, Iter last, const Val& val)
	{
		Iter i = first;
		
		while(i != last) {
			if(*i == val)
				break;
			++i;
		}

		return i;
	}

}

#endif