00001 /* --------------------------------------------------------------------------- 00002 00003 00004 This file is part of the ``utils'' package. 00005 %COPYRIGHT% 00006 00007 -----------------------------------------------------------------------------*/ 00008 00019 #ifndef __NUSMV_CORE_UTILS_DLLIST_H__ 00020 #define __NUSMV_CORE_UTILS_DLLIST_H__ 00021 00022 #include "nusmv/core/utils/StreamMgr.h" 00023 #include "nusmv/core/utils/defs.h" 00024 00025 /*---------------------------------------------------------------------------*/ 00026 /* Type declarations */ 00027 /*---------------------------------------------------------------------------*/ 00028 00035 typedef struct DLlist_TAG* DLlist_ptr; 00036 00042 #define DL_LIST(x) \ 00043 ((DLlist_ptr) x) 00044 00050 #define DL_LIST_CHECK_INSTANCE(x) \ 00051 ( nusmv_assert(DL_LIST(x) != DL_LIST(NULL)) ) 00052 00058 #define DL_LIST_FOREACH(list, iter) \ 00059 for (iter = DLlist_first(list); !DLiter_is_end(iter); iter = DLiter_next(iter)) 00060 00061 /* internal type. it cannot be used outside. */ 00062 00069 typedef struct DLnode_TAG* DLnode_ptr; 00070 /* here a struct definition is used only to create a new type. Thus 00071 C type checker will be able to catch incorrect use of iterators */ 00072 typedef struct DLiter_TAG {DLnode_ptr node;} DLiter; 00073 00074 /* ---------------------------------------------------------------------- */ 00075 /* Public interface */ 00076 /* ---------------------------------------------------------------------- */ 00077 /* Constructors, Destructors, Copiers and Cleaners ****************************/ 00078 00085 DLlist_ptr DLlist_create(void); 00086 00095 void DLlist_destroy(DLlist_ptr self); 00096 00105 DLlist_ptr DLlist_copy(DLlist_ptr self); 00106 00116 DLlist_ptr DLlist_copy_reversed(DLlist_ptr self); 00117 00118 00119 /* Getters and Setters ********************************************************/ 00120 00127 int DLlist_get_size(DLlist_ptr self); 00128 00129 00130 /* Checkers *******************************************************************/ 00131 00138 boolean DLlist_is_empty(DLlist_ptr self); 00139 00140 00141 /* SubInterface: DLiter ********************************************************/ 00142 00155 boolean DLiter_is_first(DLiter iter); 00156 00167 boolean DLiter_is_end(DLiter iter); 00168 00178 DLiter DLiter_next(DLiter iter); 00179 00189 DLiter DLiter_prev(DLiter iter); 00190 00200 void* DLiter_element(DLiter iter); 00201 00202 00203 /* Methods that work with a DLiter *********************************************/ 00204 00224 DLiter DLlist_first(DLlist_ptr self); 00225 00243 DLiter DLlist_end(DLlist_ptr self); 00244 00260 DLiter DLlist_insert_after(DLlist_ptr self, DLiter iter, 00261 void* element); 00262 00279 DLiter DLlist_insert_before(DLlist_ptr self, DLiter iter, 00280 void* element); 00281 00300 DLiter DLlist_delete(DLlist_ptr self, DLiter iter, void** element); 00301 00302 00303 /* Miscellaneous **************************************************************/ 00304 00314 void DLlist_reverse(DLlist_ptr self); 00315 00324 void DLlist_prepend(DLlist_ptr self, void* element); 00325 00334 void DLlist_append(DLlist_ptr self, void* element); 00335 00345 void* DLlist_delete_first(DLlist_ptr self); 00346 00356 void* DLlist_delete_last(DLlist_ptr self); 00357 00358 00359 /* Self-test/Debug ************************************************************/ 00360 00370 void dl_list_testing_function(StreamMgr_ptr streams); 00371 00372 00373 #endif /* __NUSMV_CORE_UTILS_DLLIST_H__ */