#include "QuadraticHash.h"
#include <assert.h>
#include <memory.h>

//
// Generic hash function for quadratic hashing H(key,index,a,b) = (k + ai + bi^2) mod N.
//
#define a ((N/3)+1)
#define b ((N/7)-1)

int QuadraticHash::H(Key key, int index) {
  return abs(key + a*index + b*index*index) % N;
};