3 /* Copyright (c) 2004 Arnaud Legrand. All rights reserved. */
5 /* This program is free software; you can redistribute it and/or modify it
6 * under the terms of the license (GNU LGPL) which comes with this package. */
11 /** \brief Bucket structure
14 typedef struct xbt_fifo_item *xbt_fifo_item_t;
16 /** \brief FIFO structure
19 typedef struct xbt_fifo *xbt_fifo_t;
22 xbt_fifo_t xbt_fifo_new(void);
23 void xbt_fifo_free(xbt_fifo_t);
25 xbt_fifo_item_t xbt_fifo_push(xbt_fifo_t, void *);
26 void *xbt_fifo_pop(xbt_fifo_t);
27 xbt_fifo_item_t xbt_fifo_unshift(xbt_fifo_t, void *);
28 void *xbt_fifo_shift(xbt_fifo_t);
30 void xbt_fifo_push_item(xbt_fifo_t, xbt_fifo_item_t);
31 xbt_fifo_item_t xbt_fifo_pop_item(xbt_fifo_t);
32 void xbt_fifo_unshift_item(xbt_fifo_t, xbt_fifo_item_t);
33 xbt_fifo_item_t xbt_fifo_shift_item(xbt_fifo_t);
35 void xbt_fifo_remove(xbt_fifo_t, void *);
36 void xbt_fifo_remove_item(xbt_fifo_t, xbt_fifo_item_t);
38 int xbt_fifo_is_in(xbt_fifo_t, void *);
40 void **xbt_fifo_to_array(xbt_fifo_t);
41 xbt_fifo_t xbt_fifo_copy(xbt_fifo_t);
43 xbt_fifo_item_t xbt_fifo_newitem(void);
44 void xbt_fifo_set_item_content(xbt_fifo_item_t, void *);
45 void *xbt_fifo_get_item_content(xbt_fifo_item_t);
46 void xbt_fifo_freeitem(xbt_fifo_item_t);
48 int xbt_fifo_size(xbt_fifo_t);
50 xbt_fifo_item_t xbt_fifo_getFirstItem(xbt_fifo_t l);
51 xbt_fifo_item_t xbt_fifo_getNextItem(xbt_fifo_item_t i);
52 xbt_fifo_item_t xbt_fifo_getPrevItem(xbt_fifo_item_t i);
55 * \brief List iterator
58 * \param f a list (#xbt_fifo_t)
59 * \param i a bucket (#xbt_fifo_item_t)
61 * \param n an object of type \a type.
63 * Iterates over the whole list.
65 #define xbt_fifo_foreach(f,i,n,type) \
66 for(i=xbt_fifo_getFirstItem(f); \
67 ((i)?(n=(type)(xbt_fifo_get_item_content(i))):(NULL)); \
68 i=xbt_fifo_getNextItem(i))
71 #endif /* _XBT_FIFO_H */