Simple C Expat Wrapper (SCEW)  1.1.7
list.h
Go to the documentation of this file.
1 
39 #ifndef LIST_H_0707122009
40 #define LIST_H_0707122009
41 
42 #include "export.h"
43 
44 #include "bool.h"
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif /* __cplusplus */
49 
55 typedef struct scew_list scew_list;
56 
70 typedef void (*scew_list_hook) (scew_list *, void *);
71 
81 typedef scew_bool (*scew_cmp_hook) (void const *, void const *);
82 
83 
101 extern SCEW_API scew_list* scew_list_create (void *data);
102 
109 extern SCEW_API void scew_list_free (scew_list *list);
110 
111 
130 extern SCEW_API void* scew_list_data (scew_list *list);
131 
140 extern SCEW_API unsigned int scew_list_size (scew_list *list);
141 
142 
161 extern SCEW_API scew_list* scew_list_append (scew_list *list, void *data);
162 
175 extern SCEW_API scew_list* scew_list_prepend (scew_list *list, void *data);
176 
190 extern SCEW_API scew_list* scew_list_delete (scew_list *list, void *data);
191 
202 extern SCEW_API scew_list* scew_list_delete_item (scew_list *list,
203  scew_list *item);
204 
205 
224 extern SCEW_API scew_list* scew_list_first (scew_list *list);
225 
238 extern SCEW_API scew_list* scew_list_last (scew_list *list);
239 
249 extern SCEW_API scew_list* scew_list_next (scew_list *list);
250 
261 extern SCEW_API scew_list* scew_list_previous (scew_list *list);
262 
273 extern SCEW_API scew_list* scew_list_index (scew_list *list,
274  unsigned int index);
275 
290 extern SCEW_API void scew_list_foreach (scew_list *list,
291  scew_list_hook hook,
292  void *user_data);
293 
311 extern SCEW_API scew_list* scew_list_find (scew_list *list, void *data);
312 
334 extern SCEW_API scew_list* scew_list_find_custom (scew_list *list,
335  void const *data,
336  scew_cmp_hook hook);
337 
338 #ifdef __cplusplus
339 }
340 #endif /* __cplusplus */
341 
342 #endif /* LIST_H_0707122009 */
scew_bool(* scew_cmp_hook)(void const *, void const *)
SCEW lists comparison hooks are used by scew_list_find_custom.
Definition: list.h:81
void(* scew_list_hook)(scew_list *, void *)
SCEW lists hooks (functions) are used by scew_list_foreach.
Definition: list.h:70
SCEW_API scew_list * scew_list_next(scew_list *list)
Obtains the next item of the given list item.
SCEW_API scew_list * scew_list_find(scew_list *list, void *data)
Finds the first list item that contains data.
SCEW shared library support.
struct scew_list scew_list
This is the type delcaration for SCEW lists.
Definition: list.h:55
SCEW_API scew_list * scew_list_find_custom(scew_list *list, void const *data, scew_cmp_hook hook)
Finds the first list item that matches the given predicate, hook.
SCEW_API void scew_list_foreach(scew_list *list, scew_list_hook hook, void *user_data)
Traverses all list items and executes the given hook for each item found.
unsigned char scew_bool
This should be defined using stdbool.h when C99 is available.
Definition: bool.h:35
SCEW_API scew_list * scew_list_last(scew_list *list)
Finds the last item of the given list.
SCEW_API scew_list * scew_list_append(scew_list *list, void *data)
Creates a new list item with the given data and appends it to list.
SCEW_API scew_list * scew_list_first(scew_list *list)
Finds the first item of the given list.
SCEW_API void * scew_list_data(scew_list *list)
Returns the data pointer of the given list item.
SCEW_API scew_list * scew_list_index(scew_list *list, unsigned int index)
Gets the list item at the given index.
SCEW_API void scew_list_free(scew_list *list)
Frees all the items from the given list.
SCEW_API unsigned int scew_list_size(scew_list *list)
Returns the number of items in the given list.
SCEW_API scew_list * scew_list_prepend(scew_list *list, void *data)
Creates a new list item with the given data and prepends it to list.
SCEW_API scew_list * scew_list_delete(scew_list *list, void *data)
Deletes the first item pointing to data from the given list.
SCEW boolean type declaration.
SCEW_API scew_list * scew_list_delete_item(scew_list *list, scew_list *item)
Deletes the given list item from list.
SCEW_API scew_list * scew_list_previous(scew_list *list)
Obtains the previous item of the given list item.
SCEW_API scew_list * scew_list_create(void *data)
Creates a new list item with the given data.