X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Flists.h;h=fa9599aa9f8e943b527d9d200ea3e686d3bcb158;hb=2e2adfa5d7ac912434bef5b8a9b25cfb14d4a4a6;hp=48b7de99c0dd01c58d2ef15125c1bd38b8c269a3;hpb=298dd2b1d1133d144dd4ec92034eff9dad8fa449;p=libucw.git diff --git a/lib/lists.h b/lib/lists.h index 48b7de99..fa9599aa 100644 --- a/lib/lists.h +++ b/lib/lists.h @@ -1,12 +1,25 @@ /* * Sherlock Library -- Linked Lists * - * (c) 1997--1999 Martin Mares + * (c) 1997--1999 Martin Mares */ #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;