st.h 3.35 KB
Newer Older
Alan Mishchenko committed
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
 * Revision Control Information
 *
 * /projects/hsis/CVS/utilities/st/st.h,v
 * serdar
 * 1.1
 * 1993/07/29 01:00:21
 *
 */
/* LINTLIBRARY */

/* /projects/hsis/CVS/utilities/st/st.h,v 1.1 1993/07/29 01:00:21 serdar Exp */

14 15
#ifndef ABC__misc__st__st_h
#define ABC__misc__st__st_h
16
#define st__INCLUDED
Alan Mishchenko committed
17

18
#include "misc/util/abc_global.h"
19 20 21

ABC_NAMESPACE_HEADER_START

22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

/* These are potential duplicates. */
#ifndef EXTERN
#   ifdef __cplusplus
#       ifdef ABC_NAMESPACE
#           define EXTERN extern
#       else
#           define EXTERN extern "C"
#       endif
#   else
#       define EXTERN extern
#   endif
#endif

#ifndef ARGS
#define ARGS(protos) protos
#endif


41 42
typedef int (* st__compare_func_type)(const char*, const char*);
typedef int (* st__hash_func_type)(const char*, int);
Alan Mishchenko committed
43

44 45
typedef struct st__table_entry st__table_entry;
struct st__table_entry {
46
    char *key;
Alan Mishchenko committed
47
    char *record;
48
    st__table_entry *next;
Alan Mishchenko committed
49 50
};

51 52 53 54
typedef struct st__table st__table;
struct st__table {
    st__compare_func_type compare;
    st__hash_func_type hash;
Alan Mishchenko committed
55 56 57 58 59
    int num_bins;
    int num_entries;
    int max_density;
    int reorder_flag;
    double grow_factor;
60
    st__table_entry **bins;
Alan Mishchenko committed
61 62
};

63 64 65 66
typedef struct st__generator st__generator;
struct st__generator {
    st__table *table;
    st__table_entry *entry;
Alan Mishchenko committed
67 68 69
    int index;
};

70 71
#define st__is_member(table,key) st__lookup(table,key,(char **) 0)
#define st__count(table) ((table)->num_entries)
Alan Mishchenko committed
72

73
enum st__retval { st__CONTINUE, st__STOP, st__DELETE};
Alan Mishchenko committed
74

75 76
typedef enum st__retval (* st__PFSR)(char *, char *, char *);
typedef int (* st__PFI)();
Alan Mishchenko committed
77

78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
extern st__table * st__init_table_with_params ( st__compare_func_type compare, st__hash_func_type hash, int size, int density, double grow_factor, int reorder_flag);
extern st__table * st__init_table ( st__compare_func_type, st__hash_func_type);
extern void st__free_table ( st__table *);
extern int st__lookup ( st__table *, const char *, char **);
extern int st__lookup_int ( st__table *, char *, int *);
extern int st__insert ( st__table *, const char *, char *);
extern int st__add_direct ( st__table *, char *, char *);
extern int st__find_or_add ( st__table *, char *, char ***);
extern int st__find ( st__table *, char *, char ***);
extern st__table * st__copy ( st__table *);
extern int st__delete ( st__table *, const char **, char **);
extern int st__delete_int ( st__table *, long *, char **);
extern int st__foreach ( st__table *, st__PFSR, char *);
extern int st__strhash (const char *, int);
extern int st__numhash (const char *, int);
extern int st__ptrhash (const char *, int);
extern int st__numcmp (const char *, const char *);
extern int st__ptrcmp (const char *, const char *);
extern st__generator * st__init_gen ( st__table *);
extern int st__gen ( st__generator *, const char **, char **);
extern int st__gen_int ( st__generator *, const char **, long *);
extern void st__free_gen ( st__generator *);
Alan Mishchenko committed
100 101


102 103 104 105
#define st__DEFAULT_MAX_DENSITY 5
#define st__DEFAULT_INIT_TABLE_SIZE 11
#define st__DEFAULT_GROW_FACTOR 2.0
#define st__DEFAULT_REORDER_FLAG 0
Alan Mishchenko committed
106

107 108
#define st__foreach_item(table, gen, key, value) \
    for(gen= st__init_gen(table); st__gen(gen,key,value) || ( st__free_gen(gen),0);)
Alan Mishchenko committed
109

110 111
#define st__foreach_item_int(table, gen, key, value) \
    for(gen= st__init_gen(table); st__gen_int(gen,key,value) || ( st__free_gen(gen),0);)
Alan Mishchenko committed
112

113
#define st__OUT_OF_MEM -10000
Alan Mishchenko committed
114

115 116 117 118 119


ABC_NAMESPACE_HEADER_END


Alan Mishchenko committed
120

121
#endif /* st__INCLUDED */