00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef VEE_PTR_H
00021 #define VEE_PTR_H
00022
00023 class VEE_Ptr
00024 {
00025 public:
00026
00027 static inline int distance(const void *p1, const void *p2)
00028 {
00029 const char * c1 = (const char *) p1;
00030 const char * c2 = (const char *) p2;
00031
00032 return c1 - c2;
00033 }
00034
00035 template <class T>
00036 static inline T * offset(T *p, int offsetBytes)
00037 { return (T *) (((char *) p) + offsetBytes); }
00038
00039 template <class T>
00040 static inline const T * offset(const T *p, int offsetBytes)
00041 { return (T *) (((char *) p) + offsetBytes); }
00042
00043
00044
00045
00047 static inline float ptrToRandom(void * ptr)
00048 {
00049 unsigned seed = (int) ptr;
00050 seed = seed * 134695621 + 1;
00051 seed = seed * 134695621 + 1;
00052 seed = seed * 134695621 + 1;
00053
00054 return seed * (1.0 / (float) ((unsigned) 0xffffffff));
00055 }
00056
00057 };
00058
00059 #endif