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 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,key) this->hash_function(key)
40 #define KeysEqual(this,key1,key2) this->cmp_function(key1, key2)
42 #define SetRangeEmpty(ptr,size) memset(ptr, 0, (size) * sizeof(cpset_hashset_entry_t))
44 #define hashset_init _cpset_init
45 #define hashset_init_size _cpset_init_size
46 #define hashset_destroy cpset_destroy
47 #define hashset_insert cpset_insert
48 #define hashset_remove cpset_remove
49 #define hashset_find cpset_find
50 #define hashset_size cpset_size
51 #define hashset_iterator_init cpset_iterator_init
52 #define hashset_iterator_next cpset_iterator_next
53 #define hashset_remove_iterator cpset_remove_iterator
57 void cpset_init(cpset_t *this, cpset_hash_function hash_function,
58 cpset_cmp_function cmp_function)
60 this->hash_function = hash_function;
61 this->cmp_function = cmp_function;
65 void cpset_init_size(cpset_t *this, cpset_hash_function hash_function,
66 cpset_cmp_function cmp_function, size_t expected_elems)
68 this->hash_function = hash_function;
69 this->cmp_function = cmp_function;
70 _cpset_init_size(this, expected_elems);