00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef LIST_H
00017 #define LIST_H
00018
00019 #include <assert.h>
00020 #include <inttypes.h>
00021 #include <stdbool.h>
00022 #include <stdio.h>
00023 #include <stdlib.h>
00024 #include <string.h>
00025
00026 #include "common/gru_base.h"
00027 #include "common/gru_status.h"
00028 #include "gru_collection_callbacks.h"
00029 #include "gru_node.h"
00030 #include "gru_node_info.h"
00031
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif
00035
00039 typedef void (*gru_nodedata_destructor)(void **);
00040
00041 typedef struct gru_list_t_ { gru_node_t *root; } gru_list_t;
00042
00047 gru_export gru_list_t *gru_list_new(gru_status_t *status);
00048
00053 gru_export void gru_list_destroy(gru_list_t **list);
00054
00061 gru_export uint32_t gru_list_count(const gru_list_t *list);
00062
00072 gru_export const gru_node_t *gru_list_append(gru_list_t *list, const void *data);
00073
00081 gru_export gru_node_t *
00082 gru_list_insert(gru_list_t *list, const void *data, uint32_t position);
00083
00090 gru_export gru_node_t *gru_list_remove(gru_list_t *list, uint32_t position);
00091
00092
00099 gru_export gru_node_t *gru_list_remove_node(gru_list_t *list, gru_node_t *node);
00100
00108 gru_export bool gru_list_remove_item(gru_list_t *list,
00109 compare_function_t comparable,
00110 const void *other);
00111
00118 gru_export const gru_node_t *gru_list_get(const gru_list_t *list, uint32_t position);
00119
00128 gru_export void gru_list_for_each_compare(const gru_list_t *list,
00129 bool uniqueness,
00130 compare_function_t comparable,
00131 const void *compare,
00132 void *result);
00133
00140 gru_export void
00141 gru_list_for_each(const gru_list_t *list, handle_function_t handle, void *data);
00142
00150 gru_export void gru_list_for_each_ex(const gru_list_t *list,
00151 handle_function_info_t handle,
00152 void *data);
00153
00162 gru_export const void *gru_list_get_item(const gru_list_t *list,
00163 compare_function_t comparable,
00164 const void *other);
00165
00166
00167 gru_export void gru_list_clean(gru_list_t *list, gru_nodedata_destructor destructor);
00168
00169 #ifdef __cplusplus
00170 }
00171 #endif
00172
00173 #endif