diff options
Diffstat (limited to '')
| -rw-r--r-- | src/hash.h | 30 |
1 files changed, 29 insertions, 1 deletions
| @@ -141,6 +141,34 @@ public: | |||
| 141 | aValues = va.allocate( nCapacity ); | 141 | aValues = va.allocate( nCapacity ); |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | Hash( const Hash &src ) : | ||
| 145 | nCapacity( src.nCapacity ), | ||
| 146 | nFilled( 0 ), | ||
| 147 | nDeleted( 0 ), | ||
| 148 | bFilled( NULL ), | ||
| 149 | bDeleted( NULL ), | ||
| 150 | aKeys( NULL ), | ||
| 151 | aValues( NULL ), | ||
| 152 | aHashCodes( NULL ) | ||
| 153 | { | ||
| 154 | nKeysSize = bitsToBytes( nCapacity ); | ||
| 155 | bFilled = ca.allocate( nKeysSize ); | ||
| 156 | bDeleted = ca.allocate( nKeysSize ); | ||
| 157 | clearBits(); | ||
| 158 | |||
| 159 | aHashCodes = ca.allocate( nCapacity ); | ||
| 160 | aKeys = ka.allocate( nCapacity ); | ||
| 161 | aValues = va.allocate( nCapacity ); | ||
| 162 | |||
| 163 | for( uint32_t j = 0; j < nCapacity; j++ ) | ||
| 164 | { | ||
| 165 | if( src.isFilled( j ) ) | ||
| 166 | { | ||
| 167 | insert( src.aKeys[j], src.aValues[j] ); | ||
| 168 | } | ||
| 169 | } | ||
| 170 | } | ||
| 171 | |||
| 144 | virtual ~Hash() | 172 | virtual ~Hash() |
| 145 | { | 173 | { |
| 146 | for( uint32_t j = 0; j < nCapacity; j++ ) | 174 | for( uint32_t j = 0; j < nCapacity; j++ ) |
| @@ -502,7 +530,7 @@ protected: | |||
| 502 | ca.deallocate( aOldHashCodes, nOldCapacity ); | 530 | ca.deallocate( aOldHashCodes, nOldCapacity ); |
| 503 | } | 531 | } |
| 504 | 532 | ||
| 505 | virtual bool isFilled( uint32_t loc ) | 533 | virtual bool isFilled( uint32_t loc ) const |
| 506 | { | 534 | { |
| 507 | return (bFilled[loc/32]&(1<<(loc%32)))!=0; | 535 | return (bFilled[loc/32]&(1<<(loc%32)))!=0; |
| 508 | } | 536 | } |
