Switch pqueue to size_t.
[libfirm] / include / libfirm / adt / set.h
index 6d736df..828dadd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
@@ -28,6 +28,8 @@
 
 #include <stddef.h>
 
+#include "../begin.h"
+
 /**
  * The abstract type of a set.
  *
@@ -67,25 +69,27 @@ 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   Initial number of collision chains.  I.e., #slots
+ * @param slots   Initial number of collision chains.  I.e., \#slots
  *                different keys can be hashed without collisions.
  *
  * @returns
  *    created set
  */
-set *new_set (set_cmp_fun func, int slots);
+FIRM_API set *new_set(set_cmp_fun func, size_t slots);
 
 /**
  * Deletes a set and all elements of it.
+ *
+ * @param set  the set to delete
  */
-void del_set (set *set);
+FIRM_API void del_set(set *set);
 
 /**
  * Returns the number of elements in a set.
  *
  * @param set   the set
  */
-int set_count (set *set);
+FIRM_API size_t set_count(set *set);
 
 /**
  * Searches an element in a set.
@@ -98,7 +102,7 @@ int set_count (set *set);
  * @return
  *    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);
+FIRM_API void *set_find(set *set, const void *key, size_t size, unsigned hash);
 
 /**
  * Inserts an element into a set.
@@ -115,7 +119,7 @@ void *set_find (set *set, const void *key, size_t size, unsigned hash);
  *    that should be inserted is already in the set, this functions does
  *    nothing but returning its pointer.
  */
-void *set_insert (set *set, const void *key, size_t size, unsigned hash);
+FIRM_API void *set_insert(set *set, const void *key, size_t size, unsigned hash);
 
 /**
  * Inserts an element into a set and returns its set_entry.
@@ -132,7 +136,7 @@ void *set_insert (set *set, const void *key, size_t size, unsigned hash);
  *    that should be inserted is already in the set, this functions does
  *    nothing but returning its set_entry.
  */
-set_entry *set_hinsert (set *set, const void *key, size_t size, unsigned hash);
+FIRM_API 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.
@@ -149,7 +153,7 @@ set_entry *set_hinsert (set *set, const void *key, size_t size, unsigned hash);
  *    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);
+FIRM_API set_entry *set_hinsert0(set *set, const void *key, size_t size, unsigned hash);
 
 /**
  * Returns the first element of a set.
@@ -158,7 +162,7 @@ set_entry *set_hinsert0 (set *set, const void *key, size_t size, unsigned hash);
  *
  * @return a pointer to the element or NULL if the set is empty
  */
-void *set_first (set *set);
+FIRM_API void *set_first(set *set);
 
 /**
  * Returns the next element of a set.
@@ -168,7 +172,7 @@ void *set_first (set *set);
  * @return a pointer to the next element or NULL if the
  *         iteration is finished
  */
-void *set_next (set *set);
+FIRM_API void *set_next(set *set);
 
 /**
  * Breaks the iteration of a set. Must be called before
@@ -177,7 +181,7 @@ void *set_next (set *set);
  *
  * @param set  the set
  */
-void set_break (set *set);
+FIRM_API void set_break(set *set);
 
 /**
  * Iterates over an set.
@@ -185,10 +189,10 @@ void set_break (set *set);
  * @param set    the set
  * @param entry  the iterator
  */
-#define foreach_set(set, entry) for (entry = set_first(set); entry; entry = set_next(set))
+#define foreach_set(set, type, entry) for (entry = (type) set_first(set); entry; entry = (type) set_next(set))
 
 /* implementation specific */
-#define new_set(cmp, slots) (SET_TRACE (new_set) ((cmp), (slots)))
+#define new_set(cmp, slots) ((new_set) ((cmp), (slots)))
 #define set_find(set, key, size, hash) \
   _set_search ((set), (key), (size), (hash), _set_find)
 #define set_insert(set, key, size, hash) \
@@ -221,7 +225,7 @@ void set_stats (set *set);
  *
  * @param set  the set
  */
-void set_describe (set *set);
+FIRM_API void set_describe(set *set);
 #endif
 
 
@@ -229,17 +233,8 @@ void set_describe (set *set);
 
 typedef enum { _set_find, _set_insert, _set_hinsert, _set_hinsert0 } _set_action;
 
-void *_set_search (set *, const void *, size_t, unsigned, _set_action);
-
-#if defined(DEBUG) && defined(HAVE_GNU_MALLOC)
-extern const char *set_tag;
-# ifdef SET_ID
-#   define SET_TRACE set_tag = SET_ID,
-# else
-#   define SET_TRACE set_tag = __FILE__,
-# endif
-#else /* !(DEBUG && HAVE_GNU_MALLOC) */
-#   define SET_TRACE
-#endif /* !(DEBUG && HAVE_GNU_MALLOC) */
+FIRM_API void *_set_search(set *, const void *, size_t, unsigned, _set_action);
+
+#include "../end.h"
 
 #endif