00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _STD_GLUE_LOCAL_H
00030 #define _STD_GLUE_LOCAL_H
00031
00032 #define brcase break; case
00033 #define brdefault break; default
00034
00035
00036 #define PRINT_VAR(v) cerr << # v << " = '" << v << "'" << endl
00037
00038 #include "std/config.H"
00039
00040 #ifdef WIN32
00041 # include <float.h>
00042 # include <windows.h>
00043 # undef min
00044 # undef max
00045 # define strncasecmp _strnicmp
00046 #endif
00047
00048 #if defined(WIN32) || (defined(__APPLE__) && _GNUC_ < 3)
00049 #ifdef __APPLE__
00050 #include <stdlib.h>
00051 #endif
00052 inline double drand48() { return rand()/double(RAND_MAX); }
00053 inline void srand48(long seed) { srand((unsigned int) seed); }
00054 inline long lrand48() { return rand(); }
00055 #endif
00056
00057 #ifdef __CYGWIN__
00058 inline double drand48() { return random()/double(INT_MAX); }
00059 #endif
00060
00061 template <class T>
00062 inline T sqr(const T x) { return x*x; }
00063
00064 #if (!defined(__GNUC__) || (__GNUC__ < 3)) && (!defined(_MSC_VER) || (_MSC_VER < 1300))
00065 #ifndef _STANDARD_C_PLUS_PLUS
00066 template <class Type>
00067 inline Type min(const Type a, const Type b) { return a < b ? a : b; }
00068
00069 template <class Type>
00070 inline Type max(const Type a, const Type b) { return a > b ? a : b; }
00071 #endif
00072
00073 template <class Type>
00074 inline void swap(Type &a, Type &b) { Type c(a); a = b; b = c; }
00075 #endif
00076
00077 template <class Type>
00078 inline Type clamp(const Type a,const Type b,const Type c)
00079 { return a > b ? (a < c ? a : c) : b ; }
00080
00081 inline int Sign (double a) { return a > 0 ? 1 : a < 0 ? -1 : 0; }
00082
00083
00084
00085 #endif