types for constants (optional)
[libfirm] / ir / adt / set.h
index 96fbdd3..4b74819 100644 (file)
@@ -1,7 +1,14 @@
-/* Declarations for set.
-   Copyright (C) 1995, 1996 Markus Armbruster */
-
-/* $Id$ */
+/*
+ * Project:     libFIRM
+ * File name:   ir/adt/set.h
+ * Purpose:     Declarations for set.
+ * Author:      Markus Armbruster
+ * Modified by:
+ * Created:     1999 by getting from fiasco
+ * CVS-ID:      $Id$
+ * Copyright:   (c) 1995, 1996 Markus Armbruster
+ * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
+ */
 
 /**
  * @file set.h
@@ -41,6 +48,11 @@ typedef struct set_entry {
  *
  * @return
  *    0 if the elements are identically, non-zero else
+ *
+ * @note
+ *    Although it is possible to define different meanings for equality of two
+ *    elements of a sets, they can be only equal if there sizes are
+ *    equal. This is checked before the compare function is called.
  */
 typedef int (*set_cmp_fun) (const void *elt, const void *key, size_t size);
 
@@ -105,6 +117,23 @@ void *set_insert (set *set, const void *key, size_t size, unsigned hash);
  */
 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 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
+ *    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. */
 void *set_first (set *set);
 
@@ -122,6 +151,8 @@ void set_break (set *set);
   _set_search ((set), (key), (size), (hash), _set_insert)
 #define set_hinsert(set, key, size, hash) \
   ((set_entry *)_set_search ((set), (key), (size), (hash), _set_hinsert))
+#define set_hinsert0(set, key, size, hash) \
+  ((set_entry *)_set_search ((set), (key), (size), (hash), _set_hinsert0))
 
 #define SET_VRFY(set) (void)0
 
@@ -138,7 +169,7 @@ void set_describe (set *);
 
 /* Private */
 
-typedef enum { _set_find, _set_insert, _set_hinsert } _set_action;
+typedef enum { _set_find, _set_insert, _set_hinsert, _set_hinsert0 } _set_action;
 
 void *_set_search (set *, const void *, size_t, unsigned, _set_action);