// name
// date
// CS 303
// HashPerfect class
//
// This class implements the perfect hashing scheme, where each key is hashed to
// a specific location, and inserted into a secondary table located there.  The
// secondary table is a hash table with linear probing, sized to the square of
// the number of items that hash to it.


#include <vector>
#include <iostream>
#include "HashLin.hpp"
#include "HashPerfect.hpp"

using namespace std;


// constructor
HashPerfect::HashPerfect (void)

{
   size = 10;

   // use for loop to set all hash pointer values to NULL
}


int HashPerfect::hash (string el)

{
   // same hash function as HashLin
}


bool HashPerfect::insert (vector<string> words)

{
   int hashEls [size];  // table to hold number of elements hash to each location


   // use for loop to set all location counts in hashEls to 0

   // use for loop to hash each element to determine how many will map to each location;
   //  increment appropriate hashEls location each time

   // at each location, allocate space for a secondary hash table that is
   //  n^2 elements, where n is the number of elements that hash to it
   for (index = 0; index < size; index++) {

      hashTable [index] = new HashLin (hashEls [index] * hashEls [index]);
   }

   // place each element into the proper secondary hash table
   for (index = 0; index < words.size (); index++) {

      hashTable [hash (words [index])] -> insert (words [index]);
   }

   return true;
}


void HashPerfect::print (void)

{
   int index;


   for (index = 0; index < size; index++) {

      cout << "  " << index << ": --> " << endl;

      // print the hash table with linear probing at this location by
      //  calling its print with indent of 7
   }
}

