st.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* $Header$ */
  2. #ifndef ST_INCLUDED
  3. #define ST_INCLUDED
  4. typedef struct st_table_entry st_table_entry;
  5. struct st_table_entry {
  6. char *key;
  7. char *record;
  8. st_table_entry *next;
  9. };
  10. typedef struct st_table st_table;
  11. struct st_table {
  12. int (*compare)();
  13. int (*hash)();
  14. int num_bins;
  15. int num_entries;
  16. int max_density;
  17. int reorder_flag;
  18. double grow_factor;
  19. st_table_entry **bins;
  20. };
  21. #define st_is_member(table,key) st_lookup(table,key,(char **) 0)
  22. enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE};
  23. int st_delete(), st_insert(), st_foreach(), st_free_table();
  24. int st_lookup(), st_find_or_add(), st_add_direct();
  25. st_table *st_init_table(), *st_init_table_with_params();
  26. #define ST_NUMCMP ((int (*)()) 0)
  27. #define ST_NUMHASH ((int (*)()) -2)
  28. #define ST_PTRCMP ((int (*)()) 0)
  29. #define ST_PTRHASH ((int (*)()) -1)
  30. #define st_numcmp ST_NUMCMP
  31. #define st_numhash ST_NUMHASH
  32. #define st_ptrcmp ST_PTRCMP
  33. #define st_ptrhash ST_PTRHASH
  34. #define ST_DEFAULT_MAX_DENSITY 5
  35. #define ST_DEFAULT_INIT_TABLE_SIZE 11
  36. #define ST_DEFAULT_GROW_FACTOR 2.0
  37. #define ST_DEFAULT_REORDER_FLAG 0
  38. int st_strhash();
  39. #endif ST_INCLUDED