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. */
10 #include "xbt/misc.h" /* BEGIN_DECL */
14 /** \addtogroup XBT_fifo
17 /** @name 1. Constructor/destructor
21 /** \brief Bucket structure
23 typedef struct xbt_fifo_item *xbt_fifo_item_t;
25 /** \brief FIFO structure
27 typedef struct xbt_fifo *xbt_fifo_t;
29 xbt_fifo_t xbt_fifo_new(void);
30 void xbt_fifo_free(xbt_fifo_t);
33 /** @name 2. Perl-like functions
36 xbt_fifo_item_t xbt_fifo_push(xbt_fifo_t, void *);
37 void *xbt_fifo_pop(xbt_fifo_t);
38 xbt_fifo_item_t xbt_fifo_unshift(xbt_fifo_t, void *);
39 void *xbt_fifo_shift(xbt_fifo_t);
40 int xbt_fifo_size(xbt_fifo_t);
41 int xbt_fifo_is_in(xbt_fifo_t, void *);
44 /** @name 3. Manipulating items directly
49 xbt_fifo_item_t xbt_fifo_new_item(void);
50 void xbt_fifo_set_item_content(xbt_fifo_item_t, void *);
51 void *xbt_fifo_get_item_content(xbt_fifo_item_t);
52 void xbt_fifo_free_item(xbt_fifo_item_t);
54 void xbt_fifo_push_item(xbt_fifo_t, xbt_fifo_item_t);
55 xbt_fifo_item_t xbt_fifo_pop_item(xbt_fifo_t);
56 void xbt_fifo_unshift_item(xbt_fifo_t, xbt_fifo_item_t);
57 xbt_fifo_item_t xbt_fifo_shift_item(xbt_fifo_t);
59 void xbt_fifo_remove(xbt_fifo_t, void *);
60 void xbt_fifo_remove_item(xbt_fifo_t, xbt_fifo_item_t);
62 xbt_fifo_item_t xbt_fifo_get_first_item(xbt_fifo_t l);
63 xbt_fifo_item_t xbt_fifo_get_next_item(xbt_fifo_item_t i);
64 xbt_fifo_item_t xbt_fifo_get_prev_item(xbt_fifo_item_t i);
67 * \brief List iterator
69 * \param f a list (#xbt_fifo_t)
70 * \param i a bucket (#xbt_fifo_item_t)
72 * \param n an object of type \a type.
74 * Iterates over the whole list.
76 #define xbt_fifo_foreach(f,i,n,type) \
77 for(i=xbt_fifo_get_first_item(f); \
78 ((i)?(n=(type)(xbt_fifo_get_item_content(i))):(NULL)); \
79 i=xbt_fifo_get_next_item(i))
83 /** @name 4. Miscanaleous
87 void **xbt_fifo_to_array(xbt_fifo_t);
88 xbt_fifo_t xbt_fifo_copy(xbt_fifo_t);
91 /** @name 5. Deprecated functions: don't use!
95 xbt_fifo_item_t xbt_fifo_newitem(void);
96 void xbt_fifo_freeitem(xbt_fifo_item_t);
98 xbt_fifo_item_t xbt_fifo_getFirstItem(xbt_fifo_t l);
99 xbt_fifo_item_t xbt_fifo_getNextItem(xbt_fifo_item_t i);
100 xbt_fifo_item_t xbt_fifo_getPrevItem(xbt_fifo_item_t i);
106 #endif /* _XBT_FIFO_H */