aboutsummaryrefslogtreecommitdiff
path: root/src/stable
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-08-18 23:43:21 +0000
committerMike Buland <eichlan@xagasoft.com>2012-08-18 23:43:21 +0000
commitf5ac2c1ba333ce6aa6d385d9a63b658caaa46503 (patch)
treecd78edf4663967a99c483fd0a7f0506328cab008 /src/stable
parent80aa35bbeca7d034c788be9942725dae9d3f46c4 (diff)
downloadlibbu++-f5ac2c1ba333ce6aa6d385d9a63b658caaa46503.tar.gz
libbu++-f5ac2c1ba333ce6aa6d385d9a63b658caaa46503.tar.bz2
libbu++-f5ac2c1ba333ce6aa6d385d9a63b658caaa46503.tar.xz
libbu++-f5ac2c1ba333ce6aa6d385d9a63b658caaa46503.zip
Added hashtable += support, optomized the random number base some?
Diffstat (limited to 'src/stable')
-rw-r--r--src/stable/hash.h15
-rw-r--r--src/stable/randombase.cpp15
-rw-r--r--src/stable/randombase.h13
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
17int32_t Bu::RandomBase::rand( int32_t iMax )
18{
19 return rand( 0, iMax );
20}
21
22int32_t Bu::RandomBase::rand( int32_t iMin, int32_t iMax )
23{
24 return iMin+(randNorm()*(iMax-iMin));
25}
26
27double 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