From 7e214c2b8977d5a19edf5f4ec6b059bd6ec9626d Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 29 Jan 2007 22:47:43 +0000 Subject: Added another new helper to Hash. --- src/hash.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src') diff --git a/src/hash.h b/src/hash.h index c65b20d..10db03a 100644 --- a/src/hash.h +++ b/src/hash.h @@ -160,13 +160,53 @@ public: aKeys = ka.allocate( nCapacity ); aValues = va.allocate( nCapacity ); + for( uint32_t j = 0; j < src.nCapacity; j++ ) + { + if( src.isFilled( j ) ) + { + insert( src.aKeys[j], src.aValues[j] ); + } + } + } + + Hash &operator=( const Hash &src ) + { for( uint32_t j = 0; j < nCapacity; j++ ) + { + if( isFilled( j ) ) + if( !isDeleted( j ) ) + { + va.destroy( &aValues[j] ); + ka.destroy( &aKeys[j] ); + } + } + va.deallocate( aValues, nCapacity ); + ka.deallocate( aKeys, nCapacity ); + ca.deallocate( bFilled, nKeysSize ); + ca.deallocate( bDeleted, nKeysSize ); + ca.deallocate( aHashCodes, nCapacity ); + + nFilled = 0; + nDeleted = 0; + nCapacity = src.nCapacity; + nKeysSize = bitsToBytes( nCapacity ); + bFilled = ca.allocate( nKeysSize ); + bDeleted = ca.allocate( nKeysSize ); + clearBits(); + + aHashCodes = ca.allocate( nCapacity ); + aKeys = ka.allocate( nCapacity ); + aValues = va.allocate( nCapacity ); + + for( uint32_t j = 0; j < src.nCapacity; j++ ) { if( src.isFilled( j ) ) { insert( src.aKeys[j], src.aValues[j] ); } } + + return *this; } virtual ~Hash() -- cgit v1.2.3