#ifndef UNITDOUBLE_H
#define UNITDOUBLE_H

#include <typedefs.h>

/*!
\brief Maps a normalized double to an integer.

This is a hash function for a uniform distribution.
 It is assumend the double has been normalized:  0.0 < x < 1.0
*/
class unitdouble
{ 
public:

  /** Configures the number of buckets. */
  uintc bucketsize;
  /** The hash function. */
  uintc index(doublec & x) const 
    { return (uint)((x*bucketsize)) % bucketsize; }
  /** Compare two doubles. */
  boolc operator() 
  (
    doublec & a,
    doublec & b
  ) const 
    { return a < b; }

  /** Construct the hash function. */
  unitdouble(uintc bucketsize_)
    : bucketsize(bucketsize_) {}
   
};

#endif



