#ifndef INC_HASH #define INC_HASH
#include <list>
#include <vector>
#include <time.h>
#include <windows.h>
typedef unsigned int uint;
typedef uint HashFunction(const std::string&);
typedef std::list<std::string> ElemList;
#define HASH_TABLE_SIZE 4096
class HashTable
{
public:
HashTable( HashFunction* f );
HashTable( HashFunction* f, uint buckets);
~HashTable();
void SetHashFunc(HashFunction * f );
HashFunction* GetHashFunc() const;
int Lookup(const std::string&);
void Add(const std::string&);
private:
HashFunction* mHashFunc;
uint mNumBuckets;
std::vector<ElemList*> mBuckets; uint Hash(const std::string&) const;
};
struct ProfTimer
{
void Start(void)
{
QueryPerformanceCounter(&mTimeStart);
};
void Stop(void)
{
QueryPerformanceCounter(&mTimeStop);
};
double GetDurationInSecs(void)
{
LARGE_INTEGER freq;
QueryPerformanceFrequency(&freq);
double duration = (double)(mTimeStop.QuadPart-mTimeStart.QuadPart)/(double)freq.QuadPart;
return duration;
}
LARGE_INTEGER mTimeStart;
LARGE_INTEGER mTimeStop;
};
#endif