You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
2.8 KiB

  1. /*
  2. * Revision Control Information
  3. *
  4. * /projects/hsis/CVS/utilities/st/st.h,v
  5. * serdar
  6. * 1.1
  7. * 1993/07/29 01:00:21
  8. *
  9. */
  10. /* LINTLIBRARY */
  11. /* /projects/hsis/CVS/utilities/st/st.h,v 1.1 1993/07/29 01:00:21 serdar Exp */
  12. #ifndef ST_INCLUDED
  13. #define ST_INCLUDED
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. typedef struct st_table_entry st_table_entry;
  18. struct st_table_entry {
  19. char *key;
  20. char *record;
  21. st_table_entry *next;
  22. };
  23. typedef struct st_table st_table;
  24. struct st_table {
  25. int (*compare)(const char *, const char *);
  26. int (*hash)(char *, int);
  27. int num_bins;
  28. int num_entries;
  29. int max_density;
  30. int reorder_flag;
  31. double grow_factor;
  32. st_table_entry **bins;
  33. };
  34. typedef struct st_generator st_generator;
  35. struct st_generator {
  36. st_table *table;
  37. st_table_entry *entry;
  38. int index;
  39. };
  40. #define st_is_member(table,key) st_lookup(table,key,(char **) 0)
  41. #define st_count(table) ((table)->num_entries)
  42. enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE};
  43. typedef enum st_retval (*ST_PFSR)(char *, char *, char *);
  44. typedef int (*ST_PFICPCP)(const char *, const char *); /* type for comparison function */
  45. typedef int (*ST_PFICPI)(char *, int); /* type for hash function */
  46. extern st_table *st_init_table_with_params (ST_PFICPCP, ST_PFICPI, int, int, double, int);
  47. extern st_table *st_init_table (ST_PFICPCP, ST_PFICPI);
  48. extern void st_free_table (st_table *);
  49. extern int st_lookup (st_table *, char *, char **);
  50. extern int st_lookup_int (st_table *, char *, int *);
  51. extern int st_insert (st_table *, char *, char *);
  52. extern int st_add_direct (st_table *, char *, char *);
  53. extern int st_find_or_add (st_table *, char *, char ***);
  54. extern int st_find (st_table *, char *, char ***);
  55. extern st_table *st_copy (st_table *);
  56. extern int st_delete (st_table *, char **, char **);
  57. extern int st_delete_int (st_table *, int *, char **);
  58. extern int st_foreach (st_table *, ST_PFSR, char *);
  59. extern int st_strhash (char *, int);
  60. extern int st_numhash (char *, int);
  61. extern int st_ptrhash (char *, int);
  62. extern int st_numcmp (const char *, const char *);
  63. extern int st_ptrcmp (const char *, const char *);
  64. extern st_generator *st_init_gen (st_table *);
  65. extern int st_gen (st_generator *, char **, char **);
  66. extern int st_gen_int (st_generator *, char **, long *);
  67. extern void st_free_gen (st_generator *);
  68. #define ST_DEFAULT_MAX_DENSITY 5
  69. #define ST_DEFAULT_INIT_TABLE_SIZE 11
  70. #define ST_DEFAULT_GROW_FACTOR 2.0
  71. #define ST_DEFAULT_REORDER_FLAG 0
  72. #define st_foreach_item(table, gen, key, value) \
  73. for(gen=st_init_gen(table); st_gen(gen,key,value) || (st_free_gen(gen),0);)
  74. #define st_foreach_item_int(table, gen, key, value) \
  75. for(gen=st_init_gen(table); st_gen_int(gen,key,value) || (st_free_gen(gen),0);)
  76. #define ST_OUT_OF_MEM -10000
  77. #ifdef __cplusplus
  78. }
  79. #endif
  80. #endif /* ST_INCLUDED */