gdsl
1.8
|
00001 /* 00002 * This file is part of the Generic Data Structures Library (GDSL). 00003 * Copyright (C) 1998-2015 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.h,v $ 00021 * $Revision: 1.26 $ 00022 * $Date: 2015/02/17 12:22:57 $ 00023 */ 00024 00029 #ifndef _GDSL_LIST_H_ 00030 #define _GDSL_LIST_H_ 00031 00032 #include <stdio.h> 00033 00034 #include "gdsl_types.h" 00035 00036 #ifdef __cplusplus 00037 extern "C" 00038 { 00039 #endif 00040 00041 00054 typedef struct _gdsl_list* gdsl_list_t; 00055 00062 typedef struct _gdsl_list_cursor* gdsl_list_cursor_t; 00063 00064 /******************************************************************************/ 00065 /* Management functions of doubly-linked lists */ 00066 /******************************************************************************/ 00067 00088 extern gdsl_list_t 00089 gdsl_list_alloc (const char* NAME, 00090 gdsl_alloc_func_t ALLOC_F, 00091 gdsl_free_func_t FREE_F 00092 ); 00093 00106 extern void 00107 gdsl_list_free (gdsl_list_t L 00108 ); 00109 00123 extern void 00124 gdsl_list_flush (gdsl_list_t L 00125 ); 00126 00127 /******************************************************************************/ 00128 /* Consultation functions of doubly-linked lists */ 00129 /******************************************************************************/ 00130 00140 extern const char* 00141 gdsl_list_get_name (const gdsl_list_t L 00142 ); 00143 00151 extern ulong 00152 gdsl_list_get_size (const gdsl_list_t L 00153 ); 00154 00163 extern bool 00164 gdsl_list_is_empty (const gdsl_list_t L 00165 ); 00166 00177 extern gdsl_element_t 00178 gdsl_list_get_head (const gdsl_list_t L 00179 ); 00180 00191 extern gdsl_element_t 00192 gdsl_list_get_tail (const gdsl_list_t L 00193 ); 00194 00195 /******************************************************************************/ 00196 /* Modification functions of doubly-linked lists */ 00197 /******************************************************************************/ 00198 00212 extern gdsl_list_t 00213 gdsl_list_set_name (gdsl_list_t L, 00214 const char* NEW_NAME 00215 ); 00216 00235 extern gdsl_element_t 00236 gdsl_list_insert_head (gdsl_list_t L, 00237 void* VALUE 00238 ); 00239 00258 extern gdsl_element_t 00259 gdsl_list_insert_tail (gdsl_list_t L, 00260 void* VALUE 00261 ); 00262 00278 extern gdsl_element_t 00279 gdsl_list_remove_head (gdsl_list_t L 00280 ); 00281 00297 extern gdsl_element_t 00298 gdsl_list_remove_tail (gdsl_list_t L 00299 ); 00300 00319 extern gdsl_element_t 00320 gdsl_list_remove (gdsl_list_t L, 00321 gdsl_compare_func_t COMP_F, 00322 const void* VALUE 00323 ); 00324 00340 extern gdsl_list_t 00341 gdsl_list_delete_head (gdsl_list_t L 00342 ); 00343 00359 extern gdsl_list_t 00360 gdsl_list_delete_tail (gdsl_list_t L 00361 ); 00362 00381 extern gdsl_list_t 00382 gdsl_list_delete (gdsl_list_t L, 00383 gdsl_compare_func_t COMP_F, 00384 const void* VALUE 00385 ); 00386 00387 /******************************************************************************/ 00388 /* Search functions of doubly-linked lists */ 00389 /******************************************************************************/ 00390 00408 extern gdsl_element_t 00409 gdsl_list_search (const gdsl_list_t L, 00410 gdsl_compare_func_t COMP_F, 00411 const void* VALUE 00412 ); 00413 00426 extern gdsl_element_t 00427 gdsl_list_search_by_position (const gdsl_list_t L, 00428 ulong POS 00429 ); 00430 00447 extern gdsl_element_t 00448 gdsl_list_search_max (const gdsl_list_t L, 00449 gdsl_compare_func_t COMP_F 00450 ); 00451 00468 extern gdsl_element_t 00469 gdsl_list_search_min (const gdsl_list_t L, 00470 gdsl_compare_func_t COMP_F 00471 ); 00472 00473 /******************************************************************************/ 00474 /* Sort functions of doubly-linked lists */ 00475 /******************************************************************************/ 00476 00489 extern gdsl_list_t 00490 gdsl_list_sort (gdsl_list_t L, 00491 gdsl_compare_func_t COMP_F 00492 ); 00493 00494 /******************************************************************************/ 00495 /* Parse functions of doubly-linked lists */ 00496 /******************************************************************************/ 00497 00515 extern gdsl_element_t 00516 gdsl_list_map_forward (const gdsl_list_t L, 00517 gdsl_map_func_t MAP_F, 00518 void* USER_DATA 00519 ); 00520 00538 extern gdsl_element_t 00539 gdsl_list_map_backward (const gdsl_list_t L, 00540 gdsl_map_func_t MAP_F, 00541 void* USER_DATA 00542 ); 00543 00544 /******************************************************************************/ 00545 /* Input/output functions of doubly-linked lists */ 00546 /******************************************************************************/ 00547 00563 extern void 00564 gdsl_list_write (const gdsl_list_t L, 00565 gdsl_write_func_t WRITE_F, 00566 FILE* OUTPUT_FILE, 00567 void* USER_DATA 00568 ); 00569 00586 extern void 00587 gdsl_list_write_xml (const gdsl_list_t L, 00588 gdsl_write_func_t WRITE_F, 00589 FILE* OUTPUT_FILE, 00590 void* USER_DATA 00591 ); 00592 00609 extern void 00610 gdsl_list_dump (const gdsl_list_t L, 00611 gdsl_write_func_t WRITE_F, 00612 FILE* OUTPUT_FILE, 00613 void* USER_DATA 00614 ); 00615 00616 /******************************************************************************/ 00617 /* Cursor specific functions of doubly-linked lists */ 00618 /******************************************************************************/ 00619 00629 gdsl_list_cursor_t 00630 gdsl_list_cursor_alloc (const gdsl_list_t L 00631 ); 00639 void 00640 gdsl_list_cursor_free (gdsl_list_cursor_t C 00641 ); 00642 00653 extern void 00654 gdsl_list_cursor_move_to_head (gdsl_list_cursor_t C 00655 ); 00656 00667 extern void 00668 gdsl_list_cursor_move_to_tail (gdsl_list_cursor_t C 00669 ); 00670 00686 extern gdsl_element_t 00687 gdsl_list_cursor_move_to_value (gdsl_list_cursor_t C, 00688 gdsl_compare_func_t COMP_F, 00689 void* VALUE 00690 ); 00691 00706 extern gdsl_element_t 00707 gdsl_list_cursor_move_to_position (gdsl_list_cursor_t C, 00708 ulong POS 00709 ); 00710 00722 extern void 00723 gdsl_list_cursor_step_forward (gdsl_list_cursor_t C 00724 ); 00725 00737 extern void 00738 gdsl_list_cursor_step_backward (gdsl_list_cursor_t C 00739 ); 00740 00750 extern bool 00751 gdsl_list_cursor_is_on_head (const gdsl_list_cursor_t C 00752 ); 00753 00763 extern bool 00764 gdsl_list_cursor_is_on_tail (const gdsl_list_cursor_t C 00765 ); 00766 00776 extern bool 00777 gdsl_list_cursor_has_succ (const gdsl_list_cursor_t C 00778 ); 00779 00789 extern bool 00790 gdsl_list_cursor_has_pred (const gdsl_list_cursor_t C 00791 ); 00792 00806 extern void 00807 gdsl_list_cursor_set_content (gdsl_list_cursor_t C, 00808 gdsl_element_t E 00809 ); 00818 extern gdsl_element_t 00819 gdsl_list_cursor_get_content (const gdsl_list_cursor_t C 00820 ); 00821 00840 extern gdsl_element_t 00841 gdsl_list_cursor_insert_after (gdsl_list_cursor_t C, 00842 void* VALUE 00843 ); 00862 extern gdsl_element_t 00863 gdsl_list_cursor_insert_before (gdsl_list_cursor_t C, 00864 void* VALUE 00865 ); 00866 00880 extern gdsl_element_t 00881 gdsl_list_cursor_remove (gdsl_list_cursor_t C 00882 ); 00883 00896 extern gdsl_element_t 00897 gdsl_list_cursor_remove_after (gdsl_list_cursor_t C 00898 ); 00899 00912 extern gdsl_element_t 00913 gdsl_list_cursor_remove_before (gdsl_list_cursor_t C 00914 ); 00915 00931 extern gdsl_list_cursor_t 00932 gdsl_list_cursor_delete (gdsl_list_cursor_t C 00933 ); 00934 00950 extern gdsl_list_cursor_t 00951 gdsl_list_cursor_delete_after (gdsl_list_cursor_t C 00952 ); 00953 00968 extern gdsl_list_cursor_t 00969 gdsl_list_cursor_delete_before (gdsl_list_cursor_t C 00970 ); 00971 00972 00973 /* 00974 * @} 00975 */ 00976 00977 00978 #ifdef __cplusplus 00979 } 00980 #endif /* __cplusplus */ 00981 00982 00983 #endif /* GDSL_LIST_H_ */ 00984 00985