X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fadt%2Fpmap.h;h=faeb7dfed7fa0e616ab4ae1422af6aa1aa30ed4a;hb=d2dc2564b47d9c113d7e6e598574e9733627fcca;hp=5cac4d7e3f38897de5051453c6fde8427b82a2a3;hpb=4310a8ac04f255d0ba74cfece9227689a94530ef;p=libfirm diff --git a/ir/adt/pmap.h b/ir/adt/pmap.h index 5cac4d7e3..faeb7dfed 100644 --- a/ir/adt/pmap.h +++ b/ir/adt/pmap.h @@ -1,57 +1,73 @@ -/* ------------------------------------------------------------------- - * $Id$ - * ------------------------------------------------------------------- - * Datentyp: Vereinfachte Map (hash-map) zum Speichern von - * Zeigern/Adressen -> Zeigern/Adressen. - * - * Erstellt: Hubert Schmid, 09.06.2002 - * ---------------------------------------------------------------- */ - +/* + * Project: libFIRM + * File name: ir/adt/eset.c + * Purpose: Datentyp: Vereinfachte Map (hash-map) zum Speichern von + * Zeigern/Adressen -> Zeigern/Adressen. + * Author: Hubert Schmid + * Modified by: + * Created: 09.06.2002 + * CVS-ID: $Id$ + * Copyright: (c) 2002 Universit�t Karlsruhe + * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. + */ #ifndef _PMAP_H_ #define _PMAP_H_ - -#include - - -/* 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); -/* Löscht eine Map. */ +/** Creates a new empty map with an initial number of slots. */ +pmap *pmap_create_ex(int slots); + +/** 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); + +/** Returns the key, value pair of "key". */ +pmap_entry * pmap_find(pmap *map, void * key); + +/** Returns the value of "key". */ +void * pmap_get(pmap *map, void * key); -/* Prüft ob ein Eintrag zu "key" exisitiert. */ -bool pmap_contains(pmap *, void * key); +int pmap_count(pmap *map); -/* Gibt den Eintrag zu "key" zurück. */ -pmap_entry * pmap_find(pmap *, void * key); +/** + * Returns the first entry of a map if the map is not empty. + */ +pmap_entry *pmap_first(pmap *map); -/* Gibt für den Eintrag zu "key" den "value" zurück. */ -void * pmap_get(pmap *, void * key); +/** + * Returns the next entry of a map or NULL if all entries were visited. + */ +pmap_entry *pmap_next(pmap *); -/* 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 *); +#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_ */