Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Do generate the header we need with flexml
[simgrid.git] / include / xbt / fifo.h
1 /*      $Id$     */
2
3 /* Copyright (c) 2004 Arnaud Legrand. All rights reserved.                  */
4
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. */
7
8 #ifndef _XBT_FIFO_H
9 #define _XBT_FIFO_H
10
11 /** \brief  Bucket structure 
12  *  \ingroup XBT_fifo
13 */
14 typedef struct xbt_fifo_item *xbt_fifo_item_t;
15
16 /** \brief  FIFO structure
17  *  \ingroup XBT_fifo
18 */
19 typedef struct xbt_fifo *xbt_fifo_t;
20
21 /* API */
22 xbt_fifo_t xbt_fifo_new(void);
23 void xbt_fifo_free(xbt_fifo_t);
24
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);
29
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);
34
35 void xbt_fifo_remove(xbt_fifo_t, void *);
36 void xbt_fifo_remove_item(xbt_fifo_t, xbt_fifo_item_t);
37
38 int xbt_fifo_is_in(xbt_fifo_t, void *);
39
40 void **xbt_fifo_to_array(xbt_fifo_t);
41 xbt_fifo_t xbt_fifo_copy(xbt_fifo_t);
42
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);
47
48 int xbt_fifo_size(xbt_fifo_t);
49
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);
53
54 /** 
55  * \brief List iterator
56  * \ingroup XBT_fifo
57  * asserts and stuff
58  * \param f a list (#xbt_fifo_t)
59  * \param i a bucket (#xbt_fifo_item_t)
60  * \param type a type
61  * \param n an object of type \a type.
62  *
63  * Iterates over the whole list. 
64  */
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))
69
70
71 #endif                          /* _XBT_FIFO_H */