Moved q_* methods into private section
[libfirm] / ir / ana2 / qset.h
1 /* -*- c -*- */
2
3 /*
4  * Time-stamp: <08.11.2004 13:29:19h liekweg>
5  * Project:     libFIRM
6  * File name:   ir/ana2/qset.h
7  * Purpose:     yet another set implementation
8  * Author:      Florian
9  * Modified by:
10  * Created:     Mon 18 Oct 2004
11  * CVS-ID:      $Id$
12  * Copyright:   (c) 1999-2004 Universität Karlsruhe
13  * Licence:     This file is protected by GPL -  GNU GENERAL PUBLIC LICENSE.
14  */
15
16 #ifndef _QSET_H_
17 #define _QSET_H_
18
19 # ifndef TRUE
20 #  define TRUE 1
21 #  define FALSE 0
22 # endif /* nof defined TRUE */
23
24 /* define this as needed */
25 # define COMPARE(A,B)       (A<B)
26 # define EQUAL(A,B)       (A==B)
27 /* typedef unsigned int sortable_t; */
28 typedef void* sortable_t;
29
30 typedef struct qset_str
31 {
32   sortable_t *values;
33   int n_slots;
34   int n_elems;
35   int is_sorted;
36   int cursor;                   /* for qset_start/qset_next */
37 } qset_t;
38
39
40 /* QSET INTERFACE */
41
42 /* Allocate a new qset with initial space for up to n_elems. */
43 qset_t *qset_new (const int);
44
45 /* Sort the entries of the given qset. */
46 void qset_sort (qset_t*);
47
48 /* Compact a qset to take up no more space than required. */
49 void qset_compact (qset_t*);
50
51 /* Free the memory associated with the given qset */
52 void qset_delete (qset_t*);
53
54 /* Test whether the given qset contains the given value. */
55 int qset_contains (qset_t*, sortable_t);
56
57 /* Delete the given value from the given qset (if it exists) */
58 void qset_remove (qset_t*, sortable_t);
59
60 /* Insert the given elem into the given qset. */
61 void qset_insert (qset_t*, sortable_t);
62
63 /* Insert all elems of qset2 into qset1. qset2 is deleted. */
64 void qset_insert_all (qset_t*, qset_t*);
65
66 /* Compare two qsets. */
67 int qset_compare (qset_t*, qset_t*);
68
69 /* Returns the union of two qsets. */
70 qset_t *qset_union (qset_t *qset1, qset_t *qset2);
71
72 /* Report the size of the given qset. */
73 int qset_size (qset_t *qset);
74
75 /* Print the given qset to the given stream. */
76 void qset_print (qset_t*, FILE*);
77
78 /* Check wether the given qset is empty */
79 int qset_is_empty (qset_t*);
80
81 /*
82    Iterate over a qset
83 */
84 /* initialise the iteration, return the first element */
85 sortable_t *qset_start (qset_t*);
86 /* step to the next element, return NULL iff no more elems are available */
87 sortable_t *qset_next (qset_t*);
88
89 #endif /* def _QSET_H_ */
90
91 /*
92  $Log$
93  Revision 1.2  2004/11/08 12:32:00  liekweg
94  Moved q_* methods into private section
95
96  Revision 1.1  2004/11/04 14:55:13  liekweg
97  added qset
98
99
100 */