00001
00114 #ifndef LIST_H
00115 #define LIST_H
00116
00117 #include "cutil.h"
00118
00119
00120
00121
00122 #define NIL (LIST) 0
00123
00132 typedef struct list_rec
00133 {
00134 struct list_rec *node;
00135 struct list_rec *next;
00136 } _LIST_;
00137
00142 typedef _LIST_ *LIST;
00143
00144
00145
00146
00147
00148 #define rest(l) ((l) ? (l)->next : NIL)
00149 #define first(l) ((l) ? (l)->node : NIL)
00150
00155 #define copy_first(l1,l2) \
00156 (l2=push(l2, first(l1)))
00157
00164 #define iterate(l) \
00165 for (; (l) != NIL; (l) = rest (l))
00166
00174 #define iterate_list(x,l) \
00175 for ((x)=(l); (x)!=0; (x)=rest(x))
00176
00182 #define JOIN_ON(list1,list2) \
00183 ((list1) = join ((list1), (list2)))
00184
00190 #define pop_off(list) \
00191 ((list) = pop (list))
00192
00198 #define push_on(list,thing) \
00199 ((list) = push (list, (LIST) (thing)))
00200
00206 #define second(l) \
00207 first (rest (l))
00208
00214 #define set_rest(l,cell)\
00215 ((l)->next = (cell))
00216
00222 #define third(l) \
00223 first (rest (rest (l)))
00224
00225
00226
00227
00228 int count(LIST var_list);
00229
00230 LIST delete_d(LIST list, void *key, int_compare is_equal);
00231
00232 LIST destroy(LIST list);
00233
00234 void destroy_nodes(LIST list, void_dest destructor);
00235
00236 void insert(LIST list, void *node);
00237
00238 int is_same_node(void *item1, void *item2);
00239
00240 int is_same(void *item1, void *item2);
00241
00242 LIST join(LIST list1, LIST list2);
00243
00244 LIST last(LIST var_list);
00245
00246 void *nth_cell(LIST var_list, int item_num);
00247
00248 LIST pop(LIST list);
00249
00250 LIST push(LIST list, void *element);
00251
00252 LIST push_last(LIST list, void *item);
00253
00254 LIST reverse(LIST list);
00255
00256 LIST reverse_d(LIST list);
00257
00258 LIST s_adjoin(LIST var_list, void *variable, int_compare compare);
00259
00260 LIST search(LIST list, void *key, int_compare is_equal);
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340 #endif