|
@@ -66,7 +66,7 @@ namespace Framework
|
|
|
|
|
|
void put( K key, V value )
|
|
|
{
|
|
|
- int index = hash( key ) % bucketCount;
|
|
|
+ int index = abs( hash( key ) ) % bucketCount;
|
|
|
if( !buckets[ index ] )
|
|
|
buckets[ index ] = new Array< MapEntry<K, V>>();
|
|
|
for( auto iterator = buckets[ index ]->getIterator(); iterator; iterator++ )
|
|
@@ -82,7 +82,7 @@ namespace Framework
|
|
|
|
|
|
void remove( K key )
|
|
|
{
|
|
|
- int index = hash( key ) % bucketCount;
|
|
|
+ int index = abs( hash( key ) ) % bucketCount;
|
|
|
if( !buckets[ index ] )
|
|
|
return;
|
|
|
int listIndex = 0;
|
|
@@ -98,7 +98,7 @@ namespace Framework
|
|
|
|
|
|
V get( K key ) const
|
|
|
{
|
|
|
- int index = hash( key ) % bucketCount;
|
|
|
+ int index = abs( hash( key ) ) % bucketCount;
|
|
|
if( !buckets[ index ] )
|
|
|
throw "element not found";
|
|
|
for( auto iterator = buckets[ index ]->getIterator(); iterator; iterator++ )
|
|
@@ -111,7 +111,7 @@ namespace Framework
|
|
|
|
|
|
V safeGet( K key, V fallback ) const
|
|
|
{
|
|
|
- int index = hash( key ) % bucketCount;
|
|
|
+ int index = abs( hash( key ) ) % bucketCount;
|
|
|
if( !buckets[ index ] )
|
|
|
return fallback;
|
|
|
for( auto iterator = buckets[ index ]->getIterator(); iterator; iterator++ )
|
|
@@ -124,7 +124,7 @@ namespace Framework
|
|
|
|
|
|
bool has( K key ) const
|
|
|
{
|
|
|
- int index = hash( key ) % bucketCount;
|
|
|
+ int index = abs( hash( key ) ) % bucketCount;
|
|
|
if( !buckets[ index ] )
|
|
|
return 0;
|
|
|
for( auto iterator = buckets[ index ]->getIterator(); iterator; iterator++ )
|