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
00093 typedef void (*ref_array_fn)(void *elem,
00094 ref_array_del_enum type,
00095 void *data);
00096
00112 typedef int (*ref_array_copy_cb)(void *elem,
00113 void *new_elem);
00114
00131 int ref_array_create(struct ref_array **ra,
00132 size_t elem,
00133 uint32_t grow_by,
00134 ref_array_fn cb,
00135 void *data);
00136
00145 struct ref_array *ref_array_getref(struct ref_array *ra);
00146
00154 void ref_array_destroy(struct ref_array *ra);
00155
00172 int ref_array_append(struct ref_array *ra, void *element);
00173
00198 void *ref_array_get(struct ref_array *ra, uint32_t idx, void *acptr);
00199
00212 int ref_array_getlen(struct ref_array *ra, uint32_t *len);
00213
00223 uint32_t ref_array_len(struct ref_array *ra);
00224
00251 int ref_array_insert(struct ref_array *ra,
00252 uint32_t idx,
00253 void *element);
00276 int ref_array_replace(struct ref_array *ra,
00277 uint32_t idx,
00278 void *element);
00279
00280
00297 int ref_array_remove(struct ref_array *ra,
00298 uint32_t idx);
00299
00300
00317 int ref_array_swap(struct ref_array *ra,
00318 uint32_t idx1,
00319 uint32_t idx2);
00320
00321
00337 void ref_array_reset(struct ref_array *ra);
00338
00339
00359 int ref_array_copy(struct ref_array *ra,
00360 ref_array_copy_cb copy_cb,
00361 ref_array_fn cb,
00362 void *data,
00363 struct ref_array **copy_ra);
00364
00365
00366
00380 void ref_array_debug(struct ref_array *ra, int num);
00381
00387 #endif