perfhlib.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. /* Perfect hashing function library. Contains functions to generate perfect
  2. hashing functions
  3. * (C) Mike van Emmerik
  4. */
  5. #define TRUE 1
  6. #define FALSE 0
  7. #define bool unsigned char
  8. #define byte unsigned char
  9. #define word unsigned short
  10. /* Prototypes */
  11. void hashParams(int NumEntry, int EntryLen, int SetSize, char SetMin,
  12. int NumVert); /* Set the parameters for the hash table */
  13. void hashCleanup(void); /* Frees memory allocated by hashParams() */
  14. void map(void); /* Part 1 of creating the tables */
  15. void assign(void); /* Part 2 of creating the tables */
  16. int hash(byte *s); /* Hash the string to an int 0 .. NUMENTRY-1 */
  17. word *readT1(void); /* Returns a pointer to the T1 table */
  18. word *readT2(void); /* Returns a pointer to the T2 table */
  19. word *readG(void); /* Returns a pointer to the g table */
  20. /* The application must provide these functions: */
  21. void getKey(int i, byte **pKeys);/* Set *keys to point to the i+1th key */
  22. void dispKey(int i); /* Display the key */
  23. /* Macro reads a LH word from the image regardless of host convention */
  24. #ifndef LH
  25. #define LH(p) ((int)((byte *)(p))[0] + ((int)((byte *)(p))[1] << 8))
  26. #endif