#ifndef STRINGHASH_H
#define STRINGHASH_H

#include <string>
using namespace std;

#include <hashfunction01.h>
#include <typedefs.h>


/*!
\brief String hash function.

It works by taking a string and then repeating it to make
 another string of cyclelength.

A hash function goes along the string hashing an integer 
 with each character in the string.
 Finally this integer is hashed by another hash function
 to give the hashed integer returned.

This integer hopefully is a random integer, except that we
 know its string as the key.
*/
class stringhash
{
  hashfunction01 hashfn;
public:

  /** Ensure that the string has the minumun cycle length
      of characters by repeating the string. */
  /** The maximum length of the string being hashed. */
  uint cyclelength;

  /** Construct in bad state. */
  stringhash() : cyclelength(0) {};

  /** Construct class. */
  void construct( uintc cyclelength_, uintc loops_ );

  /** Enter the maximum string length and the number of
      loops the hash function goes through. */
  stringhash( uintc cyclelength_, uintc loops_ );

  /** Hash the string. */
  uintc operator()(stringc & key) const;

};



#endif


