list.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2003-2004 Douglas Thain and the University of Wisconsin
00003 Copyright (C) 2005- The University of Notre Dame
00004 This software is distributed under the GNU General Public License.
00005 See the file COPYING for details.
00006 */
00007 
00008 #ifndef LIST_H
00009 #define LIST_H
00010 
00013 /*
00014 It turns out that many libraries and tools make use of
00015 symbols like "debug" and "fatal".  This causes strange
00016 failures when we link against such codes.  Rather than change
00017 all of our code, we simply insert these defines to
00018 transparently modify the linker namespace we are using.
00019 */
00020 
00021 #define list_delete                     cctools_list_delete
00022 #define list_free                       cctools_list_free
00023 #define list_pop_head                   cctools_list_pop_head
00024 #define list_peek_head                  cctools_list_peek_head
00025 #define list_pop_tail                   cctools_list_pop_tail
00026 #define list_peek_tail                  cctools_list_peek_tail
00027 #define list_remove                     cctools_list_remove
00028 #define list_find                       cctools_list_find
00029 #define list_create                     cctools_list_create
00030 #define list_splice                     cctools_list_splice
00031 #define list_split                      cctools_list_split
00032 #define list_size                       cctools_list_size
00033 #define list_push_priority              cctools_list_push_priority
00034 #define list_push_head                  cctools_list_push_head
00035 #define list_push_tail                  cctools_list_push_tail
00036 #define list_iterate                    cctools_list_iterate
00037 #define list_iterate_reverse            cctools_list_iterate_reverse
00038 #define list_first_item                 cctools_list_first_item
00039 #define list_next_item                  cctools_list_next_item
00040 
00041 struct list_node {
00042         void *data;
00043         struct list_node *next;
00044         struct list_node *prev;
00045         int priority;
00046 };
00047 
00048 struct list {
00049         struct list_node *head;
00050         struct list_node *tail;
00051         struct list_node *iter;
00052         int size;
00053 };
00054 
00055 typedef int (*list_op_t) (void *item, const void *arg);
00056 
00061 struct list *list_create();
00062 
00070 struct list *list_duplicate(struct list *list);
00071 
00078 void list_delete(struct list *list);
00079 
00085 void list_free(struct list *list);
00086 
00093 struct list *list_splice(struct list *top, struct list *bottom);
00094 
00104 struct list *list_split(struct list *src, list_op_t cmp, const void *arg);
00105 
00111 int list_size(struct list *list);
00112 
00119 int list_push_priority(struct list *list, void *item, int prio);
00120 
00126 int list_push_head(struct list *list, void *item);
00127 
00132 void *list_pop_head(struct list *list);
00133 
00138 void *list_peek_head(struct list *list);
00139 
00145 int list_push_tail(struct list *list, void *item);
00146 
00151 void *list_pop_tail(struct list *list);
00152 
00157 void *list_peek_tail(struct list *list);
00158 
00167 void *list_find(struct list *list, list_op_t cmp, const void *arg);
00168 
00176 void *list_remove(struct list *list, const void *value);
00177 
00184 void list_first_item(struct list *list);
00185 
00193 void *list_next_item(struct list *list);
00194 
00202 int list_iterate(struct list *list, list_op_t op, const void *arg);
00203 
00210 int list_iterate_reverse(struct list *list, list_op_t op, const void *arg);
00211 
00217 struct list *list_sort(struct list *list, int (*comparator) (const void *, const void *));
00218 
00219 #endif

Generated on Sun Aug 14 23:01:35 2011 for cctools by  doxygen 1.6.1