#include #include #include "HashUtility.h" using namespace std; std::size_t sum_of_components_hash::operator () (const string & str) const{ int s=0; for (int i=0; i< str.size(); i++) s+=(int)str[i]; return s; } polynomial_hash::polynomial_hash(){ srand((unsigned)time(0)); a_ = rand(); while (a_==0) a_ = rand(); cout << "chosen a: " << a_ << endl; } std::size_t polynomial_hash::operator () (const string & str) const{ int s=0; //ToDo: implement polynomial hash code here return s; } cyclic_hash::cyclic_hash(){ //ToDo: implement the default constructor in a way that you get a random integer in [0, 31] as sh. //writing the chosen sh. Do not comment out. cout << "chosen sh: " << sh_ << endl; } //cyclish_hash working with 32 bit unsigned int. std::size_t cyclic_hash::operator() (const string & str) const{ unsigned int s=0; for (int i=0; i< str.size(); i++){ s = (s << sh_) | (s >> (32 - sh_)); s += (unsigned int)str[i]; } return s; }