added doxygen comments
[libfirm] / ir / adt / pset.h
index 620a44d..9a42d1b 100644 (file)
 
 #include <stddef.h>
 
+#include "hashptr.h"
+#include "iterator.h"
+
+/**
+ * The default comparison function for pointers.
+ * @param x A pointer.
+ * @param y A pointer.
+ * @return 0 if @p x and @p y are equal. Some value != 0 otherwise.
+ */
+int pset_default_ptr_cmp(const void *x, const void *y);
+
+/*
+ * Define some convenience macros using the predefined hash function.
+ */
+#define pset_insert_ptr(set,key) pset_insert(set, key, HASH_PTR(key))
+#define pset_hinsert_ptr(set,key) pset_hinsert(set, key, HASH_PTR(key))
+#define pset_remove_ptr(set,key) pset_remove(set, key, HASH_PTR(key))
+#define pset_find_ptr(set,key) pset_find(set, key, HASH_PTR(key))
+#define pset_new_ptr(slots) new_pset(pset_default_ptr_cmp, slots)
+#define pset_new_ptr_default() pset_new_ptr(64)
+
 /**
  * The abstract type of a pset (Set of pointers).
  *
@@ -45,8 +66,9 @@ typedef int (*pset_cmp_fun) (const void *elt, const void *key);
 /**
  * Creates a new pset.
  *
- * @param func    the compare function of this pset
- * @param slots   number of initial slots
+ * @param func    The compare function of this pset.
+ * @param slots   Initial number of collision chains.  I.e., #slots
+ *                different keys can be hashed without collisions.
  *
  * @returns
  *    created pset
@@ -56,6 +78,8 @@ pset *new_pset (pset_cmp_fun func, int slots);
 /**
  * Deletes a pset.
  *
+ * @param pset   the pset
+ *
  * @note
  *    This does NOT delete the elements of this pset, just it's pointers!
  */
@@ -72,11 +96,11 @@ int pset_count (pset *pset);
  * Searches an element pointer in a pset.
  *
  * @param pset  the pset to search in
- * @param key   the element to is searched
+ * @param key   the element to search
  * @param hash  the hash value of key
  *
  * @return
- *    the pointer of the found element in the pset of NULL if it was not found
+ *    the pointer of the found element in the pset or NULL if it was not found
  */
 void *pset_find (pset *pset, const void *key, unsigned hash);
 
@@ -92,7 +116,7 @@ void *pset_find (pset *pset, const void *key, unsigned hash);
  * @note
  *    It is not possible to insert on element more than once. If a element
  *    that should be inserted is already in the set, this functions does
- *    nothing but returning its set_entry.
+ *    nothing but returning its already existing set_entry.
 
  */
 void *pset_insert (pset *pset, const void *key, unsigned hash);
@@ -179,10 +203,15 @@ void pset_stats (pset *pset);
 
 #ifdef DEBUG
 /**
- * Describe a set by printing all elements
- * to stdout.
+ * Describe a pset.
+ *
+ * Writes a description of a set to stdout. The description includes:
+ * - a header telling how many elements (nkey) and segments (nseg) are in use
+ * - for every collision chain the number of element with its hash values
+ *
+ * @param pset  the pset
  */
-void pset_describe (pset *);
+void pset_describe (pset *pset);
 #endif
 
 /* @@@ NYI */