]> mj.ucw.cz Git - libucw.git/blobdiff - lib/lists.h
Initial version of SQL gathering utility gsql added.
[libucw.git] / lib / lists.h
index 0c0ab0f6069b6c57c01832626ae4559c93c07579..fa9599aa9f8e943b527d9d200ea3e686d3bcb158 100644 (file)
@@ -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;