]> mj.ucw.cz Git - libucw.git/blobdiff - lib/lists.h
Added bfilesync().
[libucw.git] / lib / lists.h
index 48b7de99c0dd01c58d2ef15125c1bd38b8c269a3..68c7497f1cde8dcae6415050f839c8df406d84ca 100644 (file)
@@ -1,12 +1,28 @@
 /*
  *     Sherlock Library -- Linked Lists
  *
 /*
  *     Sherlock Library -- Linked Lists
  *
- *     (c) 1997--1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ *     (c) 1997--1999 Martin Mares <mj@ucw.cz>
+ *
+ *     This software may be freely distributed and used according to the terms
+ *     of the GNU Lesser General Public License.
  */
 
 #ifndef _SHERLOCK_LISTS_H
 #define _SHERLOCK_LISTS_H
 
  */
 
 #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;
 typedef struct node {
   struct node *next, *prev;
 } node;