00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef REF_ARRAY_H
00021 #define REF_ARRAY_H
00022
00023 #include <stdint.h>
00024 #include <stdlib.h>
00025
00026 struct ref_array;
00027
00028 #ifndef EOK
00029 #define EOK 0
00030 #endif
00031
00074 typedef enum
00075 {
00076 REF_ARRAY_DESTROY,
00077 REF_ARRAY_DELETE,
00078 } ref_array_del_enum;
00079
00080
00087 typedef void (*ref_array_fn)(void *elem,
00088 ref_array_del_enum type,
00089 void *data);
00090
00091
00108 int ref_array_create(struct ref_array **ra,
00109 size_t elem,
00110 uint32_t grow_by,
00111 ref_array_fn cb,
00112 void *data);
00113
00122 struct ref_array *ref_array_getref(struct ref_array *ra);
00123
00131 void ref_array_destroy(struct ref_array *ra);
00132
00149 int ref_array_append(struct ref_array *ra, void *element);
00150
00175 void *ref_array_get(struct ref_array *ra, uint32_t idx, void *acptr);
00176
00189 int ref_array_getlen(struct ref_array *ra, uint32_t *len);
00190
00200 uint32_t ref_array_len(struct ref_array *ra);
00201
00228 int ref_array_insert(struct ref_array *ra,
00229 uint32_t idx,
00230 void *element);
00253 int ref_array_replace(struct ref_array *ra,
00254 uint32_t idx,
00255 void *element);
00256
00257
00274 int ref_array_remove(struct ref_array *ra,
00275 uint32_t idx);
00276
00277
00294 int ref_array_swap(struct ref_array *ra,
00295 uint32_t idx1,
00296 uint32_t idx2);
00297
00298
00314 void ref_array_reset(struct ref_array *ra);
00315
00321 #endif