Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
d4248ed986e6008a326149875e476237b92d50f5
[simgrid.git] / tools / tesh2 / include / list.h
1 #ifndef __list_H
2 #define __list_H
3
4 #include <allocator.h>
5
6
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11 #ifndef __FN_FINALIZE_T_DEFINED
12 typedef int (*fn_finalize_t)(void**);
13 #define __FN_FINALIZE_T_DEFINED
14 #endif
15
16 #ifndef SEEK_SET
17 #define SEEK_SET                                0
18 #endif 
19
20 #ifndef SEEK_CUR
21 #define SEEK_CUR                                1
22 #endif
23
24 #ifndef SEEK_END
25 #define SEEK_END                                2
26 #endif
27
28 #ifndef __LINK_T_DEFINED
29 typedef struct s_link_t
30 {
31         void* item;                                             /* the item associated with the link                                                            */
32         struct s_link_t* next;                  /* address to the next link                                                                                     */
33         struct s_link_t* prev;                  /* address to the prev link                                                                                     */
34 }s_link_t,* link_t;
35 #define __LINK_T_DEFINED
36 #endif
37
38 typedef struct s_list
39 {
40         void* item;                                             /* not used                                                                                                                     */      
41         link_t next;                                    /* point to the last node of the list                                                           */
42         link_t prev;                                    /* point to the first node of the list                                                          */
43         fn_finalize_t fn_finalize;              /* not used                                                                                                                     */
44         int size;                                       /* the number of node contained by the list                                                     */
45         link_t cur;
46         int pos;
47 }s_list_t,* list_t;
48
49 list_t
50 list_new(fn_finalize_t fn_finalize);
51
52 int
53 list_rewind(list_t list);
54
55 int
56 list_unwind(list_t list);
57
58 int
59 list_clear(list_t list);
60
61 int
62 list_free(list_t* list_ptr);
63
64 int
65 list_push_front(list_t list, void* item);
66
67 int
68 list_push_back(list_t list, void* item);
69
70 void*
71 list_pop_back(list_t list);
72
73 void*
74 list_pop_front(list_t list);
75
76 int
77 list_remove(list_t list, void* item);
78
79 int
80 list_get_size(list_t list);
81 int
82 list_contains(list_t list, void* item);
83
84 int
85 list_is_empty(list_t list);
86
87 int
88 list_is_autodelete(list_t list);
89
90 int
91 list_move_next(list_t list);
92
93 void*
94 list_get(list_t list);
95
96 void*
97 list_set(list_t list, void* item);
98
99 void*
100 list_get_at(list_t list, int pos);
101
102 void*
103 list_set_at(list_t list, int pos, void* item);
104
105 int
106 list_move_prev(list_t list);
107
108 int
109 list_seek(list_t list, int offset, int whence);
110
111 int
112 list_tell(list_t list);
113
114 int
115 list_getpos(list_t list, int* pos);
116
117 int
118 list_setpos(list_t list, int pos);
119
120
121 void*
122 list_get_front(list_t list);
123
124 void*
125 list_get_back(list_t list);
126
127 int 
128 list_insert_after(list_t list, void* what, void* where);
129
130 int 
131 list_insert_before(list_t list, void* what, void* where);
132
133
134 #ifdef __cplusplus
135 }
136 #endif
137
138
139 #endif /* !__list_H */