/[ascend]/trunk/base/generic/compiler/setinstval.h
ViewVC logotype

Annotation of /trunk/base/generic/compiler/setinstval.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 11 - (hide annotations) (download) (as text)
Sat Nov 13 16:45:56 2004 UTC (19 years, 11 months ago) by aw0a
File MIME type: text/x-chdr
File size: 7418 byte(s)
moving things to base/generic
1 aw0a 1 /*
2     * Routines to Process Set Instance Values
3     * by Tom Epperly
4     * 11/16/89
5     * Version: $Revision: 1.7 $
6     * Version control file: $RCSfile: setinstval.h,v $
7     * Date last modified: $Date: 1998/02/05 16:37:52 $
8     * Last modified by: $Author: ballan $
9     *
10     * This file is part of the Ascend Language Interpreter.
11     *
12     * Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly
13     *
14     * The Ascend Language Interpreter is free software; you can redistribute
15     * it and/or modify it under the terms of the GNU General Public License as
16     * published by the Free Software Foundation; either version 2 of the
17     * License, or (at your option) any later version.
18     *
19     * The Ascend Language Interpreter is distributed in hope that it will be
20     * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
21     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22     * General Public License for more details.
23     *
24     * You should have received a copy of the GNU General Public License along
25     * with the program; if not, write to the Free Software Foundation, Inc., 675
26     * Mass Ave, Cambridge, MA 02139 USA. Check the file named COPYING.
27     *
28     *
29     * This group of routines is used to process the value fields of set
30     * instances.
31     */
32    
33    
34     /*
35     * When #including setinstval.h, make sure these files are #included first:
36     * #include "compiler.h"
37     */
38    
39    
40     #ifndef __SETINSTVAL_H_SEEN__
41     #define __SETINSTVAL_H_SEEN__
42     /* requires
43     # #include <stdio.h>
44     # #include"compiler.h"
45     # #include"list.h"
46     */
47     enum set_kind {
48     integer_set, /* set of integer values */
49     string_set, /* set of string values */
50     empty_set /* set with nothing in it */
51     };
52    
53     /* Do not confuse this set with the struct Set in types.h */
54     struct set_t {
55     enum set_kind kind;
56     struct gl_list_t *list;
57     };
58    
59     extern void InitSetManager(void);
60     /*
61     * We pool the set stubs for reuse, since there are so many used in
62     * most ASCEND models of any complexity.
63     * This function initializes the pool.
64     * The pool grows as needed. It does not shrink until destroyed.
65     * It is a fatal error to call this a second time unless
66     * DestroySetManager has been called first.
67     * In the pooling operation we only keep the set stubs, not the
68     * gl_lists associated.
69     *
70     * This exits if it cannot init the pool because of insufficient
71     * memory.
72     */
73    
74     extern void DestroySetManager(void);
75     /*
76     * Destroys the set pool. Bombs if no pool exists.
77     */
78    
79     extern void ReportSetManager(FILE*);
80     /*
81     * ReportSetManager(f);
82     * FILE *f;
83     * Reports on the set pool to f.
84     */
85    
86     extern struct set_t *CreateEmptySet(void);
87     /*
88     * struct set_t *CreateEmptySet()
89     * Creates an empty set.
90     */
91    
92     extern void InsertInteger(struct set_t *,long);
93     /*
94     * void InsertInteger(set,i)
95     * struct set_t *set;
96     * long i;
97     * Insert i into set. You can insert i multiple times without causing
98     * problems. Set must be non-NULL. This will coerce an empty set type
99     * into an integer set type; after that no symbols can be inserted into
100     * the set.
101     */
102    
103     extern void InsertIntegerRange(struct set_t *,long,long);
104     /*
105     * struct InsertIntegerRange(set,lower,upper)
106     * struct set_t *set;
107     * long lower, upper;
108     * Inser the elements i such that i >= lower and i <= upper. Note if
109     * lower > upper, no elements are inserted. This will coerce an empty
110     * set type into an integer set type.
111     */
112    
113     extern void InsertString(struct set_t *,symchar *);
114     /*
115     * struct InsertString(set,str)
116     * struct set_t *set;
117     * symchar *str;
118     * Insert str into set. This will coerce an empty set type into
119     * a string set type; after which no integers can be inserted.
120     */
121    
122     extern struct set_t *SetUnion(CONST struct set_t *,CONST struct set_t *);
123     /*
124     * struct set_t *SetUnion(s1,s2)
125     * const struct set_t *s1,*s2;
126     * Create a set which is the union of s1 and s2. s1 and s2 are uneffected.
127     * Union with empty set is always okay.
128     */
129    
130     extern struct set_t *SetIntersection(CONST struct set_t *,
131     CONST struct set_t *);
132     /*
133     * struct set_t *SetIntersection(s1,s2);
134     * const struct set_t *s1,*s2;
135     * Create a set which is the intersection of s1 and s2. s1 and s2 are
136     * uneffected. Intersection with empty set is okay.
137     */
138    
139     extern struct set_t *SetDifference(CONST struct set_t *,CONST struct set_t *);
140     /*
141     * struct set_t *SetDifference(s1,s2)
142     * const struct set_t *s1,*s2;
143     * Create a set which is define as follows:
144     * return set := { i | (i IN s1) and (NOT (i IN s2))}
145     */
146    
147     extern struct set_t *CopySet(CONST struct set_t *);
148     /*
149     * struct set_t *CopySet(set)
150     * const struct set_t *set;
151     */
152    
153     extern int IntMember(long,CONST struct set_t *);
154     /*
155     * int IntMember(i,set)
156     * long i;
157     * const struct set_t *set;
158     * Return a TRUE value if i is a member of set; otherwise, return a false
159     * value.
160     */
161    
162     extern int StrMember(symchar *,CONST struct set_t *);
163     /*
164     * int StrMember(str,set)
165     * symchar *str;
166     * const struct set_t *set;
167     * Return a TRUE value if str is a member of set; otherwise, return a false
168     * value.
169     */
170    
171     extern void DestroySet(struct set_t *);
172     /*
173     * "Free up" set pointer. Actually returns it to the pool of set stubs.
174     */
175    
176     extern int NullSet(CONST struct set_t *);
177     /*
178     * Testing if the set is empty. TRUE if set is empty.
179     */
180    
181     extern unsigned long Cardinality(CONST struct set_t *);
182     /*
183     * Return the number of members.
184     */
185    
186     extern symchar *FetchStrMember(CONST struct set_t *,unsigned long);
187     /*
188     * returns the nth (internal sort order ) member symbol.
189     */
190    
191     extern long FetchIntMember(CONST struct set_t *,unsigned long);
192    
193     extern void SetIterate(struct set_t *,void (*)());
194     /*
195     *
196     */
197    
198     extern enum set_kind SetKind(CONST struct set_t *);
199     /*
200     * Returns the type of the set.
201     */
202    
203     extern int SetsEqual(CONST struct set_t *,CONST struct set_t *);
204     /*
205     * int SetsEqual(s1,s2)
206     * const struct set_t *s1,*s2;
207     * Returns a true value if the two sets are equal. Set equality is
208     * defined as:
209     * (i IN s1) <==> (i IN s2)
210     * This always returns FALSE if the sets are of different type.
211     */
212    
213     extern int Subset(CONST struct set_t *,CONST struct set_t *);
214     /*
215     * int Subset(s1,s2);
216     * struct set_t *s1,*s2;
217     * Returns a true value if s1 is contained in s2. It always returns FALSE
218     * if the sets are of different type(even if they are empty sets).
219     *
220     * TRUE if (i IN s1) ==> (i IN s2)
221     * FALSE otherwise
222     */
223    
224     extern int CmpSetInstVal(CONST struct set_t *, CONST struct set_t *);
225     /*
226     * int CmpSetInstVal(s1,s2)
227     * struct set_t *s1,*s2;
228     * Returns -1, 0, 1 from comparing s1,s2.
229     */
230    
231    
232     /*
233     * Some ordered set processing. The elements of the below sets are
234     * not necessarily unique and not necessarily ordered. In this way they
235     * behave more like lists. For TRUE sets use the InsertInteger and
236     * InsertString functions above.
237     */
238    
239     extern void AppendIntegerElement(struct set_t *, long int);
240     /*
241     * void AppendIntegerElement(set,i);
242     * struct set_t *set;
243     * long int i;
244     * This function will append an integer to a set. In so doing it will NOT
245     * attempt to sort the elements of the set or to make the elements of the
246     * set unique. In this way the set is treated as a list.
247     */
248    
249     extern void AppendStringElement(struct set_t *, symchar *);
250     /*
251     * struct set_t *set;
252     * symchar *str;
253     * This function will append an string to a set. In so doing it will NOT
254     * attempt to sort the elements of the set or to make the elements of the
255     * set unique. In this way the set is treated as a list.
256     */
257    
258     #endif /* __SETINSTVAL_H_SEEN__ */

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22