gdsl  1.8
gdsl_list.h
Go to the documentation of this file.
00001 /*
00002  * This file is part of the Generic Data Structures Library (GDSL).
00003  * Copyright (C) 1998-2017 Nicolas Darnis <ndarnis@free.fr>.
00004  *
00005  * GDSL is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation, either version 3 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * GDSL is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with GDSL.  If not, see <http://www.gnu.org/licenses/>. 
00017  *
00018  * $RCSfile: gdsl_list.h,v $
00019  * $Revision: 1.26 $
00020  * $Date: 2015/02/17 12:22:57 $
00021  */
00022 
00027 #ifndef _GDSL_LIST_H_
00028 #define _GDSL_LIST_H_
00029 
00030 #include <stdio.h>
00031 
00032 #include "gdsl_types.h"
00033 
00034 #ifdef __cplusplus
00035 extern "C" 
00036 {
00037 #endif
00038 
00070 typedef struct _gdsl_list* gdsl_list_t;
00071 
00078 typedef struct _gdsl_list_cursor* gdsl_list_cursor_t;
00079 
00080 /******************************************************************************/
00081 /* Management functions of doubly-linked lists                                */
00082 /******************************************************************************/
00083 
00104 extern gdsl_list_t
00105 gdsl_list_alloc (const char* NAME,
00106          gdsl_alloc_func_t ALLOC_F,
00107          gdsl_free_func_t FREE_F
00108          );
00109 
00122 extern void 
00123 gdsl_list_free (gdsl_list_t L
00124         );
00125 
00139 extern void
00140 gdsl_list_flush (gdsl_list_t L
00141          );
00142 
00143 /******************************************************************************/
00144 /* Consultation functions of doubly-linked lists                              */
00145 /******************************************************************************/
00146 
00156 extern const char*
00157 gdsl_list_get_name (const gdsl_list_t L
00158             );
00159 
00167 extern ulong
00168 gdsl_list_get_size (const gdsl_list_t L
00169             );
00170 
00179 extern bool
00180 gdsl_list_is_empty (const gdsl_list_t L
00181             );
00182 
00193 extern gdsl_element_t
00194 gdsl_list_get_head (const gdsl_list_t L
00195             );
00196 
00207 extern gdsl_element_t
00208 gdsl_list_get_tail (const gdsl_list_t L
00209             );
00210 
00211 /******************************************************************************/
00212 /* Modification functions of doubly-linked lists                              */
00213 /******************************************************************************/
00214 
00228 extern gdsl_list_t
00229 gdsl_list_set_name (gdsl_list_t L,
00230             const char* NEW_NAME
00231             );
00232 
00251 extern gdsl_element_t
00252 gdsl_list_insert_head (gdsl_list_t L,
00253                void* VALUE
00254                );
00255 
00274 extern gdsl_element_t
00275 gdsl_list_insert_tail (gdsl_list_t L,
00276                void* VALUE
00277                );
00278 
00294 extern gdsl_element_t
00295 gdsl_list_remove_head (gdsl_list_t L
00296                );
00297 
00313 extern gdsl_element_t
00314 gdsl_list_remove_tail (gdsl_list_t L
00315                );
00316 
00335 extern gdsl_element_t
00336 gdsl_list_remove (gdsl_list_t L,
00337           gdsl_compare_func_t COMP_F,
00338           const void* VALUE
00339           );
00340 
00356 extern gdsl_list_t
00357 gdsl_list_delete_head (gdsl_list_t L
00358                );
00359 
00375 extern gdsl_list_t
00376 gdsl_list_delete_tail (gdsl_list_t L
00377                );
00378 
00397 extern gdsl_list_t
00398 gdsl_list_delete (gdsl_list_t L,
00399           gdsl_compare_func_t COMP_F,
00400           const void* VALUE
00401           );
00402 
00403 /******************************************************************************/
00404 /* Search functions of doubly-linked lists                                    */
00405 /******************************************************************************/
00406 
00424 extern gdsl_element_t
00425 gdsl_list_search (const gdsl_list_t L,
00426           gdsl_compare_func_t COMP_F,
00427           const void* VALUE
00428           );
00429 
00442 extern gdsl_element_t
00443 gdsl_list_search_by_position (const gdsl_list_t L,
00444                   ulong POS
00445                   );
00446 
00463 extern gdsl_element_t
00464 gdsl_list_search_max (const gdsl_list_t L,
00465               gdsl_compare_func_t COMP_F
00466               );
00467 
00484 extern gdsl_element_t
00485 gdsl_list_search_min (const gdsl_list_t L,
00486               gdsl_compare_func_t COMP_F
00487               );
00488 
00489 /******************************************************************************/
00490 /* Sort functions of doubly-linked lists                                      */
00491 /******************************************************************************/
00492 
00505 extern gdsl_list_t
00506 gdsl_list_sort (gdsl_list_t L,
00507         gdsl_compare_func_t COMP_F
00508         );
00509 
00510 /******************************************************************************/
00511 /* Parse functions of doubly-linked lists                                     */
00512 /******************************************************************************/
00513 
00531 extern gdsl_element_t
00532 gdsl_list_map_forward (const gdsl_list_t L,
00533                gdsl_map_func_t MAP_F,
00534                void* USER_DATA
00535                );
00536 
00554 extern gdsl_element_t
00555 gdsl_list_map_backward (const gdsl_list_t L,
00556             gdsl_map_func_t MAP_F,
00557             void* USER_DATA
00558             );
00559 
00560 /******************************************************************************/
00561 /* Input/output functions of doubly-linked lists                              */
00562 /******************************************************************************/
00563 
00579 extern void
00580 gdsl_list_write (const gdsl_list_t L,
00581          gdsl_write_func_t WRITE_F,
00582          FILE* OUTPUT_FILE,
00583          void* USER_DATA
00584          );
00585 
00602 extern void
00603 gdsl_list_write_xml (const gdsl_list_t L,
00604              gdsl_write_func_t WRITE_F,
00605              FILE* OUTPUT_FILE,
00606              void* USER_DATA
00607              );
00608 
00625 extern void
00626 gdsl_list_dump (const gdsl_list_t L,
00627         gdsl_write_func_t WRITE_F,
00628         FILE* OUTPUT_FILE,
00629         void* USER_DATA
00630         );
00631 
00632 /******************************************************************************/
00633 /* Cursor specific functions of doubly-linked lists                           */
00634 /******************************************************************************/
00635 
00645 gdsl_list_cursor_t
00646 gdsl_list_cursor_alloc (const gdsl_list_t L
00647             );
00655 void
00656 gdsl_list_cursor_free (gdsl_list_cursor_t C
00657                );
00658 
00669 extern void
00670 gdsl_list_cursor_move_to_head (gdsl_list_cursor_t C
00671                    );
00672 
00683 extern void
00684 gdsl_list_cursor_move_to_tail (gdsl_list_cursor_t C
00685                    );
00686 
00702 extern gdsl_element_t
00703 gdsl_list_cursor_move_to_value (gdsl_list_cursor_t C,
00704                 gdsl_compare_func_t COMP_F,
00705                 void* VALUE
00706                 );
00707 
00722 extern gdsl_element_t
00723 gdsl_list_cursor_move_to_position (gdsl_list_cursor_t C,
00724                    ulong POS
00725                    );
00726 
00738 extern void
00739 gdsl_list_cursor_step_forward (gdsl_list_cursor_t C
00740                    );
00741 
00753 extern void
00754 gdsl_list_cursor_step_backward (gdsl_list_cursor_t C
00755                 );
00756 
00766 extern bool
00767 gdsl_list_cursor_is_on_head (const gdsl_list_cursor_t C
00768                  );
00769 
00779 extern bool
00780 gdsl_list_cursor_is_on_tail (const gdsl_list_cursor_t C
00781                  );
00782 
00792 extern bool 
00793 gdsl_list_cursor_has_succ (const gdsl_list_cursor_t C
00794                );
00795 
00805 extern bool 
00806 gdsl_list_cursor_has_pred (const gdsl_list_cursor_t C
00807                );
00808 
00822 extern void
00823  gdsl_list_cursor_set_content (gdsl_list_cursor_t C,
00824                    gdsl_element_t E
00825                    );
00834 extern gdsl_element_t
00835 gdsl_list_cursor_get_content (const gdsl_list_cursor_t C
00836                   );
00837 
00856 extern gdsl_element_t
00857 gdsl_list_cursor_insert_after (gdsl_list_cursor_t C,
00858                    void* VALUE
00859                    );
00878 extern gdsl_element_t
00879 gdsl_list_cursor_insert_before (gdsl_list_cursor_t C,
00880                 void* VALUE
00881                 );
00882 
00896 extern gdsl_element_t
00897 gdsl_list_cursor_remove (gdsl_list_cursor_t C
00898              );
00899 
00912 extern gdsl_element_t
00913 gdsl_list_cursor_remove_after (gdsl_list_cursor_t C
00914                    );
00915 
00928 extern gdsl_element_t
00929 gdsl_list_cursor_remove_before (gdsl_list_cursor_t C
00930                 );
00931 
00947 extern gdsl_list_cursor_t
00948 gdsl_list_cursor_delete (gdsl_list_cursor_t C
00949              );
00950 
00966 extern gdsl_list_cursor_t
00967 gdsl_list_cursor_delete_after (gdsl_list_cursor_t C
00968                    );
00969 
00984 extern gdsl_list_cursor_t
00985 gdsl_list_cursor_delete_before (gdsl_list_cursor_t C
00986                 );
00987 
00988 
00994 #ifdef __cplusplus
00995 }
00996 #endif /* __cplusplus */
00997 
00998 
00999 #endif /* GDSL_LIST_H_ */
01000 
01001