Checks now the Load_mode
[libfirm] / ir / adt / set.h
index 4b74819..a97ca62 100644 (file)
@@ -25,7 +25,7 @@
  * The abstract type of a set.
  *
  * This sets stores copies of its elements, so there is no need
- * to store the elements after there were added to a set.
+ * to store the elements after they were added to a set.
  *
  * @see pset
  */
@@ -60,16 +60,25 @@ typedef int (*set_cmp_fun) (const void *elt, const void *key, size_t size);
  * Creates a new set.
  *
  * @param func    the compare function of this set
- * @param slots   number of slots
+ * @param slots   number of initial slots
  *
  * @returns
  *    created set
  */
 set *new_set (set_cmp_fun func, int slots);
 
-/** Deletes a set and all elements of it. */
+/**
+ * Deletes a set and all elements of it.
+ */
 void del_set (set *set);
 
+/**
+ * Returns the number of elements in a set.
+ *
+ * @param set   the set
+ */
+int set_count (set *set);
+
 /**
  * Searches an element in a set.
  *
@@ -79,7 +88,7 @@ void del_set (set *set);
  * @param hash  the hash value of key
  *
  * @return
- *    the address of the found element in the set of NULL if it was not found
+ *    The address of the found element in the set or NULL if it was not found.
  */
 void *set_find (set *set, const void *key, size_t size, unsigned hash);
 
@@ -87,14 +96,14 @@ void *set_find (set *set, const void *key, size_t size, unsigned hash);
  * Inserts an element into a set.
  *
  * @param set   the set to insert in
- * @param key   a pointer to the element to be inserted
+ * @param key   a pointer to the element to be inserted.  Element is copied!
  * @param size  the size of the element that should be inserted
  * @param hash  the hash-value of the element
  *
  * @return a pointer to the inserted element
  *
  * @note
- *    It is not possible to insert on element more than once. If a element
+ *    It is not possible to insert on element more than once. If an element
  *    that should be inserted is already in the set, this functions does
  *    nothing but returning its pointer.
  */
@@ -104,14 +113,14 @@ void *set_insert (set *set, const void *key, size_t size, unsigned hash);
  * Inserts an element into a set and returns its set_entry.
  *
  * @param set   the set to insert in
- * @param key   a pointer to the element to be inserted
+ * @param key   a pointer to the element to be inserted. Element is copied!
  * @param size  the size of the element that should be inserted
  * @param hash  the hash-value of the element
  *
  * @return a pointer to the set_entry of the inserted element
  *
  * @note
- *    It is not possible to insert on element more than once. If a element
+ *    It is not possible to insert an element more than once. If an element
  *    that should be inserted is already in the set, this functions does
  *    nothing but returning its set_entry.
  */
@@ -121,26 +130,45 @@ set_entry *set_hinsert (set *set, const void *key, size_t size, unsigned hash);
  * Inserts an element into a set, zero-terminate it and returns its set_entry.
  *
  * @param set   the set to insert in
- * @param key   a pointer to the element to be inserted
+ * @param key   a pointer to the element to be inserted.  Element is copied!
  * @param size  the size of the element that should be inserted
  * @param hash  the hash-value of the element
  *
  * @return a pointer to the set_entry of the inserted element
  *
  * @note
- *    It is not possible to insert on element more than once. If a element
+ *    It is not possible to insert on element more than once. If an element
  *    that should be inserted is already in the set, this functions does
  *    nothing but returning its set_entry.
  */
 set_entry *set_hinsert0 (set *set, const void *key, size_t size, unsigned hash);
 
-/** Returns the first element of a set. */
+/**
+ * Returns the first element of a set.
+ *
+ * @param set  the set to iterate
+ *
+ * @return a pointer to the element or NULL if the set is empty
+ */
 void *set_first (set *set);
 
-/** Returns the next element of a set. */
+/**
+ * Returns the next element of a set.
+ *
+ * @param set  the set to iterate
+ *
+ * @return a pointer to the next element or NULL if the
+ *         iteration is finished
+ */
 void *set_next (set *set);
 
-/** Breaks the iteration of a set. Must be called before the next set_first() call */
+/**
+ * Breaks the iteration of a set. Must be called before
+ * the next pset_first() call if the iteration was NOT
+ * finished.
+ *
+ * @param pset  the pset
+ */
 void set_break (set *set);
 
 /* implementation specific */
@@ -157,7 +185,12 @@ void set_break (set *set);
 #define SET_VRFY(set) (void)0
 
 #ifdef STATS
-void set_stats (set *);
+/**
+ * Prints statistics on a set to stdout.
+ *
+ * @param set  the set
+ */
+void set_stats (set *set);
 #else
 # define set_stats(s) ((void)0)
 #endif