00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __NUSMV_CORE_UTILS_LIST_H__
00021 #define __NUSMV_CORE_UTILS_LIST_H__
00022
00028 #define LS_DEFINED
00029
00030 #if HAVE_CONFIG_H
00031 # include "nusmv-config.h"
00032 #endif
00033
00034
00035
00036 typedef struct ls_dummy_defn {
00037 int dummy;
00038 } ls_dummy;
00039
00045 typedef ls_dummy *lsList;
00046 typedef ls_dummy *lsGen;
00047 typedef ls_dummy *lsHandle;
00048
00052 typedef int lsStatus;
00053
00057 typedef void *lsGeneric;
00058
00062 #define LS_NIL 0
00063
00067 #define LS_BADSTATE -3
00068
00072 #define LS_BADPARAM -2
00073
00077 #define LS_NOMORE -1
00078
00082 #define LS_OK 0
00083
00087 #define LS_BEFORE 1
00088
00092 #define LS_AFTER 2
00093
00097 #define LS_STOP 3
00098
00102 #define LS_DELETE 4
00103
00108 #define LS_NH (lsHandle *) 0
00109
00110
00111 typedef lsGeneric (*LS_PFLSG)(lsGeneric);
00112
00116 #define LS_COPY (LS_PFLSG) (-1)
00117
00125 lsList lsCreate(void);
00126
00135 lsList lsSingleton(lsGeneric, lsHandle *);
00136
00145 lsStatus lsDestroy(lsList, void (*)(lsGeneric));
00146
00150 lsStatus lsDestroyListList(lsList);
00151
00164 lsList lsCopy(lsList, LS_PFLSG);
00165
00169 lsList lsCopyListList(lsList);
00170
00174 lsList lsAppend(lsList, lsList, LS_PFLSG);
00175
00179 void lsJoin(lsList, lsList, LS_PFLSG);
00180
00189 lsStatus lsFirstItem(lsList, lsGeneric *, lsHandle *);
00190
00201 lsStatus lsLastItem(lsList, lsGeneric *, lsHandle *);
00202
00211 lsStatus lsNewBegin(lsList, lsGeneric, lsHandle *);
00212
00220 lsStatus lsNewEnd(lsList, lsGeneric, lsHandle *);
00221
00230 lsStatus lsDelBegin(lsList, lsGeneric *);
00231
00240 lsStatus lsDelEnd(lsList, lsGeneric *);
00241
00248 int lsLength(lsList);
00249
00258 lsGen lsStart(lsList);
00259
00267 lsGen lsEnd(lsList);
00268
00281 lsGen lsGenHandle(lsHandle, lsGeneric *, int);
00282
00298 lsStatus lsNext(lsGen, lsGeneric *, lsHandle *);
00299
00315 lsStatus lsPrev(lsGen, lsGeneric *, lsHandle *);
00316
00326 lsStatus lsInBefore(lsGen, lsGeneric, lsHandle *);
00327
00337 lsStatus lsInAfter(lsGen, lsGeneric, lsHandle *);
00338
00349 lsStatus lsDelBefore(lsGen, lsGeneric *);
00350
00361 lsStatus lsDelAfter(lsGen, lsGeneric *);
00362
00372 lsStatus lsFinish(lsGen);
00373
00380 lsList lsQueryHandle(lsHandle);
00381
00388 lsGeneric lsFetchHandle(lsHandle);
00389
00398 lsStatus lsRemoveItem(lsHandle, lsGeneric *);
00399
00412 lsStatus lsSort(lsList, int (*compare)(char*, char*));
00413
00428 lsStatus lsUniq(lsList, int (*compare)(char*, char*), void (*delFunc)(lsGeneric));
00429
00448 lsStatus lsForeach(lsList list,
00449 lsStatus (*userFunc)(lsGeneric, lsGeneric),
00450 lsGeneric arg);
00451
00460 lsStatus lsBackeach(lsList list,
00461 lsStatus (*userFunc)(lsGeneric, lsGeneric),
00462 lsGeneric arg);
00463
00474 #define lsForEachItem( \
00475 list, \
00476 gen, \
00477 data \
00478 ) \
00479 for(gen = lsStart(list); \
00480 (lsNext(gen, (lsGeneric *) &data, LS_NH) == LS_OK) \
00481 || ((void) lsFinish(gen), 0); \
00482 )
00483
00484
00485 #endif