(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.
|
#define | pset_hinsert_ptr(set, key) pset_hinsert(set, key, hash_ptr(key)) |
| Inserts into pointer set with default hash function and return entry.
|
#define | pset_remove_ptr(set, key) pset_remove(set, key, hash_ptr(key)) |
| Removes pointer from pointer set with default hash function.
|
#define | pset_find_ptr(set, key) pset_find(set, key, hash_ptr(key)) |
| Finds pointer in pointer set with default hash function.
|
#define | pset_new_ptr(slots) new_pset(pset_default_ptr_cmp, slots) |
| Creates new pointer set with default compare function.
|
#define | pset_new_ptr_default() pset_new_ptr(64) |
| Creates new pointer set with default compare function and default size.
|
#define | pset_first(type, pset) ((type*)pset_first((pset))) |
| Returns the first element of a pset.
|
#define | pset_next(type, pset) ((type*)pset_next((pset))) |
| Returns the next element of a pset.
|
#define | foreach_pset(pset, type, entry) for (type *entry = pset_first(type, pset); entry; entry = pset_next(type, pset)) |
| Iterates oven an pset.
|
Typedefs |
typedef struct pset | pset |
| The abstract type of a pset (Set of pointers).
|
typedef int(* | pset_cmp_fun )(const void *elt, const void *key) |
| The type of a set compare function.
|
Functions |
int | pset_default_ptr_cmp (const void *x, const void *y) |
| The default comparison function for pointers.
|
pset * | new_pset (pset_cmp_fun func, size_t slots) |
| Creates a new pset.
|
void | del_pset (pset *pset) |
| Deletes a pset.
|
size_t | pset_count (pset *pset) |
| Returns the number of elements in a pset.
|
void * | pset_find (pset *pset, const void *key, unsigned hash) |
| Searches an element pointer in a pset.
|
void * | pset_insert (pset *pset, const void *key, unsigned hash) |
| Inserts an element pointer into a pset.
|
pset_entry * | pset_hinsert (pset *pset, const void *key, unsigned hash) |
| Inserts an element pointer into a pset and returns its pset_entry.
|
void * | pset_remove (pset *pset, const void *key, unsigned hash) |
| Removes an element from a pset.
|
void * | pset_first (pset *pset) |
| Returns the first element of a pset.
|
void * | pset_next (pset *pset) |
| Returns the next element of a pset.
|
void | pset_break (pset *pset) |
| Breaks the iteration of a set.
|
void | pset_insert_pset_ptr (pset *target, pset *src) |
| Inserts all elements of the pointer set src into the set target (union).
|
Detailed Description
(Hash)sets containing pointers.
- Note
- This code has been deprecated. Use pset_new or cpset for new code.
Macro Definition Documentation
Iterates oven an pset.
- Parameters
-
pset | the pset |
type | type of iterator variable |
entry | the iterator |
Definition at line 243 of file pset.h.
Finds pointer in pointer set with default hash function.
Definition at line 68 of file pset.h.
#define pset_first |
( |
|
type, |
|
|
|
pset |
|
) |
| ((type*)pset_first((pset))) |
Returns the first element of a pset.
This is a wrapper for pset_first(pmap <em>map); It allows to express the intended type of the set elements (instead of weakly typed void).
- Parameters
-
type | destination type of the pointers in the set |
pset | the pset to iterate |
- Returns
- a pointer to the element or NULL if the set is empty
Definition at line 202 of file pset.h.
Inserts into pointer set with default hash function and return entry.
Definition at line 64 of file pset.h.
Inserts into pointer set with default hash function.
Definition at line 62 of file pset.h.
Creates new pointer set with default compare function.
Definition at line 70 of file pset.h.
Creates new pointer set with default compare function and default size.
Definition at line 72 of file pset.h.
#define pset_next |
( |
|
type, |
|
|
|
pset |
|
) |
| ((type*)pset_next((pset))) |
Returns the next element of a pset.
This is a wrapper for pset_next(pmap <em>map); It allows to express the intended type of the set elements (instead of weakly typed void).
- Parameters
-
type | destination type of the pointers in the set |
pset | the pset to iterate |
- Returns
- a pointer to the next element or NULL if the iteration is finished
Definition at line 225 of file pset.h.
Removes pointer from pointer set with default hash function.
Definition at line 66 of file pset.h.
Typedef Documentation
The abstract type of a pset (Set of pointers).
This kind of sets stores only pointer to elements, the elements itself must be stored somewhere else.
- See Also
- set
Definition at line 59 of file pset.h.
typedef int(* pset_cmp_fun)(const void *elt, const void *key) |
The type of a set compare function.
- Parameters
-
elt | pointer to an element |
key | pointer to another element |
- Returns
- 0 if the elements are identically, non-zero else
Definition at line 89 of file pset.h.
Function Documentation
void del_pset |
( |
pset * |
pset | ) |
|
Deletes a pset.
- Parameters
-
- Note
- This does NOT delete the elements of this pset, just its pointers!
Creates a new pset.
- Parameters
-
func | The compare function of this pset. |
slots | Initial number of collision chains. I.e., #slots different keys can be hashed without collisions. |
- Returns
- created pset
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.
- Parameters
-
size_t pset_count |
( |
pset * |
pset | ) |
|
Returns the number of elements in a pset.
- Parameters
-
int pset_default_ptr_cmp |
( |
const void * |
x, |
|
|
const void * |
y |
|
) |
| |
The default comparison function for pointers.
- Parameters
-
- Returns
- 0 if
x
and y
are equal. Some value != 0 otherwise.
void* pset_find |
( |
pset * |
pset, |
|
|
const void * |
key, |
|
|
unsigned |
hash |
|
) |
| |
Searches an element pointer in a pset.
- Parameters
-
pset | the pset to search in |
key | the element to search |
hash | the hash value of key |
- Returns
- the pointer of the found element in the pset or NULL if it was not found
void* pset_first |
( |
pset * |
pset | ) |
|
Returns the first element of a pset.
- Parameters
-
- Returns
- a pointer to the element or NULL if the set is empty
pset_entry* pset_hinsert |
( |
pset * |
pset, |
|
|
const void * |
key, |
|
|
unsigned |
hash |
|
) |
| |
Inserts an element pointer into a pset and returns its pset_entry.
- Parameters
-
pset | the pset to insert in |
key | a pointer to the element to be inserted |
hash | the hash-value of the element |
- Returns
- a pointer to the pset_entry of the inserted element
- Note
- It is not possible to insert an element more than once. If an element that should be inserted is already in the pset, this functions does nothing but returning its pset_entry.
void* pset_insert |
( |
pset * |
pset, |
|
|
const void * |
key, |
|
|
unsigned |
hash |
|
) |
| |
Inserts an element pointer into a pset.
- Parameters
-
pset | the pset to insert in |
key | a pointer to the element to be inserted |
hash | the hash-value of the element |
- Returns
- a pointer to the inserted element
- Note
- It is not possible to insert an element more than once. If an element that should be inserted is already in the set, this functions does nothing but returning its already existing set_entry.
void pset_insert_pset_ptr |
( |
pset * |
target, |
|
|
pset * |
src |
|
) |
| |
Inserts all elements of the pointer set src into the set target (union).
- Parameters
-
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.
- Parameters
-
- Returns
- a pointer to the next element or NULL if the iteration is finished
void* pset_remove |
( |
pset * |
pset, |
|
|
const void * |
key, |
|
|
unsigned |
hash |
|
) |
| |
Removes an element from a pset.
- Parameters
-
pset | the pset to delete in |
key | a pointer to the element to be deleted |
hash | the hash-value of the element |
- Returns
- the pointer to the removed element