1 #ifndef TP_FPA2_H 2 #define TP_FPA2_H 3 4 /* The objects in FPA lists are pointers to terms, and the lists 5 are ordered (decreasing) by fpa_id field in terms. 6 7 The code was originally written and debugged with integers instead; 8 hence, the following, which makes it easy to change back to ints. 9 */ 10 11 #define FTYPE struct term * 12 #define FDEFAULT NULL 13 14 #define FLT(x,y) ((x)->fpa_id < (y)->fpa_id) 15 #define FGT(x,y) ((x)->fpa_id > (y)->fpa_id) 16 #define FLE(x,y) ((x)->fpa_id <= (y)->fpa_id) 17 #define FGE(x,y) ((x)->fpa_id >= (y)->fpa_id) 18 #define FEQ(x,y) ((x) == (y)) 19 #define FNE(x,y) ((x) != (y)) 20 21 #define FTERM(p) ((p).f == NULL ? NULL : (p).f->d[(p).i]) 22 23 /* A chunk of an FPA list */ 24 25 #define FMAX 400 /* maximum number of items per chunk */ 26 27 typedef struct fnode *Fnode; 28 29 struct fnode { 30 FTYPE d[FMAX]; /* array for chunk */ 31 int n; /* current size of chunk (right justified in array) */ 32 Fnode next; /* list of chunks is singly-linked */ 33 }; 34 35 36 /* to maintain a position in an FPA list */ 37 38 struct fposition { 39 Fnode f; 40 int i; 41 }; 42 43 /* function prototypes */ 44 45 Fnode flist_insert(Fnode f, FTYPE x); 46 Fnode flist_delete(Fnode f, FTYPE x); 47 struct fposition first_fpos(Fnode f); 48 struct fposition next_fpos(struct fposition p); 49 50 #endif /* conditional compilation of whole file */ 51