4 * @brief A hashset that contains pointers
5 * @author Matthias Braun
6 * @version $Id: pset_new.h 169 2007-04-03 01:01:09Z uxsm $
8 * NOTE: This has been named pset_new_new for now until all code has been changed
9 * to use this instead of the old deprecated pset_new functions!
11 #ifndef _FIRM_PSET_NEW_H_
12 #define _FIRM_PSET_NEW_H_
14 #define HashSet pset_new_t
15 #define HashSetIterator pset_new_iterator_t
16 #define ValueType void*
21 #undef HashSetIterator
25 * Initializes a pset_new
27 * @param pset_new Pointer to allocated space for the pset_new
29 void pset_new_init(pset_new_t *pset_new);
32 * Initializes a pset_new
34 * @param pset_new Pointer to allocated space for the pset_new
35 * @param expected_elements Number of elements expected in the pset_new (rougly)
37 void pset_new_init_size(pset_new_t *pset_new, size_t expected_elements);
40 * Destroys a pset_new and frees the memory allocated for hashtable. The memory of
41 * the pset_new itself is not freed.
43 * @param pset_new Pointer to the pset_new
45 void pset_new_destroy(pset_new_t *pset_new);
48 * Inserts an element into a pset_new.
50 * @param pset_new Pointer to the pset_new
51 * @param ptr Pointer to insert into the pset_new
52 * @returns 1 if the pointer was inserted, 0 if it was already there
54 int pset_new_insert(pset_new_t *pset_new, void *ptr);
57 * Removes an element from a pset_new. Does nothing if the pset_new doesn't contain the
60 * @param pset_new Pointer to the pset_new
61 * @param ptr Pointer to remove from the pset_new
63 void pset_new_remove(pset_new_t *pset_new, const void *ptr);
66 * Tests whether a pset_new contains a pointer
68 * @param pset_new Pointer to the pset_new
69 * @param ptr The pointer to test
70 * @returns 1 @p pset_new contains the @p ptr, 0 otherwise
72 int pset_new_contains(const pset_new_t *pset_new, const void *ptr);
75 * Returns the number of pointers contained in the pset_new
77 * @param pset_new Pointer to the pset_new
78 * @returns Number of pointers contained in the pset_new
80 size_t pset_new_size(const pset_new_t *pset_new);
83 * Initializes a pset_new iterator. Sets the iterator before the first element in
86 * @param iterator Pointer to already allocated iterator memory
87 * @param pset_new Pointer to the pset_new
89 void pset_new_iterator_init(pset_new_iterator_t *iterator, const pset_new_t *pset_new);
92 * Advances the iterator and returns the current element or NULL if all elements
93 * in the pset_new have been processed.
94 * @attention It is not allowed to use pset_new_insert or pset_new_remove while
95 * iterating over a pset_new; pset_new_remove_iter is allowed.
97 * @param iterator Pointer to the pset_new iterator.
98 * @returns Next element in the pset_new or NULL
100 void* pset_new_iterator_next(pset_new_iterator_t *iterator);
103 * Removes the element that the iterator currently points to from the hashset.
105 * @param pset_new Pointer to the pset_new
106 * @param iterator Pointer to the iterator
108 void pset_new_remove_iterator(pset_new_t *pset_new, const pset_new_iterator_t *iterator);