X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fadt%2Fpmap.h;h=faeb7dfed7fa0e616ab4ae1422af6aa1aa30ed4a;hb=5ed60b9196d8f50c2426ae27d59817e813f00f0c;hp=c15120f1b3b0e714c1def53ebc8b579d327c6581;hpb=7678991c92030f755075b344c47ccfddc1c4959b;p=libfirm diff --git a/ir/adt/pmap.h b/ir/adt/pmap.h index c15120f1b..faeb7dfed 100644 --- a/ir/adt/pmap.h +++ b/ir/adt/pmap.h @@ -7,50 +7,67 @@ * Modified by: * Created: 09.06.2002 * CVS-ID: $Id$ - * Copyright: (c) 2002 Universität Karlsruhe + * Copyright: (c) 2002 Universit�t Karlsruhe * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. */ #ifndef _PMAP_H_ #define _PMAP_H_ -/* Map die Adressen auf Adressen abbildet. Der Vergleich und das - * Hashen findet über die Adresse statt. */ - +/** A map which maps addresses to addresses. */ typedef struct pmap pmap; +/** + * A key, value pair. + */ typedef struct pmap_entry { - void * key; - void * value; + void *key; /**< The key. */ + void *value; /**< The value. */ } pmap_entry; -/* Erzeugt eine neue leere Map. */ -pmap * pmap_create(void); +/** Creates a new empty map. */ +pmap *pmap_create(void); + +/** Creates a new empty map with an initial number of slots. */ +pmap *pmap_create_ex(int slots); -/* Löscht eine Map. */ +/** Deletes a map. */ void pmap_destroy(pmap *); -/* Fügt ein Paar (key,value) in die Map ein. Gibt es bereits einen - * Eintrag mit "key" in er Map, so wird der entsprechende "value" - * überschrieben. */ -void pmap_insert(pmap *, void * key, void * value); +/** + * Inserts a pair (key,value) into the map. If an entry with key + * "key" already exists, its "value" is overwritten. + */ +void pmap_insert(pmap *map, void * key, void * value); + +/** Checks if an entry with key "key" exists. */ +int pmap_contains(pmap *map, void * key); -/* Prüft ob ein Eintrag zu "key" exisitiert. */ -int pmap_contains(pmap *, void * key); +/** Returns the key, value pair of "key". */ +pmap_entry * pmap_find(pmap *map, void * key); -/* Gibt den Eintrag zu "key" zurück. */ -pmap_entry * pmap_find(pmap *, void * key); +/** Returns the value of "key". */ +void * pmap_get(pmap *map, void * key); -/* Gibt für den Eintrag zu "key" den "value" zurück. */ -void * pmap_get(pmap *, void * key); +int pmap_count(pmap *map); -/* Mit den Funktionen "pmap_first" und "pmap_next" kann man durch die - * Map iterieren. Die Funktionen geben einen Zeiger auf einen Eintrag - * zurück (key,value). Die Funktionen geben "NULL" zurück, wenn kein - * weiterer Eintrag existiert. */ -pmap_entry * pmap_first(pmap *); -pmap_entry * pmap_next(pmap *); +/** + * Returns the first entry of a map if the map is not empty. + */ +pmap_entry *pmap_first(pmap *map); + +/** + * Returns the next entry of a map or NULL if all entries were visited. + */ +pmap_entry *pmap_next(pmap *); +#define pmap_foreach(pmap, curr) \ + for (curr = pmap_first(pmap); curr; curr = pmap_next(pmap)) + +/** Breaks an iteration. + * Must be called, if a iteration ends before p_map_next() returns NULL. + */ +void pmap_break(pmap *map); #endif /* _PMAP_H_ */