ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
stmm.h
Go to the documentation of this file.
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
12/* /projects/hsis/CVS/utilities/st/st.h,v 1.1 1993/07/29 01:00:21 serdar Exp */
13
14#ifndef ABC__misc__st__stmm_h
15#define ABC__misc__st__stmm_h
16
18
20
21
22/* These are potential duplicates. */
23#ifndef EXTERN
24# ifdef __cplusplus
25# ifdef ABC_NAMESPACE
26# define EXTERN extern
27# else
28# define EXTERN extern "C"
29# endif
30# else
31# define EXTERN extern
32# endif
33#endif
34
35#ifndef ARGS
36#define ARGS(protos) protos
37#endif
38
39typedef int (*stmm_compare_func_type)(const char*, const char*);
40typedef int (*stmm_hash_func_type)(const char*, int);
41
43typedef struct stmm_table stmm_table;
45
52
54{
63 // memory manager to improve runtime and prevent memory fragmentation
64 // added by alanmi - January 16, 2003
65 void * pMemMan;
66};
67
74
75#define stmm_is_member(table,key) stmm_lookup(table,key,(char **) 0)
76#define stmm_count(table) ((table)->num_entries)
77
80
81typedef enum stmm_retval (*STMM_PFSR) (char *, char *, char *);
82
84ARGS ((stmm_compare_func_type compare, stmm_hash_func_type hash, int size, int density, double grow_factor, int reorder_flag));
87EXTERN int stmm_lookup ARGS ((stmm_table *, char *, char **));
88EXTERN int stmm_lookup_int ARGS ((stmm_table *, char *, int *));
89EXTERN int stmm_insert ARGS ((stmm_table *, char *, char *));
90EXTERN int stmm_add_direct ARGS ((stmm_table *, char *, char *));
91EXTERN int stmm_find_or_add ARGS ((stmm_table *, char *, char ***));
92EXTERN int stmm_find ARGS ((stmm_table *, char *, char ***));
94EXTERN int stmm_delete ARGS ((stmm_table *, char **, char **));
95EXTERN int stmm_delete_int ARGS ((stmm_table *, long *, char **));
97EXTERN int stmm_strhash ARGS ((const char *, int));
98EXTERN int stmm_numhash ARGS ((const char *, int));
99EXTERN int stmm_ptrhash ARGS ((const char *, int));
100EXTERN int stmm_numcmp ARGS ((const char *, const char *));
101EXTERN int stmm_ptrcmp ARGS ((const char *, const char *));
103EXTERN int stmm_gen ARGS ((stmm_generator *, char **, char **));
104EXTERN int stmm_gen_int ARGS ((stmm_generator *, char **, long *));
106// additional functions
108
109
110
111#define STMM_DEFAULT_MAX_DENSITY 5
112#define STMM_DEFAULT_INIT_TABLE_SIZE 11
113#define STMM_DEFAULT_GROW_FACTOR 2.0
114#define STMM_DEFAULT_REORDER_FLAG 0
115
116// added by Zhihong: no need for memory allocation
117#define stmm_foreach_item2(tb, /* stmm_generator */gen, key, value) \
118 for(gen.table=(tb), gen.entry=NULL, gen.index=0; \
119 stmm_gen(&(gen),key,value);)
120
121#define stmm_foreach_item(table, gen, key, value) \
122 for(gen=stmm_init_gen(table); stmm_gen(gen,key,value) || (stmm_free_gen(gen),0);)
123
124#define stmm_foreach_item_int(table, gen, key, value) \
125 for(gen=stmm_init_gen(table); stmm_gen_int(gen,key,value) || (stmm_free_gen(gen),0);)
126
127#define STMM_OUT_OF_MEM -10000
128
129/*
130
131// consider adding these other other similar definitions
132#define st__table stmm_table
133#define st__insert stmm_insert
134#define st__delete stmm_delete
135#define st__lookup stmm_lookup
136#define st__init_table stmm_init_table
137#define st__free_table stmm_free_table
138
139*/
140
141
142
144
145
146
147#endif /* STMM_INCLUDED */
#define ABC_NAMESPACE_HEADER_END
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
#define EXTERN
Definition avl.h:17
int stmm_delete(stmm_table *table, char **keyp, char **value)
Definition stmm.c:430
int stmm_delete_int(stmm_table *table, long *keyp, char **value)
Definition stmm.c:456
int stmm_ptrhash(const char *x, int size)
Definition stmm.c:533
int stmm_insert(stmm_table *table, char *key, char *value)
Definition stmm.c:200
int stmm_find_or_add(stmm_table *table, char *key, char ***slot)
Definition stmm.c:266
int stmm_strhash(const char *string, int modulus)
Definition stmm.c:514
void stmm_free_gen(stmm_generator *gen)
Definition stmm.c:622
int stmm_gen_int(stmm_generator *gen, char **key_p, long *value_p)
Definition stmm.c:594
stmm_table * stmm_copy(stmm_table *old_table)
Definition stmm.c:374
int stmm_lookup_int(stmm_table *table, char *key, int *value)
Definition stmm.c:156
int stmm_numcmp(const char *x, const char *y)
Definition stmm.c:539
int stmm_ptrcmp(const char *x, const char *y)
Definition stmm.c:545
stmm_table * stmm_init_table_with_params(stmm_compare_func_type compare, stmm_hash_func_type hash, int size, int density, double grow_factor, int reorder_flag)
Definition stmm.c:35
int stmm_add_direct(stmm_table *table, char *key, char *value)
Definition stmm.c:238
void stmm_free_table(stmm_table *table)
Definition stmm.c:79
int stmm_foreach(stmm_table *table, enum stmm_retval(*func)(char *, char *, char *), char *arg)
Definition stmm.c:482
int stmm_find(stmm_table *table, char *key, char ***slot)
Definition stmm.c:306
void stmm_clean(stmm_table *table)
Definition stmm.c:105
stmm_table * stmm_init_table(stmm_compare_func_type compare, stmm_hash_func_type hash)
Definition stmm.c:69
int stmm_lookup(stmm_table *table, char *key, char **value)
Definition stmm.c:134
stmm_generator * stmm_init_gen(stmm_table *table)
Definition stmm.c:551
int stmm_numhash(const char *x, int size)
Definition stmm.c:527
int stmm_gen(stmm_generator *gen, char **key_p, char **value_p)
Definition stmm.c:567
int(* stmm_hash_func_type)(const char *, int)
Definition stmm.h:40
int(* stmm_compare_func_type)(const char *, const char *)
Definition stmm.h:39
stmm_retval
Definition stmm.h:79
@ STMM_CONTINUE
Definition stmm.h:79
@ STMM_DELETE
Definition stmm.h:79
@ STMM_STOP
Definition stmm.h:79
#define ARGS(protos)
Definition stmm.h:36
enum stmm_retval(* STMM_PFSR)(char *, char *, char *)
Definition stmm.h:81
int index
Definition stmm.h:72
stmm_table_entry * entry
Definition stmm.h:71
stmm_table * table
Definition stmm.h:70
Definition stmm.h:47
char * key
Definition stmm.h:48
char * record
Definition stmm.h:49
stmm_table_entry * next
Definition stmm.h:50
stmm_table_entry ** bins
Definition stmm.h:62
stmm_compare_func_type compare
Definition stmm.h:55
int num_entries
Definition stmm.h:58
void * pMemMan
Definition stmm.h:65
int reorder_flag
Definition stmm.h:60
double grow_factor
Definition stmm.h:61
int num_bins
Definition stmm.h:57
int max_density
Definition stmm.h:59
stmm_hash_func_type hash
Definition stmm.h:56