4 * Time-stamp: <31.10.2004 22:36:22h liekweg>
6 * File name: ir/ana2/qset.h
7 * Purpose: yet another set implementation
10 * Created: Mon 18 Oct 2004
12 * Copyright: (c) 1999-2004 Universität Karlsruhe
13 * Licence: This file is protected by GPL - GNU GENERAL PUBLIC LICENSE.
22 # endif /* nof defined TRUE */
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;
30 typedef struct qset_str
36 int cursor; /* for qset_start/qset_next */
40 /* Print a list of sortables. */
41 void q_print (sortable_t*, const int, FILE*);
43 /* Check whether the given list of sortables is sorted. */
44 void q_check (sortable_t*, const int);
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);
50 /* Sort n_elems entries in 'values' */
51 void q_sort (sortable_t*, const int);
53 /* Merge two sorted lists */
54 sortable_t *q_merge (sortable_t*, const int,
55 sortable_t*, const int);
60 /* Allocate a new qset with initial space for up to n_elems. */
61 qset_t *qset_new (const int);
63 /* Sort the entries of the given qset. */
64 void qset_sort (qset_t*);
66 /* Compact a qset to take up no more space than required. */
67 void qset_compact (qset_t*);
69 /* Free the memory associated with the given qset */
70 void qset_delete (qset_t*);
72 /* Test whether the given qset contains the given value. */
73 int qset_contains (qset_t*, sortable_t);
75 /* Delete the given value from the given qset (if it exists) */
76 void qset_remove (qset_t*, sortable_t);
78 /* Insert the given elem into the given qset. */
79 void qset_insert (qset_t*, sortable_t);
81 /* Insert all elems of qset2 into qset1. qset2 is deleted. */
82 void qset_insert_all (qset_t*, qset_t*);
84 /* Compare two qsets. */
85 int qset_compare (qset_t*, qset_t*);
87 /* Returns the union of two qsets. */
88 qset_t *qset_union (qset_t *qset1, qset_t *qset2);
90 /* Report the size of the given qset. */
91 int qset_size (qset_t *qset);
93 /* Print the given qset to the given stream. */
94 void qset_print (qset_t*, FILE*);
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*);
104 #endif /* def _QSET_H_ */
108 Revision 1.1 2004/11/04 14:55:13 liekweg