// Hash table implementation
// By: Nick Cash
// Coded for Computer Science III

// Hash.h - Class definition header

#ifndef INC_HASH // inclusion guard
#define INC_HASH

// Standard includes & typedefs
#include <list>
#include <vector>
#include <time.h>
#include <windows.h>

// Typedefs
typedef unsigned int uint;
typedef uint HashFunction(const std::string&);
typedef std::list<std::string> ElemList;

// Defines
#define HASH_TABLE_SIZE         4096

class HashTable
{
   public:
          // constructors and destructors
          HashTable( HashFunction* f );
          HashTable( HashFunction* f, uint buckets);
         ~HashTable();
         
          // Methods
          void SetHashFunc(HashFunction * f );
          HashFunction* GetHashFunc() const;

          // Return time to look up, -1 if not in table
          int Lookup(const std::string&);
          
          // Add a word
          void Add(const std::string&);
          
   private:
  		  HashFunction* mHashFunc;
		  uint mNumBuckets;
 		  std::vector<ElemList*> mBuckets; // Our table

  		  // get the bucket for a string
 		  uint Hash(const std::string&) const;
};

// Timer.cpp

// very simple, high-precision (at least in theory) timer for timing API calls
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 // INC_HASH