diff --git a/src/GHash.hh b/src/GHash.hh index 5122e1d..df613d0 100644 --- a/src/GHash.hh +++ b/src/GHash.hh @@ -88,7 +88,7 @@ public: //nextkey is SET to the corresponding key GHashEntry* NextEntry() { //returns a pointer to a GHashEntry register int pos=fCurrentEntry; - while (pos GHash::GHash(GFreeProc* freeProc) { fFreeProc=freeProc; lastkeyptr=NULL; for (uint i=0; i GHash::GHash(bool doFree) { lastkeyptr=NULL; fFreeProc = (doFree)?&DefaultFreeProc : NULL; for (uint i=0; i void GHash::Resize(int m){ if(n!=fCapacity){ GASSERT(m<=n); GMALLOC(k, sizeof(GHashEntry)*n); - for(i=0; i const OBJ* GHash::Add(const char* ky, GASSERT(1<=x && x const OBJ* GHash::Add(const char* ky, GTRACE(("GHash::insert: key=\"%s\"\n",ky)); //GMessage("GHash::insert: key=\"%s\"\n",ky); GASSERT(0<=i && i const OBJ* GHash::shkAdd(const char* ky, GASSERT(1<=x && x const OBJ* GHash::shkAdd(const char* ky, GTRACE(("GHash::insert: key=\"%s\"\n",ky)); //GMessage("GHash::insert: key=\"%s\"\n",ky); GASSERT(0<=i && i OBJ* GHash::Replace(const char* ky,const OBJ* pdata, GASSERT(1<=x && x OBJ* GHash::Replace(const char* ky,const OBJ* pdata, if(i==-1) i=p; GTRACE(("GHash::replace: %08x: inserting: \"%s\"\n",this,ky)); GASSERT(0<=i && i OBJ* GHash::Remove(const char* ky){ GASSERT(1<=x && x bool GHash::hasKey(const char* ky) { GASSERT(1<=x && x OBJ* GHash::Find(const char* ky, char** keyptr){ GASSERT(1<=x && x void GHash::startIterate() {// initialize a key iterat template char* GHash::NextKey() { register int pos=fCurrentEntry; - while (pos char* GHash::NextKey() { template OBJ* GHash::NextData() { register int pos=fCurrentEntry; - while (pos OBJ* GHash::NextData() { template OBJ* GHash::NextData(char* &nextkey) { register int pos=fCurrentEntry; - while (pos OBJ* GHash::NextData(char* &nextkey) { // Get first non-empty entry template int GHash::First() const { register int pos=0; - while(pos int GHash::Last() const { // Find next valid entry template int GHash::Next(int pos) const { GASSERT(0<=pos && pos int GHash::Next(int pos) const { // Find previous valid entry template int GHash::Prev(int pos) const { GASSERT(0<=pos && pos= 0){ if(0<=hash[pos].hash) break; } - GASSERT(pos<0 || 0<=hash[pos].hash); + while(--pos >= 0){ if(0<=(hash[pos].hash)) break; } + GASSERT(pos<0 || 0<=(hash[pos].hash)); return pos; } @@ -493,7 +493,7 @@ template int GHash::Prev(int pos) const { template void GHash::Clear(){ register int i; for(i=0; i=0){ + if((hash[i].hash)>=0){ if (hash[i].keyalloc) GFREE((hash[i].key)); if (FREEDATA) (*fFreeProc)(hash[i].data); @@ -503,7 +503,7 @@ template void GHash::Clear(){ GMALLOC(hash, sizeof(GHashEntry)*DEF_HASH_SIZE); //reinitialize it for (i=0; i=0){ + if((hash[i].hash)>=0){ uint len=strlen(hash[i].key); store << len; store << hash[i].mark; @@ -534,7 +534,7 @@ void GHash::Load(Stream& store){ store >> fCount; for(int i=0; i> hash[i].hash; - if(hash[i].hash>=0){ + if((hash[i].hash)>=0){ uint len; store >> len; store >> hash[i].mark; @@ -550,7 +550,7 @@ void GHash::Load(Stream& store){ template GHash::~GHash(){ register int i; for(i=0; i=0){ + if((hash[i].hash)>=0){ if (hash[i].keyalloc) GFREE((hash[i].key)); if (FREEDATA) (*fFreeProc)(hash[i].data); }