12 #ifndef FIRM_ADT_PSET_H 13 #define FIRM_ADT_PSET_H 48 #define pset_insert_ptr(set,key) pset_insert(set, key, hash_ptr(key)) 50 #define pset_hinsert_ptr(set,key) pset_hinsert(set, key, hash_ptr(key)) 52 #define pset_remove_ptr(set,key) pset_remove(set, key, hash_ptr(key)) 54 #define pset_find_ptr(set,key) pset_find(set, key, hash_ptr(key)) 56 #define pset_new_ptr(slots) new_pset(pset_default_ptr_cmp, slots) 58 #define pset_new_ptr_default() pset_new_ptr(64) 186 #define pset_first(type, pset) ((type*)pset_first((pset))) 209 #define pset_next(type, pset) ((type*)pset_next((pset))) 227 #define foreach_pset(pset, type, entry) for (type *entry = pset_first(type, pset); entry; entry = pset_next(type, pset)) 240 #define new_pset(cmp, slots) ((new_pset) ((cmp), (slots))) 241 #define pset_find(pset, key, hash) \ 242 _pset_search ((pset), (key), (hash), _pset_find) 243 #define pset_insert(pset, key, hash) \ 244 _pset_search ((pset), (key), (hash), _pset_insert) 245 #define pset_hinsert(pset, key, hash) \ 246 ((pset_entry *)_pset_search ((pset), (key), (hash), _pset_hinsert)) 248 typedef enum { _pset_find, _pset_insert, _pset_hinsert } _pset_action;
250 FIRM_API
void *_pset_search(
pset *
set,
void const *key,
unsigned hash,
251 _pset_action action);
int(* pset_cmp_fun)(void const *elt, void const *key)
The type of a set compare function.
#define pset_first(type, pset)
Returns the first element of a pset.
void del_pset(pset *pset)
Deletes a pset.
void * pset_find(pset *pset, void const *key, unsigned hash)
Searches an element pointer in a pset.
unsigned hash
hash value of element
void * pset_remove(pset *pset, void const *key, unsigned hash)
Removes an element from a pset.
struct pset pset
The abstract type of a pset (Set of pointers).
int pset_default_ptr_cmp(void const *x, void const *y)
The default comparison function for pointers.
pset * new_pset(pset_cmp_fun func, size_t slots)
Creates a new pset.
size_t pset_count(pset const *pset)
Returns the number of elements in a pset.
void pset_break(pset *pset)
Breaks the iteration of a set.
void pset_insert_pset_ptr(pset *target, pset *src)
Inserts all elements of the pointer set src into the set target (union).
void * pset_insert(pset *pset, void const *key, unsigned hash)
Inserts an element pointer into a pset.
The entry of a pset, representing an element pointer in the set and its meta-information.
pset_entry * pset_hinsert(pset *pset, void const *key, unsigned hash)
Inserts an element pointer into a pset and returns its pset_entry.
void * dptr
pointer to element data
#define pset_next(type, pset)
Returns the next element of a pset.