home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Add-Ons / CodeWarrior / DASM 2.0 / DASM Src.sit / SRC / HASH.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-16  |  2.0 KB  |  56 lines

  1. // Externs and protos for the simple Hash routines.
  2. //
  3. // 17-Feb-97 LR  - modified to use typedefs, easier to read!
  4. // 29-May-95 KBI - created
  5. //
  6. /////////////////////
  7.  
  8. #ifndef _H_HASH
  9. #define _H_HASH
  10.  
  11. // Stuff specific to Hash table handling
  12.  
  13. typedef char                *cPtr;
  14.  
  15. typedef unsigned long    HashEntryType;
  16. typedef unsigned long    HashValueType;
  17. typedef unsigned int    StringIdxType;
  18.  
  19. typedef HashEntryType *HashEntryPtr;
  20. typedef HashValueType *HashValuePtr;
  21. typedef StringIdxType *StringIdxPtr;
  22.  
  23. #define    HASH_ENTRY_SIZE        sizeof( HashEntryType )
  24. #define HASH_VALUE_SIZE        sizeof( HashValueType )
  25. #define STRING_INDEX_SIZE    sizeof( StringIdxType )
  26.  
  27. #define AVG_STRING_SIZE        (20)                // calc initial string space
  28. #define GROW_SPACE_CHUNK    (1024L)            // and grow it as needed in 1K chunks
  29.  
  30. // globals - now created/carried in a handle on the fly
  31.  
  32. typedef struct
  33. {
  34.     unsigned int        gSS_Size;                // tracks current String Space Size
  35.     unsigned int        gNextString;        // where to place the next string in the string space
  36.     unsigned int        gTotalNames;        // tracks current # of entries in tbl
  37.     unsigned int        gMaxEntries;        // max hash entries for this table
  38.     Handle                gNameTable;                // The hashed values of the names
  39.     Handle                gValueTable;            // A value is associated w/each name
  40.     Handle                gStringTable;            // Table of indexes into the string space
  41.     Handle                gStringSpace;            // the actual strings used for compares
  42.  
  43. } HashTableGlobals, *HashTablePtr, **HashTableHandle;
  44.  
  45. HashEntryType    hash_Calc( char *name );
  46. HashTableHandle    hash_New( int tableSize );
  47. void hash_Dispose( HashTableHandle table );
  48. int hash_Match( HashTableHandle table, char *name );
  49. OSErr hash_Add( HashTableHandle table, char *name, HashValueType value );
  50. Boolean hash_Search( HashTableHandle table, char *name, HashValueType *value );
  51. void hash_Clear( HashTableHandle table );
  52. OSErr hash_Update( HashTableHandle table, char *name, HashValueType value );
  53. OSErr hash_DisposeHandles( HashTableHandle table );
  54.  
  55. #endif
  56.