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
25 * This implements a set of pointers which allows to specify custom callbacks
26 * for comparing and hashing its elements.
32 #define HashSet cpset_t
33 #define HashSetIterator cpset_iterator_t
34 #define HashSetEntry cpset_hashset_entry_t
35 #define ValueType void*
36 #define NullValue NULL
37 #define DeletedValue ((void*)-1)
38 #define Hash(this,key) this->hash_function(key)
39 #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 void cpset_init_(cpset_t *self);
44 #define hashset_init cpset_init_
45 void cpset_init_size_(cpset_t *self, size_t expected_elems);
46 #define hashset_init_size cpset_init_size_
47 #define hashset_destroy cpset_destroy
48 #define hashset_insert cpset_insert
49 #define hashset_remove cpset_remove
50 #define hashset_find cpset_find
51 #define hashset_size cpset_size
52 #define hashset_iterator_init cpset_iterator_init
53 #define hashset_iterator_next cpset_iterator_next
54 #define hashset_remove_iterator cpset_remove_iterator
58 void cpset_init(cpset_t *this_, cpset_hash_function hash_function,
59 cpset_cmp_function cmp_function)
61 this_->hash_function = hash_function;
62 this_->cmp_function = cmp_function;
66 void cpset_init_size(cpset_t *this_, cpset_hash_function hash_function,
67 cpset_cmp_function cmp_function, size_t expected_elems)
69 this_->hash_function = hash_function;
70 this_->cmp_function = cmp_function;
71 cpset_init_size_(this_, expected_elems);