s/full\>/ful/.
[libfirm] / ir / adt / cpset.c
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
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.
10  *
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.
14  *
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
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief   Custom pointer set
23  * @author  Matthias Braun
24  * @version $Id$
25  *
26  * This implements a set of pointers which allows to specify custom callbacks
27  * for comparing and hashing it's elements.
28  */
29 #include "config.h"
30
31 #include "cpset.h"
32
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)
41 #define SCALAR_RETURN
42 #define SetRangeEmpty(ptr,size)   memset(ptr, 0, (size) * sizeof(cpset_hashset_entry_t))
43
44 void cpset_init_(cpset_t *self);
45 #define hashset_init            cpset_init_
46 void cpset_init_size_(cpset_t *self, size_t expected_elems);
47 #define hashset_init_size       cpset_init_size_
48 #define hashset_destroy         cpset_destroy
49 #define hashset_insert          cpset_insert
50 #define hashset_remove          cpset_remove
51 #define hashset_find            cpset_find
52 #define hashset_size            cpset_size
53 #define hashset_iterator_init   cpset_iterator_init
54 #define hashset_iterator_next   cpset_iterator_next
55 #define hashset_remove_iterator cpset_remove_iterator
56
57 #include "hashset.c"
58
59 void cpset_init(cpset_t *this, cpset_hash_function hash_function,
60                 cpset_cmp_function cmp_function)
61 {
62         this->hash_function = hash_function;
63         this->cmp_function = cmp_function;
64         cpset_init_(this);
65 }
66
67 void cpset_init_size(cpset_t *this, cpset_hash_function hash_function,
68                      cpset_cmp_function cmp_function, size_t expected_elems)
69 {
70         this->hash_function = hash_function;
71         this->cmp_function = cmp_function;
72         cpset_init_size_(this, expected_elems);
73 }