2 * Copyright (C) 1995-2007 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 Custom pointer set
23 * @author Matthias Braun
26 * This implements a set of pointers which allows to specify custom callbacks
27 * for comparing and hashing it's elements.
33 #define HashSet cpset_t
34 #define HashSetIterator cpset_iterator_t
35 #define HashSetEntry cpset_hashset_entry_t
36 #define ValueType void*
37 #define NullValue NULL
38 #define DeletedValue ((void*)-1)
39 #define Hash(this,value) this->hash_function(value)
40 #define KeysEqual(this,key1,key2) this->cmp_function(key1, key2)
41 #define SetRangeEmpty(ptr,size) memset(ptr, 0, (size) * sizeof(cpset_hashset_entry_t))
43 #define hashset_init _cpset_init
44 #define hashset_init_size _cpset_init_size
45 #define hashset_destroy cpset_destroy
46 #define hashset_insert cpset_insert
47 #define hashset_remove cpset_remove
48 #define hashset_find cpset_find
49 #define hashset_size cpset_size
50 #define hashset_iterator_init cpset_iterator_init
51 #define hashset_iterator_next cpset_iterator_next
52 #define hashset_remove_iterator cpset_remove_iterator
56 void cpset_init(cpset_t *this, cpset_hash_function hash_function,
57 cpset_cmp_function cmp_function)
59 this->hash_function = hash_function;
60 this->cmp_function = cmp_function;
64 void cpset_init_size(cpset_t *this, cpset_hash_function hash_function,
65 cpset_cmp_function cmp_function, size_t expected_elems)
67 this->hash_function = hash_function;
68 this->cmp_function = cmp_function;
69 _cpset_init_size(this, expected_elems);