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_peek_current               cctools_list_peek_current
00028 #define list_remove                     cctools_list_remove
00029 #define list_find                       cctools_list_find
00030 #define list_create                     cctools_list_create
00031 #define list_splice                     cctools_list_splice
00032 #define list_split                      cctools_list_split
00033 #define list_size                       cctools_list_size
00034 #define list_push_priority              cctools_list_push_priority
00035 #define list_push_head                  cctools_list_push_head
00036 #define list_push_tail                  cctools_list_push_tail
00037 #define list_iterate                    cctools_list_iterate
00038 #define list_iterate_reverse            cctools_list_iterate_reverse
00039 #define list_first_item                 cctools_list_first_item
00040 #define list_next_item                  cctools_list_next_item
00041 
00042 struct list_node {
00043         void *data;
00044         struct list_node *next;
00045         struct list_node *prev;
00046         double priority;
00047 };
00048 
00049 struct list {
00050         struct list_node *head;
00051         struct list_node *tail;
00052         struct list_node *iter;
00053         int size;
00054 };
00055 
00056 typedef int (*list_op_t) (void *item, const void *arg);
00057 
00062 struct list *list_create();
00063 
00071 struct list *list_duplicate(struct list *list);
00072 
00079 void list_delete(struct list *list);
00080 
00086 void list_free(struct list *list);
00087 
00094 struct list *list_splice(struct list *top, struct list *bottom);
00095 
00105 struct list *list_split(struct list *src, list_op_t cmp, const void *arg);
00106 
00112 int list_size(struct list *list);
00113 
00120 int list_push_priority(struct list *list, void *item, double prio);
00121 
00127 int list_push_head(struct list *list, void *item);
00128 
00133 void *list_pop_head(struct list *list);
00134 
00139 void *list_peek_head(struct list *list);
00140 
00146 int list_push_tail(struct list *list, void *item);
00147 
00152 void *list_pop_tail(struct list *list);
00153 
00158 void *list_peek_tail(struct list *list);
00159 
00164 void *list_peek_current(struct list *list);
00165 
00174 void *list_find(struct list *list, list_op_t cmp, const void *arg);
00175 
00183 void *list_remove(struct list *list, const void *value);
00184 
00191 void list_first_item(struct list *list);
00192 
00200 void *list_next_item(struct list *list);
00201 
00209 int list_iterate(struct list *list, list_op_t op, const void *arg);
00210 
00217 int list_iterate_reverse(struct list *list, list_op_t op, const void *arg);
00218 
00224 struct list *list_sort(struct list *list, int (*comparator) (const void *, const void *));
00225 
00226 #endif

Generated on 25 Mar 2015 for cctools by  doxygen 1.6.1