![]() |
libFirm
|
(Hash)sets containing pointers. More...
Data Structures | |
| struct | pset_entry |
| The entry of a pset, representing an element pointer in the set and its meta-information. More... | |
Macros | |
| #define | pset_insert_ptr(set, key) pset_insert(set, key, hash_ptr(key)) |
| Inserts into pointer set with default hash function. More... | |
| #define | pset_hinsert_ptr(set, key) pset_hinsert(set, key, hash_ptr(key)) |
| Inserts into pointer set with default hash function and return entry. More... | |
| #define | pset_remove_ptr(set, key) pset_remove(set, key, hash_ptr(key)) |
| Removes pointer from pointer set with default hash function. More... | |
| #define | pset_find_ptr(set, key) pset_find(set, key, hash_ptr(key)) |
| Finds pointer in pointer set with default hash function. More... | |
| #define | pset_new_ptr(slots) new_pset(pset_default_ptr_cmp, slots) |
| Creates new pointer set with default compare function. More... | |
| #define | pset_new_ptr_default() pset_new_ptr(64) |
| Creates new pointer set with default compare function and default size. More... | |
| #define | pset_first(type, pset) ((type*)pset_first((pset))) |
| Returns the first element of a pset. More... | |
| #define | pset_next(type, pset) ((type*)pset_next((pset))) |
| Returns the next element of a pset. More... | |
| #define | foreach_pset(pset, type, entry) for (type *entry = pset_first(type, pset); entry; entry = pset_next(type, pset)) |
| Iterates over a pset. More... | |
Typedefs | |
| typedef struct pset | pset |
| The abstract type of a pset (Set of pointers). More... | |
| typedef int(* | pset_cmp_fun )(void const *elt, void const *key) |
| The type of a set compare function. More... | |
Functions | |
| int | pset_default_ptr_cmp (void const *x, void const *y) |
| The default comparison function for pointers. More... | |
| pset * | new_pset (pset_cmp_fun func, size_t slots) |
| Creates a new pset. More... | |
| void | del_pset (pset *pset) |
| Deletes a pset. More... | |
| size_t | pset_count (pset const *pset) |
| Returns the number of elements in a pset. More... | |
| void * | pset_find (pset *pset, void const *key, unsigned hash) |
| Searches an element pointer in a pset. More... | |
| void * | pset_insert (pset *pset, void const *key, unsigned hash) |
| Inserts an element pointer into a pset. More... | |
| pset_entry * | pset_hinsert (pset *pset, void const *key, unsigned hash) |
| Inserts an element pointer into a pset and returns its pset_entry. More... | |
| void * | pset_remove (pset *pset, void const *key, unsigned hash) |
| Removes an element from a pset. More... | |
| void * | pset_first (pset *pset) |
| Returns the first element of a pset. More... | |
| void * | pset_next (pset *pset) |
| Returns the next element of a pset. More... | |
| void | pset_break (pset *pset) |
| Breaks the iteration of a set. More... | |
| void | pset_insert_pset_ptr (pset *target, pset *src) |
| Inserts all elements of the pointer set src into the set target (union). More... | |
(Hash)sets containing pointers.
| struct pset_entry |
| #define foreach_pset | ( | pset, | |
| type, | |||
| entry | |||
| ) | for (type *entry = pset_first(type, pset); entry; entry = pset_next(type, pset)) |
Returns the first element of a pset.
This is a wrapper for pset_first(set); It allows to express the intended type of the set elements (instead of weakly typed void*).
| type | destination type of the pointers in the set |
| pset | the pset to iterate |
| #define pset_hinsert_ptr | ( | set, | |
| key | |||
| ) | pset_hinsert(set, key, hash_ptr(key)) |
| #define pset_insert_ptr | ( | set, | |
| key | |||
| ) | pset_insert(set, key, hash_ptr(key)) |
| #define pset_new_ptr | ( | slots | ) | new_pset(pset_default_ptr_cmp, slots) |
| #define pset_new_ptr_default | ( | ) | pset_new_ptr(64) |
Returns the next element of a pset.
This is a wrapper for pset_next(set); It allows to express the intended type of the set elements (instead of weakly typed void*).
| type | destination type of the pointers in the set |
| pset | the pset to iterate |
| #define pset_remove_ptr | ( | set, | |
| key | |||
| ) | pset_remove(set, key, hash_ptr(key)) |
| typedef int(* pset_cmp_fun)(void const *elt, void const *key) |
| void del_pset | ( | pset * | pset | ) |
Deletes a pset.
| pset | the pset |
| pset* new_pset | ( | pset_cmp_fun | func, |
| size_t | slots | ||
| ) |
Creates a new pset.
| func | The compare function of this pset. |
| slots | Initial number of collision chains. I.e., #slots different keys can be hashed without collisions. |
| void pset_break | ( | pset * | pset | ) |
Breaks the iteration of a set.
Must be called before the next pset_first() call if the iteration was NOT finished.
| pset | the pset |
| size_t pset_count | ( | pset const * | pset | ) |
Returns the number of elements in a pset.
| pset | the pset |
| int pset_default_ptr_cmp | ( | void const * | x, |
| void const * | y | ||
| ) |
The default comparison function for pointers.
| x | A pointer. |
| y | A pointer. |
x and y are equal. Some value != 0 otherwise. | void* pset_find | ( | pset * | pset, |
| void const * | key, | ||
| unsigned | hash | ||
| ) |
Searches an element pointer in a pset.
| pset | the pset to search in |
| key | the element to search |
| hash | the hash value of key |
| void* pset_first | ( | pset * | pset | ) |
Returns the first element of a pset.
| pset | the pset to iterate |
| pset_entry* pset_hinsert | ( | pset * | pset, |
| void const * | key, | ||
| unsigned | hash | ||
| ) |
Inserts an element pointer into a pset and returns its pset_entry.
| pset | the pset to insert in |
| key | a pointer to the element to be inserted |
| hash | the hash-value of the element |
| void* pset_insert | ( | pset * | pset, |
| void const * | key, | ||
| unsigned | hash | ||
| ) |
Inserts an element pointer into a pset.
| pset | the pset to insert in |
| key | a pointer to the element to be inserted |
| hash | the hash-value of the element |
Inserts all elements of the pointer set src into the set target (union).
| target | the target set, will contain the union |
| src | a set, will not be changed |
| void* pset_next | ( | pset * | pset | ) |
Returns the next element of a pset.
| pset | the pset to iterate |
| void* pset_remove | ( | pset * | pset, |
| void const * | key, | ||
| unsigned | hash | ||
| ) |
Removes an element from a pset.
| pset | the pset to delete in |
| key | a pointer to the element to be deleted |
| hash | the hash-value of the element |