X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Flists.h;h=fa9599aa9f8e943b527d9d200ea3e686d3bcb158;hb=2e2adfa5d7ac912434bef5b8a9b25cfb14d4a4a6;hp=0c0ab0f6069b6c57c01832626ae4559c93c07579;hpb=1571781022499a9d0c32d249f89945d034d1cbff;p=libucw.git diff --git a/lib/lists.h b/lib/lists.h index 0c0ab0f6..fa9599aa 100644 --- a/lib/lists.h +++ b/lib/lists.h @@ -7,6 +7,19 @@ #ifndef _SHERLOCK_LISTS_H #define _SHERLOCK_LISTS_H +/* + * I admit the list structure is very tricky and also somewhat awkward, + * but it's both efficient and easy to manipulate once one understands the + * basic trick: The list head always contains two synthetic nodes which are + * always present in the list: the head and the tail. But as the `next' + * entry of the tail and the `prev' entry of the head are both NULL, the + * nodes can overlap each other: + * + * head head_node.next + * null head_node.prev tail_node.next + * tail tail_node.prev + */ + typedef struct node { struct node *next, *prev; } node;