ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/util.h
(Generate patch)

Comparing deliantra/server/include/util.h (file contents):
Revision 1.37 by root, Thu Feb 15 15:43:36 2007 UTC vs.
Revision 1.39 by pippijn, Thu Mar 1 12:28:16 2007 UTC

48template<typename T, typename U> static inline void swap (T& a, U& b) { T t=a; a=(T)b; b=(U)t; } 48template<typename T, typename U> static inline void swap (T& a, U& b) { T t=a; a=(T)b; b=(U)t; }
49 49
50// lots of stuff taken from FXT 50// lots of stuff taken from FXT
51 51
52/* Rotate right. This is used in various places for checksumming */ 52/* Rotate right. This is used in various places for checksumming */
53//TODO: this sucks, use a better checksum algo 53//TODO: that sucks, use a better checksum algo
54static inline uint32_t 54static inline uint32_t
55rotate_right (uint32_t c) 55rotate_right (uint32_t c, uint32_t count = 1)
56{ 56{
57 return (c << 31) | (c >> 1); 57 return (c << (32 - count)) | (c >> count);
58}
59
60static inline uint32_t
61rotate_left (uint32_t c, uint32_t count = 1)
62{
63 return (c >> (32 - count)) | (c << count);
58} 64}
59 65
60// Return abs(a-b) 66// Return abs(a-b)
61// Both a and b must not have the most significant bit set 67// Both a and b must not have the most significant bit set
62static inline uint32_t 68static inline uint32_t
393 } 399 }
394 400
395 void erase (T *obj) 401 void erase (T *obj)
396 { 402 {
397 assert (obj->*index); 403 assert (obj->*index);
398 int pos = obj->*index; 404 unsigned int pos = obj->*index;
399 obj->*index = 0; 405 obj->*index = 0;
400 406
401 if (pos < this->size ()) 407 if (pos < this->size ())
402 { 408 {
403 (*this)[pos - 1] = (*this)[this->size () - 1]; 409 (*this)[pos - 1] = (*this)[this->size () - 1];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines