libFirm
pmap.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 
26 #ifndef FIRM_ADT_PMAP_H
27 #define FIRM_ADT_PMAP_H
28 
29 #include <stddef.h>
30 
31 #include "../begin.h"
32 
41 typedef struct pmap pmap;
42 
46 typedef struct pmap_entry {
47  const void *key;
48  void *value;
49 } pmap_entry;
50 
51 
54 
56 FIRM_API pmap *pmap_create_ex(size_t slots);
57 
59 FIRM_API void pmap_destroy(pmap *);
60 
65 FIRM_API void pmap_insert(pmap *map, const void * key, void * value);
66 
68 FIRM_API int pmap_contains(pmap *map, const void * key);
69 
71 FIRM_API pmap_entry *pmap_find(pmap *map, const void * key);
72 
74 FIRM_API void * pmap_get(pmap *map, const void * key);
75 
81 #define pmap_get(type, map, key) ((type*)pmap_get(map, key))
82 
84 FIRM_API size_t pmap_count(pmap *map);
85 
90 
95 
99 #define foreach_pmap(pmap, curr) \
100  for (curr = pmap_first(pmap); curr; curr = pmap_next(pmap))
101 
105 FIRM_API void pmap_break(pmap *map);
106 
111 #include "../end.h"
112 
113 #endif