X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=include%2Flibfirm%2Fadt%2Fpset.h;h=11d740ca1393cf039deb9930166812942c7b09f0;hb=8b9cffd15955b08311c41c37cd06acd7db3bd7f4;hp=29d8c14c3f3b458a46398dadf8acd29286dfca3a;hpb=d217f68a9e53ec6e800ae31ca3af8ed8b6f9ece9;p=libfirm diff --git a/include/libfirm/adt/pset.h b/include/libfirm/adt/pset.h index 29d8c14c3..11d740ca1 100644 --- a/include/libfirm/adt/pset.h +++ b/include/libfirm/adt/pset.h @@ -189,6 +189,18 @@ FIRM_API void *pset_remove(pset *pset, const void *key, unsigned hash); */ FIRM_API void *pset_first(pset *pset); +/** + * Returns the first element of a pset. + * This is a wrapper for pset_first(pmap *map); It allows to express the + * intended type of the set elements (instead of weakly typed void*). + * + * @param type destination type of the pointers in the set + * @param pset the pset to iterate + * + * @return a pointer to the element or NULL if the set is empty + */ +#define pset_first(type, pset) ((type*)pset_first((pset))) + /** * Returns the next element of a pset. * @@ -199,6 +211,19 @@ FIRM_API void *pset_first(pset *pset); */ FIRM_API void *pset_next(pset *pset); +/** + * Returns the next element of a pset. + * This is a wrapper for pset_next(pmap *map); It allows to express the + * intended type of the set elements (instead of weakly typed void*). + * + * @param type destination type of the pointers in the set + * @param pset the pset to iterate + * + * @return a pointer to the next element or NULL if the + * iteration is finished + */ +#define pset_next(type, pset) ((type*)pset_next((pset))) + /** * Breaks the iteration of a set. Must be called before * the next pset_first() call if the iteration was NOT @@ -215,7 +240,7 @@ FIRM_API void pset_break(pset *pset); * @param type type of iterator variable * @param entry the iterator */ -#define foreach_pset(pset, type, entry) for (entry = (type)pset_first(pset); entry; entry = (type)pset_next(pset)) +#define foreach_pset(pset, type, entry) for (type *entry = pset_first(type, pset); entry; entry = pset_next(type, pset)) /** * Inserts all elements of the pointer set src into