Loads do not remove any nodes from the exec after sets. Also fix a 'node leak'.
[libfirm] / ir / adt / pmap.h
index c15120f..e204bba 100644 (file)
@@ -1,56 +1,86 @@
 /*
- * 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.
+ * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
  */
 
-#ifndef _PMAP_H_
-#define _PMAP_H_
-
-/* Map die Adressen auf Adressen abbildet. Der Vergleich und das
- * Hashen findet über die Adresse statt. */
+/**
+ * @file
+ * @brief       Simplified hashnap for pointer->pointer relations
+ * @author      Hubert Schmid
+ * @date        09.06.2002
+ * @version     $Id$
+ */
+#ifndef FIRM_ADT_PMAP_H
+#define FIRM_ADT_PMAP_H
 
+/**  A map which maps addresses to addresses. */
 typedef struct pmap pmap;
 
+/**
+ * A key, value pair.
+ */
 typedef struct pmap_entry {
-  void * key;
-  void * value;
+       const 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, const void * key, void * value);
 
-/* Prüft ob ein Eintrag zu "key" exisitiert. */
-int pmap_contains(pmap *, void * key);
+/** Checks if an entry with key "key" exists. */
+int pmap_contains(pmap *map, const void * key);
 
-/* Gibt den Eintrag zu "key" zurück. */
-pmap_entry * pmap_find(pmap *, void * key);
+/** Returns the key, value pair of "key". */
+pmap_entry * pmap_find(pmap *map, const void * key);
 
-/* Gibt für den Eintrag zu "key" den "value" zurück. */
-void * pmap_get(pmap *, void * key);
+/** Returns the value of "key". */
+void * pmap_get(pmap *map, const void * key);
 
-/* 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 *);
+int pmap_count(pmap *map);
 
+/**
+ * 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_ */
+#endif