From fbe6bc4d8f7980a889a9df0964287b0100781dca Mon Sep 17 00:00:00 2001 From: ponchio Date: Thu, 1 Jul 2004 21:34:04 +0000 Subject: [PATCH] Rehash bug. --- apps/nexus/mfhash.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/nexus/mfhash.cpp b/apps/nexus/mfhash.cpp index f49e8b9e..debe5895 100644 --- a/apps/nexus/mfhash.cpp +++ b/apps/nexus/mfhash.cpp @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.1 2004/06/24 14:32:45 ponchio +Moved from wrap/nexus + Revision 1.1 2004/06/24 14:18:58 ponchio Created @@ -31,12 +34,14 @@ Created ****************************************************************************/ #include "mfhash.h" +#include using namespace std; using namespace nxs; bool MFHash::Create(const string &file, unsigned int reserved) { if(!buffer.Create(file)) return false; + buffer.Resize(reserved); Bucket empty; for(unsigned int i = 0; i < buffer.Size(); i++) @@ -98,8 +103,10 @@ void MFHash::Insert(unsigned int key, unsigned int value, bool rehash) { if(rehash) { float ratio = space / (float)buffer.Size(); - if(ratio < 0.4) //need to resize - Resize(buffer.Size() * 2 - 1); + if(ratio < 0.4) { //need to resize + cerr << "rehash" << endl; + Resize(buffer.Size() * 2 + 3); + } } }