gdsl  1.8
gdsl_queue.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-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_queue.h,v $
00022  * $Revision: 1.19 $
00023  * $Date: 2015/02/17 12:22:57 $
00024  */
00025 
00026 
00027 #ifndef _GDSL_QUEUE_H_
00028 #define _GDSL_QUEUE_H_
00029 
00030 
00031 #include <stdio.h>
00032 
00033 
00034 #include "gdsl_types.h"
00035 
00036 
00037 #ifdef __cplusplus
00038 extern "C" 
00039 {
00040 #endif /* __cplusplus */
00041 
00055 typedef struct _gdsl_queue* gdsl_queue_t;
00056 
00057 /******************************************************************************/
00058 /* Management functions of queues                                             */
00059 /******************************************************************************/
00060 
00081 extern gdsl_queue_t
00082 gdsl_queue_alloc (const char* NAME,
00083           gdsl_alloc_func_t ALLOC_F,
00084           gdsl_free_func_t FREE_F
00085           );
00086 
00100 extern void 
00101 gdsl_queue_free (gdsl_queue_t Q
00102          );
00103 
00117 extern void
00118 gdsl_queue_flush (gdsl_queue_t Q
00119           );
00120 
00121 /******************************************************************************/
00122 /* Consultation functions of queues                                           */
00123 /******************************************************************************/
00124 
00134 extern const char*
00135 gdsl_queue_get_name (const gdsl_queue_t Q
00136              );
00137 
00145 extern ulong
00146 gdsl_queue_get_size (const gdsl_queue_t Q
00147              );
00148 
00157 extern bool 
00158 gdsl_queue_is_empty (const gdsl_queue_t Q
00159              );
00160 
00171 extern gdsl_element_t
00172 gdsl_queue_get_head (const gdsl_queue_t Q
00173              );
00174 
00185 extern gdsl_element_t
00186 gdsl_queue_get_tail (const gdsl_queue_t Q
00187              );
00188 
00189 /******************************************************************************/
00190 /* Modification functions of queues                                           */
00191 /******************************************************************************/
00192 
00206 extern gdsl_queue_t
00207 gdsl_queue_set_name (gdsl_queue_t Q,
00208              const char* NEW_NAME
00209              );
00210 
00226 extern gdsl_element_t
00227 gdsl_queue_insert (gdsl_queue_t Q,
00228            void* VALUE
00229            );
00230 
00243 extern gdsl_element_t
00244 gdsl_queue_remove (gdsl_queue_t Q
00245            );
00246 
00247 /******************************************************************************/
00248 /* Search functions of queues                                                 */
00249 /******************************************************************************/
00250 
00266 extern gdsl_element_t
00267 gdsl_queue_search (const gdsl_queue_t Q,
00268            gdsl_compare_func_t COMP_F,
00269            void* VALUE
00270            );
00271 
00282 extern gdsl_element_t
00283 gdsl_queue_search_by_position (const gdsl_queue_t Q,
00284                    ulong POS
00285                    );
00286 
00287 /******************************************************************************/
00288 /* Parse functions of queues                                                  */
00289 /******************************************************************************/
00290 
00308 extern gdsl_element_t
00309 gdsl_queue_map_forward (const gdsl_queue_t Q,
00310             gdsl_map_func_t MAP_F,
00311             void* USER_DATA
00312             );
00313 
00331 extern gdsl_element_t
00332 gdsl_queue_map_backward (const gdsl_queue_t Q,
00333              gdsl_map_func_t MAP_F,
00334              void* USER_DATA
00335              );
00336 
00337 /******************************************************************************/
00338 /* Input/output functions of queues                                           */
00339 /******************************************************************************/
00340 
00356 extern void
00357 gdsl_queue_write (const gdsl_queue_t Q,
00358           gdsl_write_func_t WRITE_F,
00359           FILE* OUTPUT_FILE,
00360           void* USER_DATA
00361           );
00362 
00379 extern void
00380 gdsl_queue_write_xml (const gdsl_queue_t Q,
00381               gdsl_write_func_t WRITE_F,
00382               FILE* OUTPUT_FILE,
00383               void* USER_DATA
00384               );
00385 
00402 extern void 
00403 gdsl_queue_dump (const gdsl_queue_t Q,
00404          gdsl_write_func_t WRITE_F,
00405          FILE* OUTPUT_FILE,
00406          void* USER_DATA
00407          );
00408 
00414 #ifdef __cplusplus
00415 }
00416 #endif /* __cplusplus */
00417 
00418 
00419 #endif /* _GDSL_QUEUE_H_ */
00420 
00421