00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00053 #ifndef ALGORITHM_LIST_H
00054 #define ALGORITHM_LIST_H
00055
00056 #ifdef __cplusplus
00057 extern "C" {
00058 #endif
00059
00067 typedef struct _ListEntry ListEntry;
00068
00073 typedef struct _ListIterator ListIterator;
00074
00079 typedef void *ListValue;
00080
00085 struct _ListIterator {
00086 ListEntry **prev_next;
00087 ListEntry *current;
00088 };
00089
00094 #define LIST_NULL ((void *) 0)
00095
00106 typedef int (*ListCompareFunc)(ListValue value1, ListValue value2);
00107
00118 typedef int (*ListEqualFunc)(ListValue value1, ListValue value2);
00119
00126 void list_free(ListEntry *list);
00127
00137 ListEntry *list_prepend(ListEntry **list, ListValue data);
00138
00148 ListEntry *list_append(ListEntry **list, ListValue data);
00149
00158 ListEntry *list_prev(ListEntry *listentry);
00159
00168 ListEntry *list_next(ListEntry *listentry);
00169
00177 ListValue list_data(ListEntry *listentry);
00178
00187 ListEntry *list_nth_entry(ListEntry *list, int n);
00188
00198 ListValue list_nth_data(ListEntry *list, int n);
00199
00207 int list_length(ListEntry *list);
00208
00219 ListValue *list_to_array(ListEntry *list);
00220
00230 int list_remove_entry(ListEntry **list, ListEntry *entry);
00231
00242 int list_remove_data(ListEntry **list, ListEqualFunc callback, ListValue data);
00243
00251 void list_sort(ListEntry **list, ListCompareFunc compare_func);
00252
00264 ListEntry *list_find_data(ListEntry *list,
00265 ListEqualFunc callback,
00266 ListValue data);
00267
00275 void list_iterate(ListEntry **list, ListIterator *iter);
00276
00286 int list_iter_has_more(ListIterator *iterator);
00287
00296 ListValue list_iter_next(ListIterator *iterator);
00297
00305 void list_iter_remove(ListIterator *iterator);
00306
00307 #ifdef __cplusplus
00308 }
00309 #endif
00310
00311 #endif
00312