Main Page   Class Hierarchy   Compound List   File List   Compound Members  

dllist.h

00001 #ifndef DLLIST_H
00002 #define DLLIST_H
00003 
00004 #if defined( __GNUC__ ) && !defined( __cplusplus )
00005 #define inline __inline__
00006 #endif
00007 
00008 struct dl_node
00009 {
00010     struct dl_node *next;
00011     struct dl_node *prev;
00012 };
00013 
00014 struct dl_head
00015 {
00016     struct dl_node *first;
00017     struct dl_node *null;
00018     struct dl_node *last;
00019 };
00020 
00021 static inline struct dl_head *
00022 dl_init(struct dl_head *h)
00023 {
00024     h->first = (struct dl_node *)&h->null;
00025     h->null = 0;
00026     h->last = (struct dl_node *)&h->first;
00027     return h;
00028 }
00029 
00030 static inline struct dl_node *
00031 dl_remove(struct dl_node *n)
00032 {
00033     n->prev->next = n->next;
00034     n->next->prev = n->prev;
00035     return n;
00036 }
00037 
00038 static inline struct dl_node *
00039 dl_insert_after(struct dl_node *p, struct dl_node *n)
00040 {
00041     n->next = p->next;
00042     n->prev = p;
00043     p->next = n;
00044     n->next->prev = n;
00045     return n;
00046 }
00047 
00048 #define dl_empty(h)             ((h)->first->next == 0)
00049 #define dl_insert_before(p, n)  dl_insert_after((p)->prev, (n))
00050 #define dl_insert_first(h, n)   ({ struct dl_node *_n = (n); \
00051                                         dl_insert_before((h)->first, _n); })
00052 #define dl_insert_last(h, n)    ({ struct dl_node *_n = (n); \
00053                                         dl_insert_after((h)->last, _n); })
00054 #define dl_remove_first(h)      dl_remove((h)->first) /* mustn't be empty! */
00055 #define dl_remove_last(h)       dl_remove((h)->last) /* mustn't be empty! */
00056 
00057 #endif /* DLLIST_H */

Generated at Thu Jan 30 02:56:02 2003 for QtVision by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001