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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 33 by ben.allan, Sun Dec 26 20:06:01 2004 UTC revision 54 by jds, Tue Aug 2 11:20:09 2005 UTC
# Line 1  Line 1 
1  /**<  /*
2   *  Routines to Process Set Instance Values   *  Routines to Process Set Instance Values
3   *  by Tom Epperly   *  by Tom Epperly
4   *  11/16/89   *  11/16/89
# Line 24  Line 24 
24   *  You should have received a copy of the GNU General Public License along   *  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   *  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.   *  Mass Ave, Cambridge, MA 02139 USA.  Check the file named COPYING.
27   *   */
28    
29    /** @file
30     *  Routines to Process Set Instance Values.
31   *   *
32   *  This group of routines is used to process the value fields of set   *  This group of routines is used to process the value fields of set
33   *  instances.   *  instances.
34   */   *  <pre>
   
   
 /**<  
35   *  When #including setinstval.h, make sure these files are #included first:   *  When #including setinstval.h, make sure these files are #included first:
36     *         #include <stdio.h>
37     *         #include "utilities/ascConfig.h"
38   *         #include "compiler.h"   *         #include "compiler.h"
39     *         #include "list.h"
40     *  </pre>
41   */   */
42    
   
43  #ifndef __SETINSTVAL_H_SEEN__  #ifndef __SETINSTVAL_H_SEEN__
44  #define __SETINSTVAL_H_SEEN__  #define __SETINSTVAL_H_SEEN__
45  /**< requires  
 # #include <stdio.h>  
 # #include"compiler.h"  
 # #include"list.h"  
 */  
