11 #ifndef FIRM_ADT_SET_H 12 #define FIRM_ADT_SET_H 78 FIRM_API
void del_set(
set *
set);
85 FIRM_API
size_t set_count(
set const *
set);
97 FIRM_API
void *
set_find(
set *
set,
void const *key,
size_t size,
unsigned hash);
171 #define set_first(type, set) ((type*)set_first((set))) 194 #define set_next(type, set) ((type*)set_next((set))) 212 #define foreach_set(set, type, entry) for (type *entry = set_first(type, set); entry; entry = set_next(type, set)) 217 #define new_set(cmp, slots) ((new_set) ((cmp), (slots))) 218 #define set_find(type, set, key, size, hash) \ 219 ((type*)_set_search((set), 1 ? (key) : (type*)0 , (size), (hash), _set_find)) 220 #define set_insert(type, set, key, size, hash) \ 221 ((type*)_set_search((set), 1 ? (key) : (type*)0 , (size), (hash), _set_insert)) 222 #define set_hinsert(set, key, size, hash) \ 223 ((set_entry *)_set_search ((set), (key), (size), (hash), _set_hinsert)) 224 #define set_hinsert0(set, key, size, hash) \ 225 ((set_entry *)_set_search ((set), (key), (size), (hash), _set_hinsert0)) 227 typedef enum { _set_find, _set_insert, _set_hinsert, _set_hinsert0 } _set_action;
229 FIRM_API
void *_set_search(
set *
set,
void const *key,
size_t size,
230 unsigned hash, _set_action action);
unsigned hash
the hash value of the element
#define set_next(type, set)
Returns the next element of a set.
size_t set_count(set const *set)
Returns the number of elements in a set.
set_entry * set_hinsert(set *set, void const *key, size_t size, unsigned hash)
Inserts an element into a set and returns its set_entry.
void del_set(set *set)
Deletes a set and all elements of it.
The entry of a set, representing an element in the set and its meta-information.
void * set_insert(set *set, void const *key, size_t size, unsigned hash)
Inserts an element into a set.
#define set_first(type, set)
Returns the first element of a set.
void set_break(set *set)
Breaks the iteration of a set.
struct set set
The abstract type of a set.
set * new_set(set_cmp_fun func, size_t slots)
Creates a new set.
void * set_find(set *set, void const *key, size_t size, unsigned hash)
Searches an element in a set.
size_t size
the size of the element
int(* set_cmp_fun)(void const *elt, void const *key, size_t size)
The type of a set compare function.
set_entry * set_hinsert0(set *set, void const *key, size_t size, unsigned hash)
Inserts an element into a set, zero-terminate it and returns its set_entry.
int dptr[1]
the element itself, data copied in must not need more alignment than this