libFirm 1.20
|
Generic Hashset. More...
Data Structures | |
struct | set_entry |
The entry of a set, representing an element in the set and its meta-information. More... | |
Defines | |
#define | foreach_set(set, type, entry) for (entry = (type) set_first(set); entry; entry = (type) set_next(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.
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 |