46  enum set_kind {  enum set_kind {
47    integer_set,          /**< set of integer values */    integer_set,  /**< set of integer values */
48    string_set,           /**< set of string values */    string_set,   /**< set of string values */
49    empty_set         /**< set with nothing in it */    empty_set     /**< set with nothing in it */
50  };  };
51    
52  /**< Do not confuse this set with the struct Set in types.h */  /** Do not confuse this set with the struct Set in types.h */
53  struct set_t {  struct set_t {
54    enum set_kind kind;    enum set_kind kind;
55    struct gl_list_t *list;    struct gl_list_t *list;
# Line 58  struct set_t { Line 57  struct set_t {
57    
58  extern void InitSetManager(void);  extern void InitSetManager(void);
59  /**<  /**<
60     *  This function initializes the pool.
61   *  We pool the set stubs for reuse, since there are so many used in   *  We pool the set stubs for reuse, since there are so many used in
62   *  most ASCEND models of any complexity.   *  most ASCEND models of any complexity.
  *  This function initializes the pool.  
63   *  The pool grows as needed. It does not shrink until destroyed.   *  The pool grows as needed. It does not shrink until destroyed.
64   *  It is a fatal error to call this a second time unless   *  It is a fatal error to call this a second time unless
65   *  DestroySetManager has been called first.   *  DestroySetManager has been called first.
66   *  In the pooling operation we only keep the set stubs, not the   *  In the pooling operation we only keep the set stubs, not the
67   *  gl_lists associated.   *  gl_lists associated.<br><br>
68   *   *
69   *  This exits if it cannot init the pool because of insufficient   *  This exits if it cannot init the pool because of insufficient
70   *  memory.   *  memory.
# Line 76  extern void DestroySetManager(void); Line 75  extern void DestroySetManager(void);
75   *  Destroys the set pool. Bombs if no pool exists.   *  Destroys the set pool. Bombs if no pool exists.
76   */   */
77    
78  extern void ReportSetManager(FILE*);  extern void ReportSetManager(FILE*f);
79  /**<  /**<
80   *  ReportSetManager(f);   *  <!--  ReportSetManager(f);                                         -->
81   *  FILE *f;   *  <!--  FILE *f;                                                     -->
82   *  Reports on the set pool to f.   *  Reports on the set pool to f.
83   */   */
84    
85  extern struct set_t *CreateEmptySet(void);  extern struct set_t *CreateEmptySet(void);
86  /**<  /**<
87   *  struct set_t *CreateEmptySet()   *  <!--  struct set_t *CreateEmptySet()                               -->
88   *  Creates an empty set.   *  Creates an empty set.
89   */   */
90    
91  extern void InsertInteger(struct set_t *,long);  extern void InsertInteger(struct set_t *set, long i);
92  /**<  /**<
93   *  void InsertInteger(set,i)   *  <!--  void InsertInteger(set,i)                                    -->
94   *  struct set_t *set;   *  <!--  struct set_t *set;                                           -->
95   *  long i;   *  <!--  long i;                                                      -->
96   *  Insert i into set.  You can insert i multiple times without causing   *  Insert i into set.  You can insert i multiple times without causing
97   *  problems.  Set must be non-NULL.  This will coerce an empty set type   *  problems.  Set must be non-NULL.  This will coerce an empty set type
98   *  into an integer set type; after that no symbols can be inserted into   *  into an integer set type; after that no symbols can be inserted into
99   *  the set.   *  the set.
100   */   */
101    
102  extern void InsertIntegerRange(struct set_t *,long,long);  extern void InsertIntegerRange(struct set_t *set, long lower, long upper);
103  /**<  /**<
104   *  struct InsertIntegerRange(set,lower,upper)   *  <!--  struct InsertIntegerRange(set,lower,upper)                   -->
105   *  struct set_t *set;   *  <!--  struct set_t *set;                                           -->
106   *  long lower, upper;   *  <!--  long lower, upper;                                           -->
107   *  Inser the elements i such that i >= lower and i <= upper.  Note if   *  Insert the elements i such that i >= lower and i <= upper.  Note if
108   *  lower > upper, no elements are inserted.  This will coerce an empty   *  lower > upper, no elements are inserted.  This will coerce an empty
109   *  set type into an integer set type.   *  set type into an integer set type.
110   */   */
111    
112  extern void InsertString(struct set_t *,symchar *);  extern void InsertString(struct set_t *set, symchar *str);
113  /**<  /**<
114   *  struct InsertString(set,str)   *  <!--  struct InsertString(set,str)                                 -->
115   *  struct set_t *set;   *  <!--  struct set_t *set;                                           -->
116   *  symchar *str;   *  <!--  symchar *str;                                                -->
117   *  Insert str into set.  This will coerce an empty set type into   *  Insert str into set.  This will coerce an empty set type into
118   *  a string set type; after which no integers can be inserted.   *  a string set type; after which no integers can be inserted.
119   */   */
120    
121  extern struct set_t *SetUnion(CONST struct set_t *,CONST struct set_t *);  extern struct set_t *SetUnion(CONST struct set_t *s1, CONST struct set_t *s2);
122  /**<  /**<
123   *  struct set_t *SetUnion(s1,s2)   *  <!--  struct set_t *SetUnion(s1,s2)                                -->
124   *  const struct set_t *s1,*s2;   *  <!--  const struct set_t *s1,*s2;                                  -->
125   *  Create a set which is the union of s1 and s2.  s1 and s2 are uneffected.   *  Create a set which is the union of s1 and s2.  s1 and s2 are uneffected.
126   *  Union with empty set is always okay.   *  Union with empty set is always okay.
127   */   */
128    
129  extern struct set_t *SetIntersection(CONST struct set_t *,  extern struct set_t *SetIntersection(CONST struct set_t *s1,
130           CONST struct set_t *);                                       CONST struct set_t *s2);
131  /**<  /**<
132   *  struct set_t *SetIntersection(s1,s2);   *  <!--  struct set_t *SetIntersection(s1,s2);                        -->
133   *  const struct set_t *s1,*s2;   *  <!--  const struct set_t *s1,*s2;                                  -->
134   *  Create a set which is the intersection of s1 and s2.  s1 and s2 are   *  Create a set which is the intersection of s1 and s2.  s1 and s2 are
135   *  uneffected.  Intersection with empty set is okay.   *  uneffected.  Intersection with empty set is okay.
136   */   */
137    
138  extern struct set_t *SetDifference(CONST struct set_t *,CONST struct set_t *);  extern struct set_t *SetDifference(CONST struct set_t *s1, CONST struct set_t *s2);
139  /**<  /**<
140   *  struct set_t *SetDifference(s1,s2)   *  <!--  struct set_t *SetDifference(s1,s2)                           -->
141   *  const struct set_t *s1,*s2;   *  <!--  const struct set_t *s1,*s2;                                  -->
142   *  Create a set which is define as follows:   *  Create a set which is define as follows:
143   *  return set := { i | (i IN s1) and (NOT (i IN s2))}   *  return set := { i | (i IN s1) and (NOT (i IN s2))}
144   */   */
145    
146  extern struct set_t *CopySet(CONST struct set_t *);  extern struct set_t *CopySet(CONST struct set_t *set);
147  /**<  /**<
148   *  struct set_t *CopySet(set)   *  <!--  struct set_t *CopySet(set)                                   -->
149   *  const struct set_t *set;   *  <!--  const struct set_t *set;                                     -->
150     *  Copy a set.
151   */   */
152    
153  extern int IntMember(long,CONST struct set_t *);  extern int IntMember(long i, CONST struct set_t *set);
154  /**<  /**<
155   *  int IntMember(i,set)   *  <!--  int IntMember(i,set)                                         -->
156   *  long i;   *  <!--  long i;                                                      -->
157   *  const struct set_t *set;   *  <!--  const struct set_t *set;                                     -->
158   *  Return a TRUE value if i is a member of set; otherwise, return a false   *  Return a TRUE value if i is a member of set; otherwise, return a false
159   *  value.   *  value.
160   */   */
161    
162  extern int StrMember(symchar *,CONST struct set_t *);  extern int StrMember(symchar *str, CONST struct set_t *set);
163  /**<  /**<
164   *  int StrMember(str,set)   *  <!--  int StrMember(str,set)                                       -->
165   *  symchar *str;   *  <!--  symchar *str;                                                -->
166   *  const struct set_t *set;   *  <!--  const struct set_t *set;                                     -->
167   *  Return a TRUE value if str is a member of set; otherwise, return a false   *  Return a TRUE value if str is a member of set; otherwise, return a false
168   *  value.   *  value.
169   */   */
170    
171  extern void DestroySet(struct set_t *);  extern void DestroySet(struct set_t *set);
172  /**<  /**<  "Free up" set pointer. Actually returns it to the pool of set stubs. */
  *  "Free up" set pointer. Actually returns it to the pool of set stubs.  
  */  
173    
174  extern int NullSet(CONST struct set_t *);  extern int NullSet(CONST struct set_t *set);
175  /**<  /**<  Testing if the set is empty.  TRUE if set is empty. */
  *  Testing if the set is empty.  TRUE if set is empty.  
  */  
176    
177  extern unsigned long Cardinality(CONST struct set_t *);  extern unsigned long Cardinality(CONST struct set_t *set);
178  /**<  /**<  Return the number of members. */
  *  Return the number of members.  
  */  
179    
180  extern symchar *FetchStrMember(CONST struct set_t *,unsigned long);  extern symchar *FetchStrMember(CONST struct set_t *set, unsigned long n);
181  /**<  /**<  Returns the nth (internal sort order ) member symbol. */
  * returns the nth (internal sort order ) member symbol.  
  */  
182    
183  extern long FetchIntMember(CONST struct set_t *,unsigned long);  extern long FetchIntMember(CONST struct set_t *set, unsigned long n);
184    /**<  Returns the nth (internal sort order ) member number. */
185    
186  extern void SetIterate(struct set_t *,void (*)());  extern void SetIterate(struct set_t *set, void (*func)());
187  /**<  /**<  Calls func for every element in set. */
  *  
  */  
188    
189  extern enum set_kind SetKind(CONST struct set_t *);  extern enum set_kind SetKind(CONST struct set_t *set);
190  /**<  /**<  Returns the type of the set. */
  *  Returns the type of the set.  
  */  
191    
192  extern int SetsEqual(CONST struct set_t *,CONST struct set_t *);  extern int SetsEqual(CONST struct set_t *s1, CONST struct set_t *s2);
193  /**<  /**<
194   *  int SetsEqual(s1,s2)   *  <!--  int SetsEqual(s1,s2)                                         -->
195   *  const struct set_t *s1,*s2;   *  <!--  const struct set_t *s1,*s2;                                  -->
196   *  Returns a true value if the two sets are equal.  Set equality is   *  Returns a true value if the two sets are equal.  Set equality is
197   *  defined as:   *  defined as:
198   *  (i IN s1) <==> (i IN s2)   *  (i IN s1) <==> (i IN s2)
199   *  This always returns FALSE if the sets are of different type.   *  This always returns FALSE if the sets are of different type.
200   */   */
201    
202  extern int Subset(CONST struct set_t *,CONST struct set_t *);  extern int Subset(CONST struct set_t *s1, CONST struct set_t *s2);
203  /**<  /**<
204   *  int Subset(s1,s2);   *  <!--  int Subset(s1,s2);                                           -->
205   *  struct set_t *s1,*s2;   *  <!--  struct set_t *s1,*s2;                                        -->
206   *  Returns a true value if s1 is contained in s2.  It always returns FALSE   *  Returns a true value if s1 is contained in s2.  It always returns FALSE
207   *  if the sets are of different type(even if they are empty sets).   *  if the sets are of different type(even if they are empty sets).
208   *   *
209   *  TRUE  if (i IN s1) ==> (i IN s2)   *  - TRUE  if (i IN s1) ==> (i IN s2)
210   *  FALSE otherwise   *  - FALSE otherwise
211   */   */
212    
213  extern int CmpSetInstVal(CONST struct set_t *, CONST struct set_t *);  extern int CmpSetInstVal(CONST struct set_t *s1, CONST struct set_t *s2);
214  /**<  /**<
215   *  int CmpSetInstVal(s1,s2)   *  <!--  int CmpSetInstVal(s1,s2)                                     -->
216   *  struct set_t *s1,*s2;   *  <!--  struct set_t *s1,*s2;                                        -->
217   *  Returns -1, 0, 1 from comparing s1,s2.   *  Returns -1, 0, 1 from comparing s1,s2.
218   */   */
219    
220    /*
 /**<  
221   *  Some ordered set processing. The elements of the below sets are   *  Some ordered set processing. The elements of the below sets are
222   *  not necessarily unique and not necessarily ordered. In this way they   *  not necessarily unique and not necessarily ordered. In this way they
223   *  behave more like lists. For TRUE sets use the InsertInteger and   *  behave more like lists. For TRUE sets use the InsertInteger and
224   *  InsertString functions above.   *  InsertString functions above.
225   */   */
226    
227  extern void AppendIntegerElement(struct set_t *, long int);  extern void AppendIntegerElement(struct set_t *set, long int i );
228  /**<  /**<
229   *  void AppendIntegerElement(set,i);   *  <!--  void AppendIntegerElement(set,i);                            -->
230   *  struct set_t *set;   *  <!--  struct set_t *set;                                           -->
231   *  long int i;   *  <!--  long int i;                                                  -->
232   *  This function will append an integer to a set. In so doing it will NOT   *  This function will append an integer to a set. In so doing it will NOT
233   *  attempt to sort the elements of the set or to make the elements of the   *  attempt to sort the elements of the set or to make the elements of the
234   *  set unique. In this way the set is treated as a list.   *  set unique. In this way the set is treated as a list.
235   */   */
236    
237  extern void AppendStringElement(struct set_t *, symchar *);  extern void AppendStringElement(struct set_t *set, symchar *str);
238  /**<  /**<
239   *  struct set_t *set;   *  <!--  struct set_t *set;                                           -->
240   *  symchar *str;   *  <!--  symchar *str;                                                -->
241   *  This function will append an string to a set. In so doing it will NOT   *  This function will append an string to a set. In so doing it will NOT
242   *  attempt to sort the elements of the set or to make the elements of the   *  attempt to sort the elements of the set or to make the elements of the
243   *  set unique. In this way the set is treated as a list.   *  set unique. In this way the set is treated as a list.
244   */   */
245    
246  #endif /**< __SETINSTVAL_H_SEEN__ */  #endif /* __SETINSTVAL_H_SEEN__ */
247    

Legend:
Removed from v.33  
changed lines
  Added in v.54

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