00001
00002
00003
00004
00005
00006
00007
00008 #ifndef LIST_H
00009 #define LIST_H
00010
00011 struct list_node {
00012 void *data;
00013 struct list_node *next;
00014 struct list_node *prev;
00015 };
00016
00017 struct list {
00018 struct list_node *head;
00019 struct list_node *tail;
00020 int size;
00021 };
00022
00023 typedef int (*list_op_t) ( void *item, const void *arg );
00024
00025 struct list * list_create();
00026 struct list * list_splice( struct list *top, struct list *bottom );
00027 void list_delete( struct list *l );
00028 int list_size( struct list *l );
00029
00030 int list_push_head( struct list *l, void *item );
00031 void * list_pop_head( struct list *l );
00032 void * list_peek_head( struct list *l );
00033
00034 int list_push_tail( struct list *l, void *item );
00035 void * list_pop_tail( struct list *l );
00036 void * list_peek_tail( struct list *l );
00037
00038 void * list_remove( struct list *l, const void *value );
00039 void * list_find( struct list *l, list_op_t cmp, const void *arg );
00040 int list_iterate( struct list *l, list_op_t op, const void *arg );
00041 int list_iterate_reverse( struct list *l, list_op_t op, const void *arg );
00042
00043 #endif