libFirm
|
Generic Hashset. More...
Data Structures | |
struct | set_entry |
The entry of a set, representing an element in the set and its meta-information. More... |
Macros | |
#define | set_first(type, set) ((type*)set_first((set))) |
Returns the first element of a set. | |
#define | set_next(type, set) ((type*)set_next((set))) |
Returns the next element of a set. | |
#define | foreach_set(set, type, entry) for (type *entry = set_first(type, set); entry; entry = set_next(type, set)) |
Iterates over an set. |
Typedefs | |
typedef struct set | set |
The abstract type of a set. | |
typedef int(* | set_cmp_fun )(const void *elt, const void *key, size_t size) |
The type of a set compare function. |
Functions | |
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. | |
size_t | set_count (set *set) |
Returns the number of elements in a set. | |
void * | set_find (set *set, const void *key, size_t size, unsigned hash) |
Searches an element in a set. | |
void * | set_insert (set *set, const void *key, size_t size, unsigned hash) |
Inserts an element into a set. | |
set_entry * | set_hinsert (set *set, const void *key, size_t size, unsigned hash) |
Inserts an element into a set and returns its set_entry. | |
set_entry * | set_hinsert0 (set *set, const void *key, size_t size, unsigned hash) |
Inserts an element into a set, zero-terminate it and returns its set_entry. | |
void * | set_first (set *set) |
Returns the first element of a set. | |
void * | set_next (set *set) |
Returns the next element of a set. | |
void | set_break (set *set) |
Breaks the iteration of a set. |
Generic Hashset.
Returns the first element of a set.
This is a wrapper for set_first(set <em>set); It allows to express the intended type of the set elements (instead of weakly typed void).
set | the set to iterate |
type | type of the set elements |
Returns the next element of a set.
This is a wrapper for set_next(set <em>set); It allows to express the intended type of the set elements (instead of weakly typed void).
set | the set to iterate |
type | type of the set elements |
typedef int(* set_cmp_fun)(const void *elt, const void *key, size_t size) |
The type of a set compare function.
elt | pointer to an element |
key | pointer to another element |
size | size of the elements |
void del_set | ( | set * | set | ) |
Deletes a set and all elements of it.
set | the set to delete |
set* new_set | ( | set_cmp_fun | func, |
size_t | slots | ||
) |
Creates a new set.
func | The compare function of this set. |
slots | Initial number of collision chains. I.e., #slots different keys can be hashed without collisions. |
void set_break | ( | set * | set | ) |
Breaks the iteration of a set.
Must be called before the next set_first() call if the iteration was NOT finished.
set | the set |
size_t set_count | ( | set * | set | ) |
Returns the number of elements in a set.
set | the set |
void* set_find | ( | set * | set, |
const void * | key, | ||
size_t | size, | ||
unsigned | hash | ||
) |
Searches an element in a set.
set | the set to search in |
key | the element to is searched |
size | the size of key |
hash | the hash value of key |
void* set_first | ( | set * | set | ) |
Returns the first element of a set.
set | the set to iterate |
Inserts an element into a set and returns its set_entry.
set | the set to insert in |
key | a pointer to the element to be inserted. Element is copied! |
size | the size of the element that should be inserted |
hash | the hash-value of the element |
Inserts an element into a set, zero-terminate it and returns its set_entry.
set | the set to insert in |
key | a pointer to the element to be inserted. Element is copied! |
size | the size of the element that should be inserted |
hash | the hash-value of the element |
void* set_insert | ( | set * | set, |
const void * | key, | ||
size_t | size, | ||
unsigned | hash | ||
) |
Inserts an element into a set.
set | the set to insert in |
key | a pointer to the element to be inserted. Element is copied! |
size | the size of the element that should be inserted |
hash | the hash-value of the element |
void* set_next | ( | set * | set | ) |
Returns the next element of a set.
set | the set to iterate |