gdsl
1.8
|
00001 /* 00002 * This file is part of the Generic Data Structures Library (GDSL). 00003 * Copyright (C) 1998-2018 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 00019 /* 00020 * GDSL - Generic Data Structures Library 00021 * $RCSfile: gdsl_list.h,v $ 00022 * $Revision: 1.26 $ 00023 * $Date: 2015/02/17 12:22:57 $ 00024 */ 00025 00026 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 00052 typedef struct _gdsl_list* gdsl_list_t; 00053 00060 typedef struct _gdsl_list_cursor* gdsl_list_cursor_t; 00061 00062 /******************************************************************************/ 00063 /* Management functions of doubly-linked lists */ 00064 /******************************************************************************/ 00065 00086 extern gdsl_list_t 00087 gdsl_list_alloc (const char* NAME, 00088 gdsl_alloc_func_t ALLOC_F, 00089 gdsl_free_func_t FREE_F 00090 ); 00091 00104 extern void 00105 gdsl_list_free (gdsl_list_t L 00106 ); 00107 00121 extern void 00122 gdsl_list_flush (gdsl_list_t L 00123 ); 00124 00125 /******************************************************************************/ 00126 /* Consultation functions of doubly-linked lists */ 00127 /******************************************************************************/ 00128 00138 extern const char* 00139 gdsl_list_get_name (const gdsl_list_t L 00140 ); 00141 00149 extern ulong 00150 gdsl_list_get_size (const gdsl_list_t L 00151 ); 00152 00161 extern bool 00162 gdsl_list_is_empty (const gdsl_list_t L 00163 ); 00164 00175 extern gdsl_element_t 00176 gdsl_list_get_head (const gdsl_list_t L 00177 ); 00178 00189 extern gdsl_element_t 00190 gdsl_list_get_tail (const gdsl_list_t L 00191 ); 00192 00193 /******************************************************************************/ 00194 /* Modification functions of doubly-linked lists */ 00195 /******************************************************************************/ 00196 00210 extern gdsl_list_t 00211 gdsl_list_set_name (gdsl_list_t L, 00212 const char* NEW_NAME 00213 ); 00214 00233 extern gdsl_element_t 00234 gdsl_list_insert_head (gdsl_list_t L, 00235 void* VALUE 00236 ); 00237 00256 extern gdsl_element_t 00257 gdsl_list_insert_tail (gdsl_list_t L, 00258 void* VALUE 00259 ); 00260 00276 extern gdsl_element_t 00277 gdsl_list_remove_head (gdsl_list_t L 00278 ); 00279 00295 extern gdsl_element_t 00296 gdsl_list_remove_tail (gdsl_list_t L 00297 ); 00298 00317 extern gdsl_element_t 00318 gdsl_list_remove (gdsl_list_t L, 00319 gdsl_compare_func_t COMP_F, 00320 const void* VALUE 00321 ); 00322 00338 extern gdsl_list_t 00339 gdsl_list_delete_head (gdsl_list_t L 00340 ); 00341 00357 extern gdsl_list_t 00358 gdsl_list_delete_tail (gdsl_list_t L 00359 ); 00360 00379 extern gdsl_list_t 00380 gdsl_list_delete (gdsl_list_t L, 00381 gdsl_compare_func_t COMP_F, 00382 const void* VALUE 00383 ); 00384 00385 /******************************************************************************/ 00386 /* Search functions of doubly-linked lists */ 00387 /******************************************************************************/ 00388 00406 extern gdsl_element_t 00407 gdsl_list_search (const gdsl_list_t L, 00408 gdsl_compare_func_t COMP_F, 00409 const void* VALUE 00410 ); 00411 00424 extern gdsl_element_t 00425 gdsl_list_search_by_position (const gdsl_list_t L, 00426 ulong POS 00427 ); 00428 00445 extern gdsl_element_t 00446 gdsl_list_search_max (const gdsl_list_t L, 00447 gdsl_compare_func_t COMP_F 00448 ); 00449 00466 extern gdsl_element_t 00467 gdsl_list_search_min (const gdsl_list_t L, 00468 gdsl_compare_func_t COMP_F 00469 ); 00470 00471 /******************************************************************************/ 00472 /* Sort functions of doubly-linked lists */ 00473 /******************************************************************************/ 00474 00487 extern gdsl_list_t 00488 gdsl_list_sort (gdsl_list_t L, 00489 gdsl_compare_func_t COMP_F 00490 ); 00491 00492 /******************************************************************************/ 00493 /* Parse functions of doubly-linked lists */ 00494 /******************************************************************************/ 00495 00513 extern gdsl_element_t 00514 gdsl_list_map_forward (const gdsl_list_t L, 00515 gdsl_map_func_t MAP_F, 00516 void* USER_DATA 00517 ); 00518 00536 extern gdsl_element_t 00537 gdsl_list_map_backward (const gdsl_list_t L, 00538 gdsl_map_func_t MAP_F, 00539 void* USER_DATA 00540 ); 00541 00542 /******************************************************************************/ 00543 /* Input/output functions of doubly-linked lists */ 00544 /******************************************************************************/ 00545 00561 extern void 00562 gdsl_list_write (const gdsl_list_t L, 00563 gdsl_write_func_t WRITE_F, 00564 FILE* OUTPUT_FILE, 00565 void* USER_DATA 00566 ); 00567 00584 extern void 00585 gdsl_list_write_xml (const gdsl_list_t L, 00586 gdsl_write_func_t WRITE_F, 00587 FILE* OUTPUT_FILE, 00588 void* USER_DATA 00589 ); 00590 00607 extern void 00608 gdsl_list_dump (const gdsl_list_t L, 00609 gdsl_write_func_t WRITE_F, 00610 FILE* OUTPUT_FILE, 00611 void* USER_DATA 00612 ); 00613 00614 /******************************************************************************/ 00615 /* Cursor specific functions of doubly-linked lists */ 00616 /******************************************************************************/ 00617 00627 gdsl_list_cursor_t 00628 gdsl_list_cursor_alloc (const gdsl_list_t L 00629 ); 00637 void 00638 gdsl_list_cursor_free (gdsl_list_cursor_t C 00639 ); 00640 00651 extern void 00652 gdsl_list_cursor_move_to_head (gdsl_list_cursor_t C 00653 ); 00654 00665 extern void 00666 gdsl_list_cursor_move_to_tail (gdsl_list_cursor_t C 00667 ); 00668 00684 extern gdsl_element_t 00685 gdsl_list_cursor_move_to_value (gdsl_list_cursor_t C, 00686 gdsl_compare_func_t COMP_F, 00687 void* VALUE 00688 ); 00689 00704 extern gdsl_element_t 00705 gdsl_list_cursor_move_to_position (gdsl_list_cursor_t C, 00706 ulong POS 00707 ); 00708 00720 extern void 00721 gdsl_list_cursor_step_forward (gdsl_list_cursor_t C 00722 ); 00723 00735 extern void 00736 gdsl_list_cursor_step_backward (gdsl_list_cursor_t C 00737 ); 00738 00748 extern bool 00749 gdsl_list_cursor_is_on_head (const gdsl_list_cursor_t C 00750 ); 00751 00761 extern bool 00762 gdsl_list_cursor_is_on_tail (const gdsl_list_cursor_t C 00763 ); 00764 00774 extern bool 00775 gdsl_list_cursor_has_succ (const gdsl_list_cursor_t C 00776 ); 00777 00787 extern bool 00788 gdsl_list_cursor_has_pred (const gdsl_list_cursor_t C 00789 ); 00790 00804 extern void 00805 gdsl_list_cursor_set_content (gdsl_list_cursor_t C, 00806 gdsl_element_t E 00807 ); 00816 extern gdsl_element_t 00817 gdsl_list_cursor_get_content (const gdsl_list_cursor_t C 00818 ); 00819 00838 extern gdsl_element_t 00839 gdsl_list_cursor_insert_after (gdsl_list_cursor_t C, 00840 void* VALUE 00841 ); 00860 extern gdsl_element_t 00861 gdsl_list_cursor_insert_before (gdsl_list_cursor_t C, 00862 void* VALUE 00863 ); 00864 00878 extern gdsl_element_t 00879 gdsl_list_cursor_remove (gdsl_list_cursor_t C 00880 ); 00881 00894 extern gdsl_element_t 00895 gdsl_list_cursor_remove_after (gdsl_list_cursor_t C 00896 ); 00897 00910 extern gdsl_element_t 00911 gdsl_list_cursor_remove_before (gdsl_list_cursor_t C 00912 ); 00913 00929 extern gdsl_list_cursor_t 00930 gdsl_list_cursor_delete (gdsl_list_cursor_t C 00931 ); 00932 00948 extern gdsl_list_cursor_t 00949 gdsl_list_cursor_delete_after (gdsl_list_cursor_t C 00950 ); 00951 00966 extern gdsl_list_cursor_t 00967 gdsl_list_cursor_delete_before (gdsl_list_cursor_t C 00968 ); 00969 00970 00975 #ifdef __cplusplus 00976 } 00977 #endif /* __cplusplus */ 00978 00979 00980 #endif /* GDSL_LIST_H_ */ 00981 00982