## camel-list-utils

camel-list-utils

## Synopsis

                        CamelDList;
                        CamelDListNode;
    #define             CAMEL_DLIST_INITIALISER             (l)
    void                camel_dlist_init                    (CamelDList *v);
    CamelDListNode *    camel_dlist_addhead                 (CamelDList *l,
                                                             CamelDListNode *n);
    CamelDListNode *    camel_dlist_addtail                 (CamelDList *l,
                                                             CamelDListNode *n);
    CamelDListNode *    camel_dlist_remove                  (CamelDListNode *n);
    CamelDListNode *    camel_dlist_remhead                 (CamelDList *l);
    CamelDListNode *    camel_dlist_remtail                 (CamelDList *l);
    gint                camel_dlist_empty                   (CamelDList *l);
    gint                camel_dlist_length                  (CamelDList *l);
                        CamelSListNode;
                        CamelSList;
    #define             CAMEL_SLIST_INITIALISER             (l)
    void                camel_slist_init                    (CamelSList *l);
    CamelSListNode *    camel_slist_addhead                 (CamelSList *l,
                                                             CamelSListNode *n);
    CamelSListNode *    camel_slist_addtail                 (CamelSList *l,
                                                             CamelSListNode *n);
    CamelSListNode *    camel_slist_remove                  (CamelSList *l,
                                                             CamelSListNode *n);
    CamelSListNode *    camel_slist_remhead                 (CamelSList *l);
    CamelSListNode *    camel_slist_remtail                 (CamelSList *l);
    gint                camel_slist_empty                   (CamelSList *l);
    gint                camel_slist_length                  (CamelSList *l);

## Description

## Details

### CamelDList

    typedef struct {
    	struct _CamelDListNode *head;
    	struct _CamelDListNode *tail;
    	struct _CamelDListNode *tailpred;
    } CamelDList;

### CamelDListNode

    typedef struct {
    	struct _CamelDListNode *next;
    	struct _CamelDListNode *prev;
    } CamelDListNode;

### CAMEL_DLIST_INITIALISER()

    #define CAMEL_DLIST_INITIALISER(l) { (CamelDListNode *)&l.tail, NULL, (CamelDListNode *)&l.head }

`l` : |

### camel_dlist_init ()

    void                camel_dlist_init                    (CamelDList *v);

Initialise a double-linked list header. All list headers must be initialised before use.

### camel_dlist_addhead ()

    CamelDListNode *    camel_dlist_addhead                 (CamelDList *l,
                                                             CamelDListNode *n);

Add the list node `n` to the head (start) of the list `l`.

`l` : | An initialised list header.
`n` : | A node, the next and prev pointers will be overwritten.
Returns : | `n`.

### camel_dlist_addtail ()

    CamelDListNode *    camel_dlist_addtail                 (CamelDList *l,
                                                             CamelDListNode *n);

Add the list onde `n` to the tail (end) of the list `l`.

`l` : | An intialised list header.
`n` : | A node, the next and prev pointers will be overwritten.
Returns : | `n`.

### camel_dlist_remove ()

    CamelDListNode *    camel_dlist_remove                  (CamelDListNode *n);

Remove `n` from the list it's in. `n` must belong to a list.

`n` : | A node which is part of a list.
Returns : | `n`.

### camel_dlist_remhead ()

    CamelDListNode *    camel_dlist_remhead                 (CamelDList *l);

Remove the head node (start) of the list.

xReturn value: The previously first-node in the list, or NULLif `l` is an empty list.

`l` : | An initialised list, maybe containing items.
Returns : |

### camel_dlist_remtail ()

    CamelDListNode *    camel_dlist_remtail                 (CamelDList *l);

Remove the last node in the list.

`l` : | An initialised list, maybe containing items.
Returns : | The previously last-node in the list, or NULL if `l` is an empty list.

### camel_dlist_empty ()

    gint                camel_dlist_empty                   (CamelDList *l);

Returns `TRUE` if `l` is an empty list.

`l` : | An initialised list header.
Returns : | `TRUE` if `l` is an empty list, `FALSE` otherwise.

### camel_dlist_length ()

    gint                camel_dlist_length                  (CamelDList *l);

Returns the number of nodes in the list `l`.

`l` : | An initialised list header.
Returns : | The number of nodes.

### CamelSListNode

    typedef struct {
    	struct _CamelSListNode *next;
    } CamelSListNode;

### CamelSList

    typedef struct {
    	struct _CamelSListNode *head;
    } CamelSList;

### CAMEL_SLIST_INITIALISER()

    #define CAMEL_SLIST_INITIALISER(l) { 0 }

`l` : |

### camel_slist_init ()

    void                camel_slist_init                    (CamelSList *l);

`l` : |

### camel_slist_addhead ()

    CamelSListNode *    camel_slist_addhead                 (CamelSList *l,
                                                             CamelSListNode *n);

`l` : |
`n` : |
Returns : |

### camel_slist_addtail ()

    CamelSListNode *    camel_slist_addtail                 (CamelSList *l,
                                                             CamelSListNode *n);

`l` : |
`n` : |
Returns : |

### camel_slist_remove ()

    CamelSListNode *    camel_slist_remove                  (CamelSList *l,
                                                             CamelSListNode *n);

`l` : |
`n` : |
Returns : |

### camel_slist_remhead ()

    CamelSListNode *    camel_slist_remhead                 (CamelSList *l);

`l` : |
Returns : |

### camel_slist_remtail ()

    CamelSListNode *    camel_slist_remtail                 (CamelSList *l);

`l` : |
Returns : |

### camel_slist_empty ()

    gint                camel_slist_empty                   (CamelSList *l);

`l` : |
Returns : |

### camel_slist_length ()

    gint                camel_slist_length                  (CamelSList *l);

`l` : |
Returns : |