fixed inline to INLINE
[libfirm] / ir / adt / pmap.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/adt/eset.c
4  * Purpose:     Datentyp: Vereinfachte Map (hash-map) zum Speichern von
5  *              Zeigern/Adressen -> Zeigern/Adressen.
6  * Author:      Hubert Schmid
7  * Modified by:
8  * Created:     09.06.2002
9  * CVS-ID:      $Id$
10  * Copyright:   (c) 2002 Universit�t Karlsruhe
11  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
12  */
13
14 #ifndef _PMAP_H_
15 #define _PMAP_H_
16
17 /**  A map which maps addresses to addresses. */
18 typedef struct pmap pmap;
19
20 /**
21  * A key, value pair.
22  */
23 typedef struct pmap_entry {
24         const void *key;    /**< The key. */
25         void *value;  /**< The value. */
26 } pmap_entry;
27
28
29 /** Creates a new empty map. */
30 pmap *pmap_create(void);
31
32 /** Creates a new empty map with an initial number of slots. */
33 pmap *pmap_create_ex(int slots);
34
35 /** Deletes a map. */
36 void pmap_destroy(pmap *);
37
38 /**
39  *  Inserts a pair (key,value) into the map. If an entry with key
40  * "key" already exists, its "value" is overwritten.
41  */
42 void pmap_insert(pmap *map, const void * key, void * value);
43
44 /** Checks if an entry with key "key" exists. */
45 int pmap_contains(pmap *map, const void * key);
46
47 /** Returns the key, value pair of "key". */
48 pmap_entry * pmap_find(pmap *map, const void * key);
49
50 /** Returns the value of "key". */
51 void * pmap_get(pmap *map, const void * key);
52
53 int pmap_count(pmap *map);
54
55 /**
56  * Returns the first entry of a map if the map is not empty.
57  */
58 pmap_entry *pmap_first(pmap *map);
59
60 /**
61  * Returns the next entry of a map or NULL if all entries were visited.
62  */
63 pmap_entry *pmap_next(pmap *);
64
65 #define pmap_foreach(pmap, curr) \
66         for (curr = pmap_first(pmap); curr; curr = pmap_next(pmap))
67
68 /** Breaks an iteration.
69  *  Must be called, if a iteration ends before p_map_next() returns NULL.
70  */
71 void pmap_break(pmap *map);
72
73 #endif /* _PMAP_H_ */