diff options
author | Martin Mares <mj@ucw.cz> | 1998-04-22 14:58:34 +0200 |
---|---|---|
committer | Martin Mares <mj@ucw.cz> | 1998-04-22 14:58:34 +0200 |
commit | 58ef912c6babf1866193ab04674a5866dd761f13 (patch) | |
tree | 244af1a4acb9feac08b45800587a06653a6ff264 /lib/lists.h | |
parent | b60f7489148d021cb541414b8788f795ec4378fa (diff) | |
download | bird-58ef912c6babf1866193ab04674a5866dd761f13.tar bird-58ef912c6babf1866193ab04674a5866dd761f13.zip |
First look at data structures. More to come tomorrow...
Diffstat (limited to 'lib/lists.h')
-rw-r--r-- | lib/lists.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/lists.h b/lib/lists.h new file mode 100644 index 0000000..acc054d --- /dev/null +++ b/lib/lists.h @@ -0,0 +1,42 @@ +/* + * BIRD Library -- Linked Lists + * + * (c) 1998 Martin Mares <mj@ucw.cz> + * + * Can be freely distributed and used under the terms of the GNU GPL. + */ + +#ifndef _BIRD_LISTS_H_ +#define _BIRD_LISTS_H_ + +typedef struct node { + struct node *next, *prev; +} node; + +typedef struct list { /* In fact two overlayed nodes */ + struct node *head, *null, *tail; +} list; + +#define NODE (node *) +#define HEAD(list) ((void *)((list).head)) +#define TAIL(list) ((void *)((list).tail)) +#define WALK_LIST(n,list) for((n)=HEAD(list);(NODE (n))->next; \ + n=(void *)((NODE (n))->next)) +#define EMPTY_LIST(list) (!(list).head->next) + +void add_tail(list *, node *); +void add_head(list *, node *); +void rem_node(node *); +void add_tail_list(list *, list *); +void init_list(list *); +void insert_node(node *, node *); + +#ifndef _BIRD_LISTS_C_ +#define LIST_INLINE extern inline +#include <lib/lists.c> +#undef LIST_INLINE +#else +#define LIST_INLINE +#endif + +#endif |