home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / lucid / lemacs-19.6 / src / hash.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-11  |  2.2 KB  |  76 lines

  1. #ifndef _HASH_H_
  2. #define _HASH_H_
  3.  
  4. typedef struct{
  5.  void*    key;
  6.  void*    contents;
  7. } hentry;
  8.  
  9. struct _C_hashtable{
  10.  hentry*    harray;
  11.  int zero_set;
  12.  void *zero_entry;
  13.  unsigned int    size; /* size of the hasharray */
  14.  unsigned int    fullness; /* number of entries in the hashtable */
  15.  unsigned long (*hash_function)();
  16.  int (*test_function)();
  17. #ifdef emacs
  18.  void *elisp_table;
  19. #endif
  20. };
  21.  
  22. typedef struct _C_hashtable *c_hashtable;
  23.  
  24. /* size is the number of initial entries. The hashtable will be grown
  25.    automatically if the number of entries approaches the size */
  26. extern c_hashtable make_hashtable (unsigned int size);
  27.  
  28. extern c_hashtable make_general_hashtable 
  29.   (unsigned int hsize, unsigned long (*hash_function)(), 
  30.       int (*test_function)());
  31.  
  32. extern c_hashtable make_strings_hashtable ( /* unsigned int hsize */ );
  33.  
  34. /* clears the hash table. A freshly created hashtable is already cleared up */
  35. extern void clrhash (c_hashtable hash);
  36.  
  37. /* frees the table and substructures */
  38. extern void free_hashtable (c_hashtable hash);
  39.  
  40. /* returns a hentry whose key is 0 if the entry does not exist in hashtable */
  41. extern void* gethash (void* key, c_hashtable hash, void** ret_value);
  42.  
  43. /* key should be different from 0 */
  44. extern void puthash (void* key, void* cont, c_hashtable hash);
  45.  
  46. /* delete the entry which key is key */
  47. extern void remhash (void* key, c_hashtable hash);
  48.  
  49. typedef void (*maphash_function) 
  50. (void* key, void* contents, void* arg);
  51.  
  52. typedef int (*remhash_predicate) 
  53. (void* key, void* contents, void* arg);
  54.  
  55. typedef void (*generic_hashtable_op) 
  56. (c_hashtable table, void *arg1, void *arg2, void *arg3);
  57.  
  58. /* calls mf with the following arguments:  key, contents, arg; for every 
  59.    entry in the hashtable */
  60. extern void 
  61. maphash (maphash_function fn, c_hashtable hash, void* arg);
  62.  
  63. /* delete objects from the table which satisfy the predicate */
  64. extern void 
  65. map_remhash (remhash_predicate predicate, c_hashtable hash, void *arg);
  66.  
  67. /* copies all the entries of src into dest -- dest is modified as needed
  68.    so it is as big as src. */ 
  69. extern void copy_hash (c_hashtable dest, c_hashtable src);
  70.  
  71. #ifdef emacs    /* for elhash.c */
  72. extern unsigned int compute_harray_size (unsigned int);
  73. #endif
  74.  
  75. #endif /* _HASH_H_ */
  76.