#include "DoubleHash.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 DoubleHash::H(Key key, int index) {
  return abs(key + a*index + b*index*H2(key,index)) % N;
};

int DoubleHash::H2(Key key, int index) {
  return abs(key) % (N-2);
};