diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/stable/hash.h | 15 | ||||
| -rw-r--r-- | src/stable/randombase.cpp | 15 | ||||
| -rw-r--r-- | src/stable/randombase.h | 13 |
3 files changed, 25 insertions, 18 deletions
diff --git a/src/stable/hash.h b/src/stable/hash.h index e461cf5..86f189e 100644 --- a/src/stable/hash.h +++ b/src/stable/hash.h | |||
| @@ -1212,6 +1212,21 @@ namespace Bu | |||
| 1212 | return !(*this == rhs); | 1212 | return !(*this == rhs); |
| 1213 | } | 1213 | } |
| 1214 | 1214 | ||
| 1215 | MyType &operator+=( const MyType &rhs ) | ||
| 1216 | { | ||
| 1217 | if( this == &rhs ) | ||
| 1218 | return *this; | ||
| 1219 | if( core == rhs.core ) | ||
| 1220 | return *this; | ||
| 1221 | if( core == NULL || rhs.core == NULL ) | ||
| 1222 | return *this; | ||
| 1223 | |||
| 1224 | for( const_iterator i = rhs.begin(); i; i++ ) | ||
| 1225 | insert( i.getKey(), i.getValue() ); | ||
| 1226 | |||
| 1227 | return *this; | ||
| 1228 | } | ||
| 1229 | |||
| 1215 | protected: | 1230 | protected: |
| 1216 | virtual Core *_copyCore( Core *src ) | 1231 | virtual Core *_copyCore( Core *src ) |
| 1217 | { | 1232 | { |
diff --git a/src/stable/randombase.cpp b/src/stable/randombase.cpp index 71a5c89..6514df3 100644 --- a/src/stable/randombase.cpp +++ b/src/stable/randombase.cpp | |||
| @@ -14,18 +14,3 @@ Bu::RandomBase::~RandomBase() | |||
| 14 | { | 14 | { |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | int32_t Bu::RandomBase::rand( int32_t iMax ) | ||
| 18 | { | ||
| 19 | return rand( 0, iMax ); | ||
| 20 | } | ||
| 21 | |||
| 22 | int32_t Bu::RandomBase::rand( int32_t iMin, int32_t iMax ) | ||
| 23 | { | ||
| 24 | return iMin+(randNorm()*(iMax-iMin)); | ||
| 25 | } | ||
| 26 | |||
| 27 | double Bu::RandomBase::randNorm() | ||
| 28 | { | ||
| 29 | return (((uint32_t)rand())&0xfffffffeul)/(double)(0xfffffffful); | ||
| 30 | } | ||
| 31 | |||
diff --git a/src/stable/randombase.h b/src/stable/randombase.h index a5a4f42..d33bb99 100644 --- a/src/stable/randombase.h +++ b/src/stable/randombase.h | |||
| @@ -19,9 +19,16 @@ namespace Bu | |||
| 19 | 19 | ||
| 20 | virtual void seed( int32_t iSeed )=0; | 20 | virtual void seed( int32_t iSeed )=0; |
| 21 | virtual int32_t rand()=0; | 21 | virtual int32_t rand()=0; |
| 22 | virtual int32_t rand( int32_t iMax ); | 22 | virtual inline int32_t rand( int32_t iMax ) { |
| 23 | virtual int32_t rand( int32_t iMin, int32_t iMax ); | 23 | return rand( 0, iMax ); |
| 24 | virtual double randNorm(); | 24 | } |
| 25 | virtual inline int32_t rand( int32_t iMin, int32_t iMax ) { | ||
| 26 | return iMin+(randNorm()*(iMax-iMin)); | ||
| 27 | } | ||
| 28 | virtual inline double randNorm() { | ||
| 29 | return (((uint32_t)rand())&0xfffffffeul)*0x1.00000001p-32; | ||
| 30 | // return (((uint32_t)rand())&0xfffffffeul)/(double)(0xfffffffful); | ||
| 31 | } | ||
| 25 | }; | 32 | }; |
| 26 | }; | 33 | }; |
| 27 | 34 | ||
