Main Page | Namespace List | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

Int.hpp

Go to the documentation of this file.
00001 
00027 //
00028 // File int.h
00029 //
00030 // Implements several functions on integers
00031 //
00032 //  990806 Uppsala
00033 //  990928 Uppsala, min added
00034 //  19/02/2000 Manchester, slightly reimplemented
00035 //  09/06/2000 Manchester, toString added and int.cpp created
00036 //
00037 
00038 
00039 #ifndef __INT__
00040 #define __INT__
00041 
00042 
00043 #include <climits>
00044 #include "List.hpp"
00045 
00046 
00047 using namespace std;
00048 
00049 
00050 enum Compare 
00051 {
00052   LESS = -1,
00053   EQUAL = 0,
00054   GREATER = 1
00055 };
00056 
00057 
00058 #ifdef _MSC_VER // VC++
00059 #  undef max
00060 #  undef min
00061 #endif
00062 
00063 
00064 class Int 
00065 {
00066  public:
00067 
00068   static int max ( int i1, int i2 );
00069   static int min ( int i1, int i2 );
00070   static Compare compare ( int i1, int i2 );
00071   static const int max ();
00072   static const int min ();
00073   static void toString ( int i, char* str );
00074   static char* toString (int i);
00075 
00076   typedef List<int,CID_INTLIST> List;
00077 };
00078 
00079 
00080 inline 
00081 int Int::max ( int i1, int i2 ) 
00082 {
00083   return  i1 > i2 ? i1 : i2 ;
00084 }
00085 
00086 
00087 inline 
00088 int Int::min ( int i1, int i2 ) 
00089 {
00090   return  i1 < i2 ? i1 : i2 ;
00091 }
00092 
00093 
00094 inline 
00095 Compare Int::compare ( int i1, int i2 ) 
00096 {
00097   if ( i1 > i2 )
00098     return GREATER;
00099 
00100   if ( i1 == i2 )
00101     return EQUAL;
00102 
00103   return LESS;
00104 } // Int::compare
00105 
00106 
00107 inline
00108 const int Int::max ()
00109 {
00110   return INT_MAX;
00111 }
00112 
00113 
00114 inline
00115 const int Int::min ()
00116 {
00117   return INT_MIN;
00118 }
00119 
00120 
00121 #endif  // __INT__
00122 

Generated on Sat Jun 28 15:08:57 2003 for Vampire by doxygen 1.3.2