#ifndef LLRH #define LLRH /********************************************************************************************** * * List Library 1.0 (LLR 1.0) * * Associated files: * * llr.c llr.h * * Programmer: * * Lluís Ros (c) 1995-2007 * Institut de Robōtica i Informātica Industrial (CSIC-UPC) * Llorens Artigas 4-6, 2a planta * 08028 Barcelona * Web: http://www-iri.upc.es/people/ros * E-mail: llros@iri.upc.es * * What is LLR? * * LLR (List Library) is a suite of functions to handle lists of any kind (the list * type is implemented as a "polymorphic" type). * * Conditions of use: * * Most routines have directly been taken from the book by Jeffrey Esakov & Tom Weiss * "Data Structures, an Advanced Approach Using C" and, hence, the code in llr.c and * llr.h may be considered as open source with any restrictions of use applicable to * the code in the previous book. The programmer above assumes no responsibility of * any kind for any trouble or damage induced by the use of this code by anyone. * * Acknowledgements: * * Special thanks to Pablo Jimenez, Manel Guerris, Albert Castellet, Gorka Bonals, and * Josep M. Porta for using LLR on different contexts, and for suggesting improvements * to the code. * ***********************************************************************************************/ #include "general.h" /* * List types and prototypes */ typedef struct node node; typedef struct node* list; struct node { generic_ptr datapointer; list next; }; /* * List type accessor macros */ #define DATA(L) ((L)->datapointer) #define NEXT(L) ((L)->next) /* * Prototypes of public operations of the list abstract data type */ status init_list(list *p_L); boolean empty_list(list L); status append(list *p_L, generic_ptr data); status insert(list *p_L, generic_ptr data); status delete_first(list* p_L, generic_ptr* p_data, void (*p_func_f)(void*)); status delete_node(list* p_L, list node, void (*p_func_f)(void*)); status find_key(list L, generic_ptr key, int (*p_cmp_f)(generic_ptr,generic_ptr), list* p_keynode); list list_iterator(list L, list lastreturn); void destroy_list(list* p_L, void (*p_func_f)(void*)); int length(list L); list last(list L); list first(list L); void free_node(list *p_L); status concatenate(list* p_list1, list* p_list2); void print_prolog_list(FILE* fd, list alist, void (*p_print_funct)(FILE*,list)); status copy_list(list List1, list* p_List2, status (*p_cp_dat)(generic_ptr,generic_ptr*)); #endif /* LLRH */