Use 'ao-dbg' instead of 's51' to communicate with TeleMetrum
[fw/sdcc] / src / SDCCset.h
1 /*-----------------------------------------------------------------
2     SDCCset.h - contains support routines for sets .
3
4     Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998)
5
6     This program is free software; you can redistribute it and/or modify it
7     under the terms of the GNU General Public License as published by the
8     Free Software Foundation; either version 2, or (at your option) any
9     later version.
10     
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15     
16     You should have received a copy of the GNU General Public License
17     along with this program; if not, write to the Free Software
18     Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19     
20     In other words, you are welcome to use, share and improve this program.
21     You are forbidden to forbid anyone else to use, share and improve
22     what you give them.   Help stamp out software-hoarding!  
23 -------------------------------------------------------------------------*/
24
25 #ifndef SDCCSET_H
26 #define SDCCSET_H
27 #include <stdarg.h>
28
29
30 #ifndef THROWS
31 #define THROWS
32 #define THROW_NONE  0
33 #define THROW_SRC   1
34 #define THROW_DEST  2
35 #define THROW_BOTH  3
36 #endif
37
38 /* linear linked list generic */
39 typedef struct set
40   {
41     void *item;
42     struct set *curr;
43     struct set *next;
44   }
45 set;
46
47 #define DEFSETFUNC(fname)  int fname ( void *item, va_list ap)
48 #define V_ARG(type,var) type var = va_arg(ap,type)
49
50 /* set related functions */
51 set *newSet (void);
52 void *addSet (set **, void *);
53 void *addSetHead (set **, void *);
54 void *getSet (set **);
55 void deleteSetItem (set **, void *);
56 void deleteItemIf (set **, int (*cond) (void *, va_list),...);
57 int isinSet (set *, void *);
58 typedef int (* insetwithFunc) (void *, void *);
59 int isinSetWith (set *, void *, insetwithFunc cfunc);
60 int applyToSet (set * list, int (*somefunc) (void *, va_list),...);
61 int applyToSetFTrue (set * list, int (*somefunc) (void *, va_list),...);
62 void mergeSets (set **sset, set *list);
63 set *unionSets (set *, set *, int);
64 set *unionSetsWith (set *, set *, int (*cFunc) (), int);
65 set *intersectSets (set *, set *, int);
66 void *addSetIfnotP (set **, void *);
67 set *setFromSet (set *);
68 set *setFromSetNonRev (set *);
69 int isSetsEqual (set *, set *);
70 set *subtractFromSet (set *, set *, int);
71 int elementsInSet (set *);
72 void *indexSet(set *, int);
73 set *intersectSetsWith (set *, set *, int (*cFunc) (void *, void *), int);
74 int isSetsEqualWith (set *, set *, int (*cFunc) (void *, void *));
75 void *peekSet (set *);
76 void *setFirstItem (set *);
77 void *setNextItem (set *);
78 void setToNull (void **);
79 set *reverseSet (set *);
80 void deleteSet (set **s);
81
82 #endif