Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members

minmax.h

Go to the documentation of this file.
00001 /*--------------------------------------------------------------------
00002  *
00003  * (C) Copyright Koninklijke Philips Electronics NV 2006. 
00004  * All rights reserved. This software is licensed under the terms of
00005  * version 2.1 of the GNU Lesser General Public License as published 
00006  * by the Free Software Foundation. For licensing and warranty
00007  * information, see the file COPYING in the main directory.
00008  *
00009  *------------------------------------------------------------------*/
00010 
00011 #ifndef MINMAX_H
00012 #define MINMAX_H
00013 
00014 #ifdef NO_ALGO
00015 #include <string.h>
00016 
00017 template<class T>
00018 T min(const T& a, const T& b)
00019 {
00020   return a < b ? a : b;
00021 }
00022 
00023 template<class T>
00024 T max(const T& a, const T& b)
00025 {
00026   return a > b ? a : b;
00027 }
00028 
00029 template<class T>
00030 void copy(const T* begin, const T* end, T* result)
00031 {
00032   while (begin != end)
00033     *result++ = *begin++;
00034 
00035   // memcpy(result, begin, (end-begin)*sizeof(T));
00036 }
00037 
00038 #else
00039 #include <algorithm>
00040 using std::min;
00041 using std::max;
00042 using std::copy;
00043 #endif
00044 
00045 #endif

Generated on Wed Feb 15 14:52:39 2006 for yapi by doxygen 1.3.2