Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
hashfn.h File Reference
#include "host.h"

Go to the source code of this file.

Functions

inT32 hash (inT32 bits, void *key, inT32 keysize)
 

Function Documentation

inT32 hash ( inT32  bits,
void *  key,
inT32  keysize 
)

Definition at line 30 of file hashfn.cpp.

34  {
35  inT32 bitindex; //current bit count
36  uinT32 keybits; //bit buffer
37  uinT32 hcode; //current hash code
38  uinT32 mask; //bit mask
39 
40  mask = (1 << bits) - 1;
41  keysize *= 8; //in bits
42  bitindex = 0;
43  keybits = 0;
44  hcode = 0;
45  do {
46  while (keysize > 0 && bitindex <= 24) {
47  keybits |= *((uinT8 *) key) << bitindex;
48  key = (uinT8 *) key + 1;
49  bitindex += 8;
50  keysize -= 8;
51  }
52  hcode ^= keybits & mask; //key new key
53  keybits >>= bits;
54  }
55  while (keysize > 0);
56  return hcode; //initial hash
57 }
int inT32
Definition: host.h:102
unsigned char uinT8
Definition: host.h:99
unsigned int uinT32
Definition: host.h:103