list.h
00001
00002
00003
00004
00005
00006
00035 #ifndef LIST_H
00036 #define LIST_H
00037
00038 #include <limits.h>
00039 #include <stdbool.h>
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #define list_create cctools_list_create
00050 #define list_destroy cctools_list_destroy
00051 #define list_length cctools_list_length
00052 #define list_cursor_create cctools_list_cursor_create
00053 #define list_cursor_destroy cctools_list_cursor_destroy
00054 #define list_cursor_clone cctools_list_cursor_clone
00055 #define list_reset cctools_list_reset
00056 #define list_seek cctools_list_seek
00057 #define list_tell cctools_list_tell
00058 #define list_next cctools_list_next
00059 #define list_prev cctools_list_prev
00060 #define list_get cctools_list_get
00061 #define list_set cctools_list_set
00062 #define list_drop cctools_list_drop
00063 #define list_insert cctools_list_insert
00064
00065 #define list_size cctools_list_size
00066 #define list_delete cctools_list_delete
00067 #define list_free cctools_list_free
00068 #define list_pop_head cctools_list_pop_head
00069 #define list_peek_head cctools_list_peek_head
00070 #define list_pop_tail cctools_list_pop_tail
00071 #define list_peek_tail cctools_list_peek_tail
00072 #define list_peek_current cctools_list_peek_current
00073 #define list_remove cctools_list_remove
00074 #define list_find cctools_list_find
00075 #define list_splice cctools_list_splice
00076 #define list_split cctools_list_split
00077 #define list_push_head cctools_list_push_head
00078 #define list_push_tail cctools_list_push_tail
00079 #define list_push_priority cctools_list_push_priority
00080 #define list_iterate cctools_list_iterate
00081 #define list_iterate_reverse cctools_list_iterate_reverse
00082 #define list_first_item cctools_list_first_item
00083 #define list_next_item cctools_list_next_item
00084
00088 struct list *list_create(void);
00089
00099 bool list_destroy(struct list *list);
00100
00105 unsigned list_length(struct list *list);
00106
00113 struct list_cursor *list_cursor_create(struct list *list);
00114
00121 void list_cursor_destroy(struct list_cursor *cur);
00122
00129 struct list_cursor *list_cursor_clone(struct list_cursor *cur);
00130
00136 void list_reset(struct list_cursor *cur);
00137
00148 bool list_seek(struct list_cursor *cur, int index);
00149
00161 bool list_tell(struct list_cursor *cur, unsigned *index);
00162
00168 bool list_next(struct list_cursor *cur);
00169
00175 bool list_prev(struct list_cursor *cur);
00176
00186 bool list_get(struct list_cursor *cur, void **item);
00187
00196 bool list_set(struct list_cursor *cur, void *item);
00197
00206 bool list_drop(struct list_cursor *cur);
00207
00215 void list_insert(struct list_cursor *cur, void *item);
00216
00217
00218
00219
00220 typedef int (*list_op_t) (void *item, const void *arg);
00221 typedef double (*list_priority_t) (void *item);
00222
00228 int list_size(struct list *list);
00229
00237 struct list *list_duplicate(struct list *list);
00238
00245 void list_delete(struct list *list);
00246
00252 void list_free(struct list *list);
00253
00260 struct list *list_splice(struct list *top, struct list *bottom);
00261
00271 struct list *list_split(struct list *src, list_op_t cmp, const void *arg);
00272
00278 int list_push_head(struct list *list, void *item);
00279
00284 void *list_pop_head(struct list *list);
00285
00290 void *list_peek_head(struct list *list);
00291
00297 int list_push_tail(struct list *list, void *item);
00298
00303 void *list_pop_tail(struct list *list);
00304
00309 void *list_peek_tail(struct list *list);
00310
00315 void *list_peek_current(struct list *list);
00316
00329 void list_push_priority(struct list *list, list_priority_t p, void *item);
00330
00339 void *list_find(struct list *list, list_op_t cmp, const void *arg);
00340
00348 void *list_remove(struct list *list, const void *value);
00349
00356 void list_first_item(struct list *list);
00357
00365 void *list_next_item(struct list *list);
00366
00374 int list_iterate(struct list *list, list_op_t op, const void *arg);
00375
00382 int list_iterate_reverse(struct list *list, list_op_t op, const void *arg);
00383
00389 struct list *list_sort(struct list *list, int (*comparator) (const void *, const void *));
00390
00391 #endif