xdasd_list.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00039 #ifndef XDASD_LIST_H_INCLUDED
00040 #define XDASD_LIST_H_INCLUDED
00041
00049 #define XDL_IS_HEAD(x) ((x)->isHead)
00050
00053 #define XDL_IS_EMPTY(h) \
00054 ((((h)->next == (h)) && ((h)->prev == (h)) )? 1: 0)
00055
00058 #define XDL_INSERT(n,x) \
00059 {(n)->prev = (x); \
00060 (n)->next = (x)->next; \
00061 (x)->next->prev = (n); \
00062 (x)->next = (n);}
00063
00066 #define XDL_INSERT_AFTER XDL_INSERT
00067
00070 #define XDL_INSERT_BEFORE(n,x)\
00071 {(n)->next = (x); \
00072 (n)->prev = (x)->prev; \
00073 (x)->prev->next = (n); \
00074 (x)->prev = (n);}
00075
00078 #define XDL_INSERT_WORKNODE_LAST(n,x) \
00079 {gettimeofday(&((n)->timer)); \
00080 (n)->next = (x); \
00081 (n)->prev = (x)->prev; \
00082 (x)->prev->next = (n); \
00083 (x)->prev = (n);}
00084
00087 #define XDL_INSERT_WORKNODE_FIRST(n,x) \
00088 {gettimeofday(&((n)->timer)); \
00089 (n)->prev = (x); \
00090 (n)->next = (x)->next; \
00091 (x)->next->prev = (n); \
00092 (x)->next = (n);}
00093
00096 #define XDL_UNLINK(x) \
00097 {(x)->prev->next = (x)->next; \
00098 (x)->next->prev = (x)->prev;}
00099
00102 #define XDL_IS_LAST(h,x) \
00103 (((x)->prev == (h) && (h)->prev == (x))? 1: 0)
00104
00107 #define XDL_IS_FIRST(h,x) \
00108 (((x)->prev == (h) && (h)->next == (x))? 1: 0)
00109
00112 #define XDL_IS_ONLY(h,x) \
00113 (((x)->next == (h) && (h)->prev == (x))? 1: 0)
00114
00117 #define XDL_LINK_HEAD(d,s) \
00118 {(d)->next = (s)->next; \
00119 (d)->prev = (s)->prev; \
00120 (s)->next->prev = (d); \
00121 (s)->prev->next = (d);}
00122
00125 typedef struct XDLItem_tag
00126 {
00127 struct XDLItem_tag * prev;
00128 struct XDLItem_tag * next;
00129 } XDLItem;
00130
00133 typedef struct XDList_tag
00134 {
00135 XDLItem * head;
00136 XDLItem * tail;
00137 int count;
00138 } XDList;
00139
00140 XDLItem * xdasd_list_unlink(XDList * list, XDLItem * item);
00141 XDLItem * xdasd_list_link_head(XDList * list, XDLItem * item);
00142 XDLItem * xdasd_list_link_tail(XDList * list, XDLItem * item);
00143
00147 #endif
00148