libFirm
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
set.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 1995-2011 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
25
#ifndef FIRM_ADT_SET_H
26
#define FIRM_ADT_SET_H
27
28
#include <stddef.h>
29
30
#include "../begin.h"
31
48
typedef
struct
set
set
;
49
51
typedef
struct
set_entry
{
52
unsigned
hash
;
53
size_t
size
;
54
int
dptr
[1];
56
}
set_entry
;
57
73
typedef
int (*
set_cmp_fun
) (
const
void
*elt,
const
void
*key,
size_t
size);
74
85
FIRM_API
set
*
new_set
(
set_cmp_fun
func,
size_t
slots);
86
92
FIRM_API
void
del_set
(
set
*
set
);
93
99
FIRM_API
size_t
set_count
(
set
*
set
);
100
112
FIRM_API
void
*
set_find
(
set
*
set
,
const
void
*key,
size_t
size,
unsigned
hash);
113
129
FIRM_API
void
*
set_insert
(
set
*
set
,
const
void
*key,
size_t
size,
unsigned
hash);
130
146
FIRM_API
set_entry
*
set_hinsert
(
set
*
set
,
const
void
*key,
size_t
size,
unsigned
hash);
147
163
FIRM_API
set_entry
*
set_hinsert0
(
set
*
set
,
const
void
*key,
size_t
size,
unsigned
hash);
164
172
FIRM_API
void
*
set_first
(
set
*
set
);
173
184
#define set_first(type, set) ((type*)set_first((set)))
185
194
FIRM_API
void
*
set_next
(
set
*
set
);
195
207
#define set_next(type, set) ((type*)set_next((set)))
208
216
FIRM_API
void
set_break
(
set
*
set
);
217
225
#define foreach_set(set, type, entry) for (type *entry = set_first(type, set); entry; entry = set_next(type, set))
226
229
/* implementation specific */
230
#define new_set(cmp, slots) ((new_set) ((cmp), (slots)))
231
#define set_find(type, set, key, size, hash) \
232
((type*)_set_search((set), 1 ? (key) : (type*)0
/* type check */
, (size), (hash), _set_find))
233
#define set_insert(type, set, key, size, hash) \
234
((type*)_set_search((set), 1 ? (key) : (type*)0
/* type check */
, (size), (hash), _set_insert))
235
#define set_hinsert(set, key, size, hash) \
236
((set_entry *)_set_search ((set), (key), (size), (hash), _set_hinsert))
237
#define set_hinsert0(set, key, size, hash) \
238
((set_entry *)_set_search ((set), (key), (size), (hash), _set_hinsert0))
239
240
typedef
enum
{ _set_find, _set_insert, _set_hinsert, _set_hinsert0 } _set_action;
241
242
FIRM_API
void
*_set_search(
set
*,
const
void
*,
size_t
,
unsigned
, _set_action);
243
248
#include "../end.h"
249
250
#endif
libfirm
adt
set.h
Generated on Sat Nov 24 2012 19:13:48 for libFirm by
1.8.1.2