2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief A pointer hash-set (WARNING: deprecated!)
23 * @author Hubert Schmid
34 int dummy; /* dummy entry */
38 #define INITIAL_SLOTS 64
40 static int pcmp(const void *p1, const void *p2, size_t size) {
41 const void **q1 = (const void **)p1;
42 const void **q2 = (const void **)p2;
49 eset * eset_create(void) {
50 return (eset *) new_set(pcmp, INITIAL_SLOTS);
54 eset * eset_copy(eset *source) {
55 eset * ret = eset_create();
57 for (p = eset_first(source); p; p = eset_next(source)) {
64 void eset_destroy(eset *s) {
68 /* Returns the number of elements in the set. */
69 int eset_count(eset *s) {
70 return set_count((set *)s);
73 void eset_insert(eset *s, void *p) {
74 if (!eset_contains(s, p)) {
75 set_insert((set *)s, &p, sizeof(p), HASH_PTR(p));
80 int eset_contains(eset *s, void *p) {
81 return set_find((set *)s, &p, sizeof(p), HASH_PTR(p)) != NULL;
85 void * eset_first(eset *s) {
86 void * p = set_first((set *) s);
87 return p == NULL ? NULL : *((void **)p);
91 void * eset_next(eset *s) {
92 void *p = set_next((set *) s);
93 return p == NULL ? NULL : *((void **)p);
97 void eset_insert_all(eset *target, eset *source) {
99 for (p = eset_first(source); p; p = eset_next(source)) {
100 eset_insert(target, p);