fixed end block handling
[libfirm] / ir / ana2 / qset.h
1 /* -*- c -*- */
2
3 /*
4  * Time-stamp: <31.10.2004 22:36:22h 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 /* QSET INTERFACE */
40 /* Print a list of sortables. */
41 void q_print (sortable_t*, const int, FILE*);
42
43 /* Check whether the given list of sortables is sorted. */
44 void q_check (sortable_t*, const int);
45
46 /* Test whether the given val is among values.  Return the index of
47    val in values, or -1. */
48 int q_test (sortable_t*, const sortable_t, const int);
49
50 /* Sort n_elems entries  in 'values' */
51 void q_sort (sortable_t*, const int);
52
53 /* Merge two sorted lists */
54 sortable_t *q_merge (sortable_t*, const int,
55                      sortable_t*, const int);
56
57
58 /* QSET INTERFACE */
59
60 /* Allocate a new qset with initial space for up to n_elems. */
61 qset_t *qset_new (const int);
62
63 /* Sort the entries of the given qset. */
64 void qset_sort (qset_t*);
65
66 /* Compact a qset to take up no more space than required. */
67 void qset_compact (qset_t*);
68
69 /* Free the memory associated with the given qset */
70 void qset_delete (qset_t*);
71
72 /* Test whether the given qset contains the given value. */
73 int qset_contains (qset_t*, sortable_t);
74
75 /* Delete the given value from the given qset (if it exists) */
76 void qset_remove (qset_t*, sortable_t);
77
78 /* Insert the given elem into the given qset. */
79 void qset_insert (qset_t*, sortable_t);
80
81 /* Insert all elems of qset2 into qset1. qset2 is deleted. */
82 void qset_insert_all (qset_t*, qset_t*);
83
84 /* Compare two qsets. */
85 int qset_compare (qset_t*, qset_t*);
86
87 /* Returns the union of two qsets. */
88 qset_t *qset_union (qset_t *qset1, qset_t *qset2);
89
90 /* Report the size of the given qset. */
91 int qset_size (qset_t *qset);
92
93 /* Print the given qset to the given stream. */
94 void qset_print (qset_t*, FILE*);
95
96 /*
97    Iterate over a qset
98 */
99 /* initialise the iteration, return the first element */
100 sortable_t *qset_start (qset_t*);
101 /* step to the next element, return NULL iff no more elems are available */
102 sortable_t *qset_next (qset_t*);
103
104 #endif /* def _QSET_H_ */
105
106 /*
107  $Log$
108  Revision 1.1  2004/11/04 14:55:13  liekweg
109  added qset
110
111
112 */