00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef CUCON_PARRAY_H
00019 #define CUCON_PARRAY_H
00020
00021 #include <cucon/fwd.h>
00022 #include <cucon/array.h>
00023
00024 CU_BEGIN_DECLARATIONS
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 struct cucon_parray
00036 {
00037 struct cucon_array arr;
00038 };
00039
00040
00041 CU_SINLINE void
00042 cucon_parray_init_empty(cucon_parray_t arr)
00043 { cucon_array_init(&arr->arr, cu_false, 0); }
00044
00045
00046 CU_SINLINE cucon_parray_t
00047 cucon_parray_new_empty(void)
00048 { return (cucon_parray_t)cucon_array_new(cu_false, 0); }
00049
00050
00051 CU_SINLINE void
00052 cucon_parray_init_size(cucon_parray_t arr, size_t size)
00053 { cucon_array_init(&arr->arr, cu_false, size*sizeof(void *)); }
00054
00055
00056 CU_SINLINE cucon_parray_t
00057 cucon_parray_new_size(size_t size)
00058 { return (cucon_parray_t)cucon_array_new(cu_false, size*sizeof(void *)); }
00059
00060
00061 void cucon_parray_init_fill(cucon_parray_t arr, size_t size, void *ptr);
00062
00063
00064 cucon_parray_t cucon_parray_new_fill(size_t size, void *ptr);
00065
00066
00067 CU_SINLINE void
00068 cucon_parray_swap(cucon_parray_t arr0, cucon_parray_t arr1)
00069 { cucon_array_swap(&arr0->arr, &arr1->arr); }
00070
00071
00072 CU_SINLINE size_t
00073 cucon_parray_size(cucon_parray_t arr)
00074 { return cucon_array_size(&arr->arr)/sizeof(void *); }
00075
00076
00077 CU_SINLINE cu_ptr_ptr_t
00078 cucon_parray_ref_at(cucon_parray_t arr, size_t index)
00079 { return cucon_array_ref_at(&arr->arr, index*sizeof(void *)); }
00080
00081
00082 CU_SINLINE void *
00083 cucon_parray_at(cucon_parray_t arr, size_t index)
00084 { return *(void **)cucon_array_ref_at(&arr->arr, index*sizeof(void *)); }
00085
00086
00087 CU_SINLINE void
00088 cucon_parray_set_at(cucon_parray_t arr, size_t index, void *ptr)
00089 { *(void **)cucon_array_ref_at(&arr->arr, index*sizeof(void *)) = ptr; }
00090
00091
00092 CU_SINLINE void
00093 cucon_parray_resize_gp(cucon_parray_t arr, size_t size)
00094 { cucon_array_resize_gp(&arr->arr, size*sizeof(void *)); }
00095
00096
00097 CU_SINLINE void
00098 cucon_parray_resize_gpmax(cucon_parray_t arr, size_t size)
00099 { cucon_array_resize_gpmax(&arr->arr, size*sizeof(void *)); }
00100
00101
00102 CU_SINLINE void
00103 cucon_parray_resize_exact(cucon_parray_t arr, size_t size)
00104 { cucon_array_resize_exact(&arr->arr, size*sizeof(void *)); }
00105
00106
00107 CU_SINLINE void
00108 cucon_parray_resize_exactmax(cucon_parray_t arr, size_t size)
00109 { cucon_array_resize_exactmax(&arr->arr, size*sizeof(void *)); }
00110
00111
00112 void cucon_parray_resize_gp_fill(cucon_parray_t arr, size_t size, void *ptr);
00113
00114
00115
00116 void cucon_parray_resize_gpmax_fill(cucon_parray_t arr, size_t size, void *ptr);
00117
00118
00119
00120 void cucon_parray_resize_exact_fill(cucon_parray_t arr, size_t size, void *ptr);
00121
00122
00123
00124 void cucon_parray_resize_exactmax_fill(cucon_parray_t arr, size_t size,
00125 void *ptr);
00126
00127
00128
00129 CU_SINLINE void
00130 cucon_parray_append_gp(cucon_parray_t arr, void *elt)
00131 {
00132 void **p = (void **)cucon_array_extend_gp(&arr->arr, sizeof(void *));
00133 *p = elt;
00134 }
00135
00136
00137 void cucon_parray_fill_all(cucon_parray_t arr, void *ptr);
00138
00139
00140
00141 void cucon_parray_fill_range(cucon_parray_t arr,
00142 size_t start, size_t end, void *ptr);
00143
00144
00145
00146 CU_SINLINE void **
00147 cucon_parray_begin(cucon_parray_t arr)
00148 { return (void **)cucon_array_begin(&arr->arr); }
00149
00150
00151
00152 CU_SINLINE void **
00153 cucon_parray_end(cucon_parray_t arr)
00154 { return (void **)cucon_array_end(&arr->arr); }
00155
00156
00157 CU_END_DECLARATIONS
00158
00159 #endif