add license info to ana2
[libfirm] / ir / ana2 / qset.h
1 /* -*- c -*- */
2
3 /*
4  * Copyrigth (C) 1995-2007 University of Karlsruhe.  All right reserved.
5  *
6  * This file is part of libFirm.
7  *
8  * This file may be distributed and/or modified under the terms of the
9  * GNU General Public License version 2 as published by the Free Software
10  * Foundation and appearing in the file LICENSE.GPL included in the
11  * packaging of this file.
12  *
13  * Licensees holding valid libFirm Professional Edition licenses may use
14  * this file in accordance with the libFirm Commercial License.
15  * Agreement provided with the Software.
16  *
17  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE.
20  */
21
22 /**
23  * @file
24  * @brief   yet another set implementation
25  * @author  Florian
26  * @date    Mon 18 Oct 2004
27  * @version $Id$
28  */
29 #ifndef FIRM_ANA2_QSET_H
30 #define FIRM_ANA2_QSET_H
31
32 # ifndef TRUE
33 #  define TRUE 1
34 #  define FALSE 0
35 # endif /* nof defined TRUE */
36
37 /* define this as needed */
38 # define COMPARE(A,B)       (A<B)
39 # define EQUAL(A,B)       (A==B)
40 /* typedef unsigned int sortable_t; */
41 typedef void* sortable_t;
42
43 struct obstack;                 /* forward decl */
44
45 typedef struct qset_str
46 {
47   struct obstack *obst;
48   sortable_t *values;
49   int n_slots;
50   int n_elems;
51   int is_sorted;
52   int cursor;                   /* for qset_start/qset_next */
53   int id;
54 } qset_t;
55
56
57 /* QSET INTERFACE */
58
59 /* Allocate a new qset with initial space for up to n_elems.
60    If a non-NULL obstack is given, it is used for all allocations of this qset
61    and must be initialised and deleted by the user of the qset. */
62 qset_t *qset_new (const int, struct obstack*);
63
64 /* Sort the entries of the given qset. */
65 void qset_sort (qset_t*);
66
67 /* Compact a qset to take up no more space than required. */
68 void qset_compact (qset_t*);
69
70 /* Free the memory associated with the given qset */
71 void qset_delete (qset_t*);
72
73 /* Test whether the given qset contains the given value. */
74 int qset_contains (qset_t*, sortable_t);
75
76 /* Delete the given value from the given qset (if it exists) */
77 void qset_remove (qset_t*, sortable_t);
78
79 /* Insert the given elem into the given qset; return nonzero iff any involved values change. */
80 int qset_insert (qset_t*, sortable_t);
81
82 /* Insert all elems of qset2 into qset1. qset2 is deleted; return
83    nonzero iff any involved values change. */
84 int qset_insert_all (qset_t*, qset_t*);
85
86 /* Compare two qsets. */
87 int qset_compare (qset_t*, qset_t*);
88
89 /* Returns the union of two qsets. */
90 qset_t *qset_union (qset_t *qset1, qset_t *qset2);
91
92 /* Report the size of the given qset. */
93 int qset_size (qset_t *qset);
94
95 /* Print the given qset to the given stream. */
96 void qset_print (qset_t*, FILE*);
97
98 /* Check wether the given qset is empty */
99 int qset_is_empty (qset_t*);
100
101 /*
102    Iterate over a qset
103 */
104 /* initialise the iteration, return the first element */
105 sortable_t *qset_start (qset_t*);
106 /* step to the next element, return NULL iff no more elems are available */
107 sortable_t *qset_next (qset_t*);
108
109 #endif
110
111 /*
112  $Log$
113  Revision 1.5  2004/11/30 14:47:11  liekweg
114  insert report changes
115
116  Revision 1.4  2004/11/24 14:53:56  liekweg
117  Bugfixes
118
119  Revision 1.3  2004/11/18 16:35:46  liekweg
120  Added unique ids for debugging
121
122  Revision 1.2  2004/11/08 12:32:00  liekweg
123  Moved q_* methods into private section
124
125  Revision 1.1  2004/11/04 14:55:13  liekweg
126  added qset
127
128
129 */