From 74f94e9b20c93b93ad8b9091474f6368fc79c697 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 12 Jul 2006 08:14:08 +0000 Subject: Added a clear function to the hashtable. How we made it this long without is beyond me... --- src/hashtable.cpp | 5 +++++ src/hashtable.h | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/src/hashtable.cpp b/src/hashtable.cpp index d3f9f26..8a31f57 100644 --- a/src/hashtable.cpp +++ b/src/hashtable.cpp @@ -31,6 +31,11 @@ void HashTable::set( int j, const void *newID, const void *newData ) aTable[j].data = newData; } +void HashTable::clear() +{ + memset( aTable, 0, sizeof(HashNode) * nTableSize ); +} + bool HashTable::isFilled( int j ) { return (aTable[j].id != NULL)||(aTable[j].bDeleted); diff --git a/src/hashtable.h b/src/hashtable.h index d14be71..b015107 100644 --- a/src/hashtable.h +++ b/src/hashtable.h @@ -175,6 +175,13 @@ public: */ bool del( const void *id, int nSkip=0 ); + /** + * Deletes every entry in the hash table. See the notes on del to see what + * this means, except that since no data is being kept, the entire table is + * just marked as usable space. + */ + void clear(); + private: /** * Contains info related to a position in the hashtable. Used for -- cgit v1.2.3