libFirm 1.20
|
00001 /* 00002 * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved. 00003 * 00004 * This file is part of libFirm. 00005 * 00006 * This file may be distributed and/or modified under the terms of the 00007 * GNU General Public License version 2 as published by the Free Software 00008 * Foundation and appearing in the file LICENSE.GPL included in the 00009 * packaging of this file. 00010 * 00011 * Licensees holding valid libFirm Professional Edition licenses may use 00012 * this file in accordance with the libFirm Commercial License. 00013 * Agreement provided with the Software. 00014 * 00015 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00016 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00017 * PURPOSE. 00018 */ 00019 00026 #ifndef FIRM_ADT_PSET_H 00027 #define FIRM_ADT_PSET_H 00028 00029 #include <stddef.h> 00030 00031 #include "hashptr.h" 00032 00033 #include "../begin.h" 00034 00049 FIRM_API int pset_default_ptr_cmp(const void *x, const void *y); 00050 00059 typedef struct pset pset; 00060 00062 #define pset_insert_ptr(set,key) pset_insert(set, key, hash_ptr(key)) 00063 00064 #define pset_hinsert_ptr(set,key) pset_hinsert(set, key, hash_ptr(key)) 00065 00066 #define pset_remove_ptr(set,key) pset_remove(set, key, hash_ptr(key)) 00067 00068 #define pset_find_ptr(set,key) pset_find(set, key, hash_ptr(key)) 00069 00070 #define pset_new_ptr(slots) new_pset(pset_default_ptr_cmp, slots) 00071 00072 #define pset_new_ptr_default() pset_new_ptr(64) 00073 00075 typedef struct { 00076 unsigned hash; 00077 void *dptr; 00078 } pset_entry; 00079 00089 typedef int (*pset_cmp_fun) (const void *elt, const void *key); 00090 00101 FIRM_API pset *new_pset(pset_cmp_fun func, size_t slots); 00102 00111 FIRM_API void del_pset(pset *pset); 00112 00118 FIRM_API size_t pset_count(pset *pset); 00119 00130 FIRM_API void *pset_find(pset *pset, const void *key, unsigned hash); 00131 00147 FIRM_API void *pset_insert(pset *pset, const void *key, unsigned hash); 00148 00163 FIRM_API pset_entry *pset_hinsert(pset *pset, const void *key, unsigned hash); 00164 00181 FIRM_API void *pset_remove(pset *pset, const void *key, unsigned hash); 00182 00190 FIRM_API void *pset_first(pset *pset); 00191 00200 FIRM_API void *pset_next(pset *pset); 00201 00209 FIRM_API void pset_break(pset *pset); 00210 00218 #define foreach_pset(pset, type, entry) for (entry = (type)pset_first(pset); entry; entry = (type)pset_next(pset)) 00219 00227 FIRM_API void pset_insert_pset_ptr(pset *target, pset *src); 00228 00231 #define new_pset(cmp, slots) ((new_pset) ((cmp), (slots))) 00232 #define pset_find(pset, key, hash) \ 00233 _pset_search ((pset), (key), (hash), _pset_find) 00234 #define pset_insert(pset, key, hash) \ 00235 _pset_search ((pset), (key), (hash), _pset_insert) 00236 #define pset_hinsert(pset, key, hash) \ 00237 ((pset_entry *)_pset_search ((pset), (key), (hash), _pset_hinsert)) 00238 00239 typedef enum { _pset_find, _pset_insert, _pset_hinsert } _pset_action; 00240 00241 FIRM_API void *_pset_search(pset *, const void *, unsigned, _pset_action); 00242 00247 #include "../end.h" 00248 00249 #endif