Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
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.

{
inT32 bitindex; //current bit count
uinT32 keybits; //bit buffer
uinT32 hcode; //current hash code
uinT32 mask; //bit mask
mask = (1 << bits) - 1;
keysize *= 8; //in bits
bitindex = 0;
keybits = 0;
hcode = 0;
do {
while (keysize > 0 && bitindex <= 24) {
keybits |= *((uinT8 *) key) << bitindex;
key = (uinT8 *) key + 1;
bitindex += 8;
keysize -= 8;
}
hcode ^= keybits & mask; //key new key
keybits >>= bits;
}
while (keysize > 0);
return hcode; //initial hash
}