properly mark symbols in the public API to be exported. This allows us to use -fvisib...
[libfirm] / include / libfirm / adt / pmap.h
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       Simplified hashnap for pointer->pointer relations
23  * @author      Hubert Schmid
24  * @date        09.06.2002
25  * @version     $Id$
26  */
27 #ifndef FIRM_ADT_PMAP_H
28 #define FIRM_ADT_PMAP_H
29
30 #include "../begin.h"
31
32 /**  A map which maps addresses to addresses. */
33 typedef struct pmap pmap;
34
35 /**
36  * A key, value pair.
37  */
38 typedef struct pmap_entry {
39         const void *key;    /**< The key. */
40         void *value;  /**< The value. */
41 } pmap_entry;
42
43
44 /** Creates a new empty map. */
45 pmap *pmap_create(void);
46
47 /** Creates a new empty map with an initial number of slots. */
48 pmap *pmap_create_ex(int slots);
49
50 /** Deletes a map. */
51 void pmap_destroy(pmap *);
52
53 /**
54  *  Inserts a pair (key,value) into the map. If an entry with key
55  * "key" already exists, its "value" is overwritten.
56  */
57 void pmap_insert(pmap *map, const void * key, void * value);
58
59 /** Checks if an entry with key "key" exists. */
60 int pmap_contains(pmap *map, const void * key);
61
62 /** Returns the key, value pair of "key". */
63 pmap_entry * pmap_find(pmap *map, const void * key);
64
65 /** Returns the value of "key". */
66 void * pmap_get(pmap *map, const void * key);
67
68 int pmap_count(pmap *map);
69
70 /**
71  * Returns the first entry of a map if the map is not empty.
72  */
73 pmap_entry *pmap_first(pmap *map);
74
75 /**
76  * Returns the next entry of a map or NULL if all entries were visited.
77  */
78 pmap_entry *pmap_next(pmap *);
79
80 #define foreach_pmap(pmap, curr) \
81         for (curr = pmap_first(pmap); curr; curr = pmap_next(pmap))
82
83 /** Breaks an iteration.
84  *  Must be called, if a iteration ends before p_map_next() returns NULL.
85  */
86 void pmap_break(pmap *map);
87
88 #include "../end.h"
89
90 #endif