RNAlib-2.0.4
|
00001 /* 00002 $Log: list.h,v $ 00003 Revision 1.2 2000/10/10 08:50:01 ivo 00004 some annotation for lclint 00005 00006 Revision 1.1 1997/08/04 21:05:32 walter 00007 Initial revision 00008 00009 */ 00010 00011 #ifndef __LIST_H 00012 #define __LIST_H 00013 00014 /*---------------------- Macros and type definitions ----------------------*/ 00015 00016 typedef struct LST_BUCKET { 00017 struct LST_BUCKET *next; 00018 } 00019 LST_BUCKET; 00020 00021 typedef struct { 00022 int count; /* Number of elements currently in list */ 00023 LST_BUCKET *head; /* Pointer to head element of list */ 00024 LST_BUCKET *z; /* Pointer to last node of list */ 00025 LST_BUCKET hz[2]; /* Space for head and z nodes */ 00026 } 00027 LIST; 00028 00029 /* Return a pointer to the user space given the address of the header of 00030 * a node. 00031 */ 00032 00033 #define LST_USERSPACE(h) ((void*)((LST_BUCKET*)(h) + 1)) 00034 00035 /* Return a pointer to the header of a node, given the address of the 00036 * user space. 00037 */ 00038 00039 #define LST_HEADER(n) ((LST_BUCKET*)(n) - 1) 00040 00041 /* Return a pointer to the user space of the list's head node. This user 00042 * space does not actually exist, but it is useful to be able to address 00043 * it to enable insertion at the start of the list. 00044 */ 00045 00046 #define LST_HEAD(l) LST_USERSPACE((l)->head) 00047 00048 /* Determine if a list is empty 00049 */ 00050 00051 #define LST_EMPTY(l) ((l)->count == 0) 00052 00053 /*-------------------------- Function Prototypes --------------------------*/ 00054 00055 /*@only@*//*@out@*/ void *lst_newnode (int size); 00056 void lst_freenode (/*@only@*/ void *node); 00057 /*@only@*//*@out@*/ LIST *lst_init (void); 00058 void lst_kill (LIST * l, void (*freeNode) ()); 00059 void lst_insertafter (LIST * l, /*@keep@*/ void *node, void *after); 00060 void *lst_deletenext (/*@only@*/ LIST * l, void *node); 00061 /*@dependent@*/ void *lst_first (LIST * l); 00062 /*@dependent@*/ void *lst_next (void *prev); 00063 void lst_mergesort (LIST * l, int (*cmp_func) ()); 00064 00065 #endif