4 * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
6 * This file is part of libFirm.
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.
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.
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
24 * @brief yet another set implementation
26 * @date Mon 18 Oct 2004
29 #ifndef FIRM_ANA2_QSET_H
30 #define FIRM_ANA2_QSET_H
35 # endif /* nof defined TRUE */
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;
43 struct obstack; /* forward decl */
45 typedef struct qset_str
52 int cursor; /* for qset_start/qset_next */
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*);
64 /* Sort the entries of the given qset. */
65 void qset_sort (qset_t*);
67 /* Compact a qset to take up no more space than required. */
68 void qset_compact (qset_t*);
70 /* Free the memory associated with the given qset */
71 void qset_delete (qset_t*);
73 /* Test whether the given qset contains the given value. */
74 int qset_contains (qset_t*, sortable_t);
76 /* Delete the given value from the given qset (if it exists) */
77 void qset_remove (qset_t*, sortable_t);
79 /* Insert the given elem into the given qset; return nonzero iff any involved values change. */
80 int qset_insert (qset_t*, sortable_t);
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*);
86 /* Compare two qsets. */
87 int qset_compare (qset_t*, qset_t*);
89 /* Returns the union of two qsets. */
90 qset_t *qset_union (qset_t *qset1, qset_t *qset2);
92 /* Report the size of the given qset. */
93 int qset_size (qset_t *qset);
95 /* Print the given qset to the given stream. */
96 void qset_print (qset_t*, FILE*);
98 /* Check wether the given qset is empty */
99 int qset_is_empty (qset_t*);
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*);
113 Revision 1.5 2004/11/30 14:47:11 liekweg
114 insert report changes
116 Revision 1.4 2004/11/24 14:53:56 liekweg
119 Revision 1.3 2004/11/18 16:35:46 liekweg
120 Added unique ids for debugging
122 Revision 1.2 2004/11/08 12:32:00 liekweg
123 Moved q_* methods into private section
125 Revision 1.1 2004/11/04 14:55:13 liekweg