libFirm
Loading...
Searching...
No Matches
pmap.h
1/*
2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
4 */
5
12#ifndef FIRM_ADT_PMAP_H
13#define FIRM_ADT_PMAP_H
14
15#include <stddef.h>
16
17#include "../begin.h"
18
27typedef struct pmap pmap;
28
32typedef struct {
33 void const *key;
34 void *value;
36
37
39FIRM_API pmap *pmap_create(void);
40
42FIRM_API pmap *pmap_create_ex(size_t slots);
43
45FIRM_API void pmap_destroy(pmap *map);
46
51FIRM_API void pmap_insert(pmap *map, void const *key, void *value);
52
54FIRM_API int pmap_contains(pmap const *map, void const *key);
55
57FIRM_API pmap_entry *pmap_find(pmap const *map, void const *key);
58
60FIRM_API void *pmap_get(pmap const *map, void const *key);
61
67#define pmap_get(type, map, key) ((type*)pmap_get(map, key))
68
70FIRM_API size_t pmap_count(pmap const *map);
71
75FIRM_API pmap_entry *pmap_first(pmap *map);
76
80FIRM_API pmap_entry *pmap_next(pmap *map);
81
85#define foreach_pmap(pmap, curr) \
86 for (pmap_entry *curr = pmap_first(pmap); curr; curr = pmap_next(pmap))
87
90FIRM_API void pmap_break(pmap *map);
91
96#include "../end.h"
97
98#endif
A key, value pair.
Definition pmap.h:32
void * value
The value.
Definition pmap.h:34
void const * key
The key.
Definition pmap.h:33
pmap * pmap_create_ex(size_t slots)
Creates a new empty map with an initial number of slots.
void pmap_break(pmap *map)
Breaks an iteration.
size_t pmap_count(pmap const *map)
Return number of elements in the map.
pmap_entry * pmap_first(pmap *map)
Returns the first entry of a map if the map is not empty.
#define pmap_get(type, map, key)
Returns the value of "key".
Definition pmap.h:67
pmap_entry * pmap_find(pmap const *map, void const *key)
Returns the key, value pair of "key".
pmap_entry * pmap_next(pmap *map)
Returns the next entry of a map or NULL if all entries were visited.
struct pmap pmap
A map which maps addresses to addresses.
Definition pmap.h:27
pmap * pmap_create(void)
Creates a new empty map.
int pmap_contains(pmap const *map, void const *key)
Checks if an entry with key "key" exists.
void pmap_destroy(pmap *map)
Deletes a map.
void pmap_insert(pmap *map, void const *key, void *value)
Inserts a pair (key,value) into the map.