Public Member Functions | Protected Attributes

OpenTissue::spatial_hashing::ShiftedGoldenMeanHashFunction Class Reference

#include <spatial_hashing_shifted_golden_mean_function.h>

List of all members.

Public Member Functions

 ShiftedGoldenMeanHashFunction ()
 ShiftedGoldenMeanHashFunction (size_t size)
size_t operator() (int i, int j, int k)
void resize (size_t new_size)
size_t size () const

Protected Attributes

size_t m_size

Detailed Description

Hash Function suggested by Robert Bridson.

For a single 32-bit size_teger k:

size_t hash(size_t k) { return k*2654435769u; }

This is based on shifting the golden-mean to fill 32 bits, from Knuth. Then for a triple of 32-bit integers (i,j,k):

size_t hash(int i, int j, int k){ return i ^ hash(j ^ hash(k)); }

The hash function for 3 integers generalizes to any number of integers, and 8-, 16-, or 64-bit quantities are just as easy to deal with, using a different multiplier in the core hash function)


Constructor & Destructor Documentation

OpenTissue::spatial_hashing::ShiftedGoldenMeanHashFunction::ShiftedGoldenMeanHashFunction (  )  [inline]
OpenTissue::spatial_hashing::ShiftedGoldenMeanHashFunction::ShiftedGoldenMeanHashFunction ( size_t  size  )  [inline]

Member Function Documentation

size_t OpenTissue::spatial_hashing::ShiftedGoldenMeanHashFunction::operator() ( int  i,
int  j,
int  k 
) [inline]
void OpenTissue::spatial_hashing::ShiftedGoldenMeanHashFunction::resize ( size_t  new_size  )  [inline]
size_t OpenTissue::spatial_hashing::ShiftedGoldenMeanHashFunction::size (  )  const [inline]

Member Data Documentation


The documentation for this class was generated from the following file: