1 /*----------------------------------------------------------------- 2 SDCCset.h - contains support routines for doubly linked lists. 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 replaceSetItem (set *, void *olditem, void *newitem); 57 void deleteItemIf (set **, int (*cond) (void *, va_list),...); 58 void destructItemIf (set **, void (*destructor)(void *), int (*cond) (void *, va_list),...); 59 int isinSet (const set *, const void *); 60 typedef int (* insetwithFunc) (void *, void *); 61 int isinSetWith (set *, void *, insetwithFunc cfunc); 62 int applyToSet (set * list, int (*somefunc) (void *, va_list),...); 63 int applyToSetFTrue (set * list, int (*somefunc) (void *, va_list),...); 64 void mergeSets (set **sset, set *list); 65 set *unionSets (set *, set *, int); 66 set *unionSetsWith (set *, set *, int (*cFunc) (), int); 67 set *intersectSets (set *, set *, int); 68 void *addSetIfnotP (set **, void *); 69 set *setFromSet (const set *); 70 set *setFromSetNonRev (const set *); 71 int isSetsEqual (const set *, const set *); 72 set *subtractFromSet (set *, set *, int); 73 int elementsInSet (const set *); 74 void *indexSet(set *, int); 75 set *intersectSetsWith (set *, set *, int (*cFunc) (void *, void *), int); 76 int isSetsEqualWith (set *, set *, int (*cFunc) (void *, void *)); 77 void *peekSet (const set *); 78 void *setFirstItem (set *); 79 void *setNextItem (set *); 80 void setToNull (void **); 81 set *reverseSet (set *); 82 void deleteSet (set **s); 83 84 #endif 85