libFirm 1.20
|
00001 /* 00002 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. 00003 * 00004 * This file is part of libFirm. 00005 * 00006 * This file may be distributed and/or modified under the terms of the 00007 * GNU General Public License version 2 as published by the Free Software 00008 * Foundation and appearing in the file LICENSE.GPL included in the 00009 * packaging of this file. 00010 * 00011 * Licensees holding valid libFirm Professional Edition licenses may use 00012 * this file in accordance with the libFirm Commercial License. 00013 * Agreement provided with the Software. 00014 * 00015 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00016 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00017 * PURPOSE. 00018 */ 00019 00031 #ifndef FIRM_ADT_PLIST_H 00032 #define FIRM_ADT_PLIST_H 00033 00034 #include <stddef.h> 00035 #include "obst.h" 00036 00037 #include "../begin.h" 00038 00039 typedef struct plist_element plist_element_t; 00040 typedef struct plist plist_t; 00041 00045 struct plist { 00047 struct obstack *obst; 00048 00050 unsigned foreign_obstack : 1; 00051 00053 plist_element_t *first_element; 00054 00056 plist_element_t *last_element; 00057 00059 int element_count; 00060 00066 plist_element_t* first_free_element; 00067 }; 00068 00072 struct plist_element { 00073 plist_element_t *next; 00074 plist_element_t *prev; 00075 void *data; 00076 }; 00077 00082 FIRM_API plist_t *plist_new(void); 00083 00090 FIRM_API plist_t *plist_obstack_new(struct obstack *obst); 00091 00097 FIRM_API void plist_free(plist_t *list); 00098 00104 #define plist_count(list) \ 00105 ((list)->element_count) 00106 00112 FIRM_API void plist_insert_back(plist_t *list, void *value); 00113 00119 FIRM_API void plist_insert_front(plist_t *list, void *value); 00120 00129 FIRM_API void plist_insert_before(plist_t *list, plist_element_t *element, void *value); 00130 00139 FIRM_API void plist_insert_after(plist_t *list, plist_element_t *element, void *value); 00140 00147 FIRM_API int plist_has_value(plist_t *list, void *value); 00148 00155 FIRM_API plist_element_t *plist_find_value(plist_t *list, void *value); 00156 00163 FIRM_API void plist_erase(plist_t *list, plist_element_t *element); 00164 00169 FIRM_API void plist_clear(plist_t *list); 00170 00176 #define plist_first(list) \ 00177 ((list)->first_element) 00178 00184 #define plist_last(list) \ 00185 ((list)->last_element) 00186 00193 #define plist_element_has_next(element) \ 00194 ((element)->next != NULL) 00195 00202 #define plist_element_has_prev(element) \ 00203 ((element)->prev != NULL) 00204 00211 #define plist_element_get_next(element) \ 00212 ((element)->next) 00213 00220 #define plist_element_get_prev(element) \ 00221 ((element)->prev) 00222 00228 #define plist_element_get_value(element) \ 00229 ((element)->data) 00230 00234 #define foreach_plist(list, el) \ 00235 for (el = plist_first(list); el; el = plist_element_get_next(el)) 00236 00237 #include "../end.h" 00238 00239 #endif