Main Page | Class List | File List | Class Members | File Members | Related Pages

list.h

Go to the documentation of this file.
00001 /* 00002 * $Id: list.h,v 1.15 2003/12/23 03:51:31 jasta Exp $ 00003 * 00004 * Copyright (C) 2001-2003 giFT project (gift.sourceforge.net) 00005 * 00006 * This program is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU General Public License as published by the 00008 * Free Software Foundation; either version 2, or (at your option) any 00009 * later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, but 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * General Public License for more details. 00015 */ 00016 00017 #ifndef __LIST_H 00018 #define __LIST_H 00019 00020 /*****************************************************************************/ 00021 00030 /*****************************************************************************/ 00031 00032 #define list_next(n) ((n) ? (n)->next : NULL) 00033 #define list_prev(n) ((n) ? (n)->prev : NULL) 00034 00035 /*****************************************************************************/ 00036 00044 typedef int (*CompareFunc) (void *a, void *b); 00045 00049 typedef struct listlink 00050 { 00051 void *data; 00053 struct listlink *prev; 00054 struct listlink *next; 00055 } List; 00056 00057 /**************************************************************************/ 00058 00059 EXTERN_C_BEGIN 00060 00061 /*****************************************************************************/ 00062 00069 typedef int (*ListForeachFunc) (void *data, void *udata); 00070 #define LIST_FOREACH(func) ((ListForeachFunc)func) 00071 00072 /*****************************************************************************/ 00073 00077 LIBGIFT_EXPORT 00078 List *list_append (List *head, void *udata); 00079 00080 #if 0 00081 00086 LIBGIFT_EXPORT 00087 List *list_append_link (List *head, List *link); 00088 #endif 00089 00093 LIBGIFT_EXPORT 00094 List *list_prepend (List *head, void *udata); 00095 00096 #if 0 00097 00100 LIBGIFT_EXPORT 00101 List *list_prepend_link (List *head, List *link); 00102 #endif 00103 00104 /*****************************************************************************/ 00105 00110 LIBGIFT_EXPORT 00111 List *list_insert (List *head, int nth, void *udata); 00112 00117 LIBGIFT_EXPORT 00118 List *list_insert_sorted (List *head, CompareFunc func, void *udata); 00119 00120 /*****************************************************************************/ 00121 00126 LIBGIFT_EXPORT 00127 List *list_remove (List *head, void *udata); 00128 00133 LIBGIFT_EXPORT 00134 List *list_remove_link (List *head, List *link); 00135 00136 #if 0 00137 00141 LIBGIFT_EXPORT 00142 List *list_unlink_link (List *head, List *link); 00143 #endif 00144 00145 /*****************************************************************************/ 00146 00153 LIBGIFT_EXPORT 00154 List *list_free (List *head); 00155 00156 /*****************************************************************************/ 00157 00162 LIBGIFT_EXPORT 00163 List *list_find (List *head, void *udata); 00164 00170 LIBGIFT_EXPORT 00171 List *list_find_custom (List *head, void *udata, CompareFunc func); 00172 00173 /*****************************************************************************/ 00174 00179 LIBGIFT_EXPORT 00180 void list_foreach (List *head, ListForeachFunc func, void *udata); 00181 00188 LIBGIFT_EXPORT 00189 List *list_foreach_remove (List *head, ListForeachFunc func, void *udata); 00190 00191 /*****************************************************************************/ 00192 00196 LIBGIFT_EXPORT 00197 List *list_nth (List *head, int nth); 00198 00203 LIBGIFT_EXPORT 00204 void *list_nth_data (List *head, int nth); 00205 00210 LIBGIFT_EXPORT 00211 List *list_last (List *head); 00212 00213 /*****************************************************************************/ 00214 00218 LIBGIFT_EXPORT 00219 int list_length (List *head); 00220 00226 LIBGIFT_EXPORT 00227 List *list_sort (List *head, CompareFunc func); 00228 00233 LIBGIFT_EXPORT 00234 List *list_copy (List *head); 00235 00236 /**************************************************************************/ 00237 00238 EXTERN_C_END 00239 00240 /*****************************************************************************/ 00241 00242 #endif /* __LIST_H */

Generated on Sun Aug 22 08:07:10 2004 by doxygen 1.3.7