gdsl  1.6
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-2006 Nicolas Darnis <ndarnis@free.fr>.
00004  *
00005  * The GDSL library is free software; you can redistribute it and/or 
00006  * modify it under the terms of the GNU General Public License as 
00007  * published by the Free Software Foundation; either version 2 of
00008  * the License, or (at your option) any later version.
00009  *
00010  * The GDSL library 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 the GDSL library; see the file COPYING.
00017  * If not, write to the Free Software Foundation, Inc., 
00018  * 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
00019  *
00020  * $RCSfile: gdsl__list_8h_source.html,v $
00021  * $Revision: 1.2 $
00022  * $Date: 2012/08/21 14:01:03 $
00023  */
00024 
00025 
00026 #ifndef _GDSL_LIST_H_
00027 #define _GDSL_LIST_H_
00028 
00029 #include <stdio.h>
00030 
00031 #include "gdsl_types.h"
00032 
00033 #ifdef __cplusplus
00034 extern "C" 
00035 {
00036 #endif
00037 
00038 
00051 typedef struct _gdsl_list* gdsl_list_t;
00052 
00059 typedef struct _gdsl_list_cursor* gdsl_list_cursor_t;
00060 
00061 /******************************************************************************/
00062 /* Management functions of doubly-linked lists                                */
00063 /******************************************************************************/
00064 
00085 extern gdsl_list_t
00086 gdsl_list_alloc (const char* NAME,
00087          gdsl_alloc_func_t ALLOC_F,
00088          gdsl_free_func_t FREE_F
00089          );
00090 
00103 extern void 
00104 gdsl_list_free (gdsl_list_t L
00105         );
00106 
00120 extern void
00121 gdsl_list_flush (gdsl_list_t L
00122          );
00123 
00124 /******************************************************************************/
00125 /* Consultation functions of doubly-linked lists                              */
00126 /******************************************************************************/
00127 
00137 extern const char*
00138 gdsl_list_get_name (const gdsl_list_t L
00139             );
00140 
00148 extern ulong
00149 gdsl_list_get_size (const gdsl_list_t L
00150             );
00151 
00160 extern bool
00161 gdsl_list_is_empty (const gdsl_list_t L
00162             );
00163 
00174 extern gdsl_element_t
00175 gdsl_list_get_head (const gdsl_list_t L
00176             );
00177 
00188 extern gdsl_element_t
00189 gdsl_list_get_tail (const gdsl_list_t L
00190             );
00191 
00192 /******************************************************************************/
00193 /* Modification functions of doubly-linked lists                              */
00194 /******************************************************************************/
00195 
00209 extern gdsl_list_t
00210 gdsl_list_set_name (gdsl_list_t L,
00211             const char* NEW_NAME
00212             );
00213 
00232 extern gdsl_element_t
00233 gdsl_list_insert_head (gdsl_list_t L,
00234                void* VALUE
00235                );
00236 
00255 extern gdsl_element_t
00256 gdsl_list_insert_tail (gdsl_list_t L,
00257                void* VALUE
00258                );
00259 
00275 extern gdsl_element_t
00276 gdsl_list_remove_head (gdsl_list_t L
00277                );
00278 
00294 extern gdsl_element_t
00295 gdsl_list_remove_tail (gdsl_list_t L
00296                );
00297 
00316 extern gdsl_element_t
00317 gdsl_list_remove (gdsl_list_t L,
00318           gdsl_compare_func_t COMP_F,
00319           const void* VALUE
00320           );
00321 
00337 extern gdsl_list_t
00338 gdsl_list_delete_head (gdsl_list_t L
00339                );
00340 
00356 extern gdsl_list_t
00357 gdsl_list_delete_tail (gdsl_list_t L
00358                );
00359 
00378 extern gdsl_list_t
00379 gdsl_list_delete (gdsl_list_t L,
00380           gdsl_compare_func_t COMP_F,
00381           const void* VALUE
00382           );
00383 
00384 /******************************************************************************/
00385 /* Search functions of doubly-linked lists                                    */
00386 /******************************************************************************/
00387 
00405 extern gdsl_element_t
00406 gdsl_list_search (const gdsl_list_t L,
00407           gdsl_compare_func_t COMP_F,
00408           const void* VALUE
00409           );
00410 
00423 extern gdsl_element_t
00424 gdsl_list_search_by_position (const gdsl_list_t L,
00425                   ulong POS
00426                   );
00427 
00444 extern gdsl_element_t
00445 gdsl_list_search_max (const gdsl_list_t L,
00446               gdsl_compare_func_t COMP_F
00447               );
00448 
00465 extern gdsl_element_t
00466 gdsl_list_search_min (const gdsl_list_t L,
00467               gdsl_compare_func_t COMP_F
00468               );
00469 
00470 /******************************************************************************/
00471 /* Sort functions of doubly-linked lists                                      */
00472 /******************************************************************************/
00473 
00486 extern gdsl_list_t
00487 gdsl_list_sort (gdsl_list_t L,
00488         gdsl_compare_func_t COMP_F
00489         );
00490 
00491 /******************************************************************************/
00492 /* Parse functions of doubly-linked lists                                     */
00493 /******************************************************************************/
00494 
00512 extern gdsl_element_t
00513 gdsl_list_map_forward (const gdsl_list_t L,
00514                gdsl_map_func_t MAP_F,
00515                void* USER_DATA
00516                );
00517 
00535 extern gdsl_element_t
00536 gdsl_list_map_backward (const gdsl_list_t L,
00537             gdsl_map_func_t MAP_F,
00538             void* USER_DATA
00539             );
00540 
00541 /******************************************************************************/
00542 /* Input/output functions of doubly-linked lists                              */
00543 /******************************************************************************/
00544 
00560 extern void
00561 gdsl_list_write (const gdsl_list_t L,
00562          gdsl_write_func_t WRITE_F,
00563          FILE* OUTPUT_FILE,
00564          void* USER_DATA
00565          );
00566 
00583 extern void
00584 gdsl_list_write_xml (const gdsl_list_t L,
00585              gdsl_write_func_t WRITE_F,
00586              FILE* OUTPUT_FILE,
00587              void* USER_DATA
00588              );
00589 
00606 extern void
00607 gdsl_list_dump (const gdsl_list_t L,
00608         gdsl_write_func_t WRITE_F,
00609         FILE* OUTPUT_FILE,
00610         void* USER_DATA
00611         );
00612 
00613 /******************************************************************************/
00614 /* Cursor specific functions of doubly-linked lists                           */
00615 /******************************************************************************/
00616 
00626 gdsl_list_cursor_t
00627 gdsl_list_cursor_alloc (const gdsl_list_t L
00628             );
00636 void
00637 gdsl_list_cursor_free (gdsl_list_cursor_t C
00638                );
00639 
00650 extern void
00651 gdsl_list_cursor_move_to_head (gdsl_list_cursor_t C
00652                    );
00653 
00664 extern void
00665 gdsl_list_cursor_move_to_tail (gdsl_list_cursor_t C
00666                    );
00667 
00683 extern gdsl_element_t
00684 gdsl_list_cursor_move_to_value (gdsl_list_cursor_t C,
00685                 gdsl_compare_func_t COMP_F,
00686                 void* VALUE
00687                 );
00688 
00703 extern gdsl_element_t
00704 gdsl_list_cursor_move_to_position (gdsl_list_cursor_t C,
00705                    ulong POS
00706                    );
00707 
00719 extern void
00720 gdsl_list_cursor_step_forward (gdsl_list_cursor_t C
00721                    );
00722 
00734 extern void
00735 gdsl_list_cursor_step_backward (gdsl_list_cursor_t C
00736                 );
00737 
00747 extern bool
00748 gdsl_list_cursor_is_on_head (const gdsl_list_cursor_t C
00749                  );
00750 
00760 extern bool
00761 gdsl_list_cursor_is_on_tail (const gdsl_list_cursor_t C
00762                  );
00763 
00773 extern bool 
00774 gdsl_list_cursor_has_succ (const gdsl_list_cursor_t C
00775                );
00776 
00786 extern bool 
00787 gdsl_list_cursor_has_pred (const gdsl_list_cursor_t C
00788                );
00789 
00803 extern void
00804  gdsl_list_cursor_set_content (gdsl_list_cursor_t C,
00805                    gdsl_element_t E
00806                    );
00815 extern gdsl_element_t
00816 gdsl_list_cursor_get_content (const gdsl_list_cursor_t C
00817                   );
00818 
00837 extern gdsl_element_t
00838 gdsl_list_cursor_insert_after (gdsl_list_cursor_t C,
00839                    void* VALUE
00840                    );
00859 extern gdsl_element_t
00860 gdsl_list_cursor_insert_before (gdsl_list_cursor_t C,
00861                 void* VALUE
00862                 );
00863 
00877 extern gdsl_element_t
00878 gdsl_list_cursor_remove (gdsl_list_cursor_t C
00879              );
00880 
00893 extern gdsl_element_t
00894 gdsl_list_cursor_remove_after (gdsl_list_cursor_t C
00895                    );
00896 
00909 extern gdsl_element_t
00910 gdsl_list_cursor_remove_before (gdsl_list_cursor_t C
00911                 );
00912 
00928 extern gdsl_list_cursor_t
00929 gdsl_list_cursor_delete (gdsl_list_cursor_t C
00930              );
00931 
00947 extern gdsl_list_cursor_t
00948 gdsl_list_cursor_delete_after (gdsl_list_cursor_t C
00949                    );
00950 
00965 extern gdsl_list_cursor_t
00966 gdsl_list_cursor_delete_before (gdsl_list_cursor_t C
00967                 );
00968 
00969 
00970 /*
00971  * @}
00972  */
00973 
00974 
00975 #ifdef __cplusplus
00976 }
00977 #endif /* __cplusplus */
00978 
00979 
00980 #endif /* GDSL_LIST_H_ */
00981 
00982