59typedef int (*
set_cmp_fun) (
void const *elt,
void const *key,
size_t size);
97FIRM_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))
227typedef enum { _set_find, _set_insert, _set_hinsert, _set_hinsert0 } _set_action;
229FIRM_API
void *_set_search(
set *
set,
void const *key,
size_t size,
230 unsigned hash, _set_action action);
The entry of a set, representing an element in the set and its meta-information.
size_t size
the size of the element
unsigned hash
the hash value of the element
int dptr[1]
the element itself, data copied in must not need more alignment than this
set * new_set(set_cmp_fun func, size_t slots)
Creates a new set.
void del_set(set *set)
Deletes a set and all elements of it.
#define set_first(type, set)
Returns the first element of a set.
void * set_insert(set *set, void const *key, size_t size, unsigned hash)
Inserts an element into a set.
size_t set_count(set const *set)
Returns the number of elements in a set.
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.
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.
int(* set_cmp_fun)(void const *elt, void const *key, size_t size)
The type of a set compare function.
void set_break(set *set)
Breaks the iteration of a set.
struct set set
The abstract type of a set.
#define set_next(type, set)
Returns the next element of a set.
void * set_find(set *set, void const *key, size_t size, unsigned hash)
Searches an element in a set.