proj home

Files   Classes   Functions   Hierarchy  

hashfunction01 Class Reference

#include <hashfunction01.h>

Collaboration diagram for hashfunction01:

List of all members.

Public Member Functions

 hashfunction01 ()
 Construct in bad state.
void construct (uint nloops_)
 Construct class.
 hashfunction01 (uintc nloops_)
 Control the number of loops, must be greater than 0.
uintc operator() (uintc key) const
 Hash an integer to another integer.

Public Attributes

uint nloops
 The number of loops in the hash function.


Detailed Description

Definition at line 14 of file hashfunction01.h.


Constructor & Destructor Documentation

hashfunction01::hashfunction01 (  ) 

Construct in bad state.

Definition at line 4 of file hashfunction01.cpp.

00005   : nloops(0) {}

hashfunction01::hashfunction01 ( uintc  nloops_  ) 

Control the number of loops, must be greater than 0.

Definition at line 7 of file hashfunction01.cpp.

00008   : nloops(loops_) {}


Member Function Documentation

void hashfunction01::construct ( uint  nloops_  )  [inline]

Construct class.

Definition at line 25 of file hashfunction01.h.

References nloops.

Referenced by stringhash::construct().

00026     { nloops=nloops_; }

uintc hashfunction01::operator() ( uintc  key  )  const

Hash an integer to another integer.

Definition at line 11 of file hashfunction01.cpp.

References nloops.

00012 {
00013   uint h = key;
00014   uint i;
00015 
00016   assert(nloops!=0);
00017 
00018   for (i=0; i<nloops; ++i)
00019   {
00020     h += ~(h << 15);
00021     h ^=  (h >> 10);
00022     h +=  (h << 3);
00023     h ^=  (h >> 6);
00024     h += ~(h << 11);
00025     h ^=  (h >> 10);
00026   }
00027 
00028   return h;
00029 }


Member Data Documentation

The number of loops in the hash function.

Definition at line 19 of file hashfunction01.h.

Referenced by construct(), and operator()().


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

Generated on Fri Mar 4 00:50:02 2011 for Chelton Evans Source by  doxygen 1.5.8