3 * File name: ir/adt/eset.h
4 * Purpose: Datentyp: Vereinfachte Menge (hash-set) zum Speichern von
6 * Author: Hubert Schmid
10 * Copyright: (c) 2002 Universität Karlsruhe
11 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
17 * "eset" is a set of addresses. The addresses are used for element
18 * compare and hash calculation.
19 * The value "NULL" can not be stored, as it is used as internal sentinel.
21 typedef struct eset eset;
23 /** Creates a new empty set. */
24 eset *eset_create(void);
27 * Creates a copy of the given set. Does NOT work if NULL is contained in source. */
28 eset *eset_copy(eset *source);
31 void eset_destroy(eset *s);
33 /** Returns the number of elements in the set. */
34 int eset_count(eset *s);
36 /** Inserts an address into the set. */
37 void eset_insert(eset *s, void *p);
39 /** Checks, whether an address is element of a set. */
40 int eset_contains(eset *s, void *p);
43 * Starts the iteration over a set and returns the first element or NULL
44 * if the set is empty.
46 * @note: It is NOT possible to add new elements while iterating through a set.
48 void *eset_first(eset *s);
51 * Continues iteration through a set and returns the next element or NULL if the
52 * iteration is finished.
54 * @note: It is NOT possible to add new elements while iterating through a set.
56 void *eset_next(eset *s);
58 /** Inserts all elements of source into target (union). Does NOT work if NULL is contained in source. */
59 void eset_insert_all(eset *target, eset *source);