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. More... | |
#define | set_next(type, set) ((type*)set_next((set))) |
Returns the next element of a set. More... | |
#define | foreach_set(set, type, entry) for (type *entry = set_first(type, set); entry; entry = set_next(type, set)) |
Iterates over an set. More... | |
Typedefs | |
typedef struct set | set |
The abstract type of a set. More... | |
typedef int(* | set_cmp_fun) (void const *elt, void const *key, size_t size) |
The type of a set compare function. More... | |
Functions | |
set * | new_set (set_cmp_fun func, size_t slots) |
Creates a new set. More... | |
void | del_set (set *set) |
Deletes a set and all elements of it. More... | |
size_t | set_count (set const *set) |
Returns the number of elements in a set. More... | |
void * | set_find (set *set, void const *key, size_t size, unsigned hash) |
Searches an element in a set. More... | |
void * | set_insert (set *set, void const *key, size_t size, unsigned hash) |
Inserts an element into a set. More... | |
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. More... | |
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. More... | |
void * | set_first (set *set) |
Returns the first element of a set. More... | |
void * | set_next (set *set) |
Returns the next element of a set. More... | |
void | set_break (set *set) |
Breaks the iteration of a set. More... | |
Generic Hashset.
struct set_entry |
Returns the first element of a set.
This is a wrapper for set_first(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); 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) (void const *elt, void const *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 const * | set | ) |
Returns the number of elements in a set.
set | the set |
void* set_find | ( | set * | set, |
void const * | 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, |
void const * | 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 |