return (it->indx=cust_prefix##_find_after_indx(container, key))!=(unsigned)-1;\
}
-/* Declaration of new static custom array without support of runtime modifications */
-#define GSA_STATIC_CUST_DEC(cust_prefix, cust_array_t, cust_item_t, cust_key_t,\
+/* Declaration of new const custom array without support of runtime modifications */
+#define GSA_CONST_CUST_DEC(cust_prefix, cust_array_t, cust_item_t, cust_key_t,\
cust_array_field, cust_item_key, cust_cmp_fnc) \
\
GSA_BASE_CUST_DEC(cust_prefix, cust_array_t, cust_item_t, cust_key_t,\
\
GSA_IT_CUST_DEC(cust_prefix, const cust_array_t, cust_item_t, cust_key_t)
-/*** Declaration of dynamic custom array with ***/
+/*** Declaration of dynamic custom array with full functions ***/
#define GSA_CUST_DEC(cust_prefix, cust_array_t, cust_item_t, cust_key_t,\
cust_array_field, cust_item_key, cust_cmp_fnc) \
\
cust_prefix##_delete_at(it->container,it->indx);\
}\
+/*** Declaration of static custom array with limited functions ***/
+#define GSA_STATIC_CUST_DEC(cust_prefix, cust_array_t, cust_item_t, cust_key_t,\
+ cust_array_field, cust_item_key, cust_cmp_fnc) \
+\
+GSA_BASE_CUST_DEC(cust_prefix, cust_array_t, cust_item_t, cust_key_t,\
+ cust_array_field, cust_item_key, cust_cmp_fnc) \
+\
+int cust_prefix##_insert(cust_array_t *array, cust_item_t *item);\
+int cust_prefix##_delete(cust_array_t *array, const cust_item_t *item);\
+void cust_prefix##_init_array_field(cust_array_t *array);\
+int cust_prefix##_insert_at(cust_array_t *array, cust_item_t *item, unsigned indx);\
+int cust_prefix##_delete_at(cust_array_t *array, unsigned indx); \
+\
+static inline void \
+cust_prefix##_delete_all(cust_array_t *array)\
+{\
+ cust_prefix##_init_array_field(array);\
+}\
+\
+static inline cust_item_t *\
+cust_prefix##_cut_last(cust_array_t *array)\
+{\
+ if(cust_prefix##_is_empty(array)) return NULL;\
+ return (cust_item_t *)array->cust_array_field.items\
+ [--array->cust_array_field.count];\
+}\
+/*** Iterators ***/\
+GSA_IT_CUST_DEC(cust_prefix, cust_array_t, cust_item_t, cust_key_t) \
+\
+static inline void \
+cust_prefix##_delete_it(cust_prefix##_it_t *it)\
+{\
+ cust_prefix##_delete_at(it->container,it->indx);\
+}\
+
/* The next implementation of foreaach is elegant, but can not
be used in C99 non-conformant C compiler */
extern "C" {
#endif
-/* Static version of custom GSA arrays. It does not support runtime modifications. */
-#define GSA_STATIC_CUST_IMP(cust_prefix, cust_array_t, cust_item_t, cust_key_t,\
+/* Constant version of custom GSA arrays. It does not support runtime modifications. */
+#define GSA_CONST_CUST_IMP(cust_prefix, cust_array_t, cust_item_t, cust_key_t,\
cust_array_field, cust_item_key, cust_cmp_fnc, cust_ins_fl) \
\
int \
#define GSA_CUST_IMP(cust_prefix, cust_array_t, cust_item_t, cust_key_t,\
cust_array_field, cust_item_key, cust_cmp_fnc, cust_ins_fl) \
\
-GSA_STATIC_CUST_IMP(cust_prefix, cust_array_t, cust_item_t, cust_key_t,\
+GSA_CONST_CUST_IMP(cust_prefix, cust_array_t, cust_item_t, cust_key_t,\
cust_array_field, cust_item_key, cust_cmp_fnc, cust_ins_fl) \
\
int \
}
+/* Static version with limited support of insert and delete functions. */
+#define GSA_STATIC_CUST_IMP(cust_prefix, cust_array_t, cust_item_t, cust_key_t,\
+ cust_array_field, cust_item_key, cust_cmp_fnc, cust_ins_fl) \
+\
+GSA_CUST_IMP(cust_prefix, cust_array_t, cust_item_t, cust_key_t,\
+ cust_array_field, cust_item_key, cust_cmp_fnc, cust_ins_fl) \
+\
+void \
+cust_prefix##_init_array_field(cust_array_t *array)\
+{\
+ array->cust_array_field.count=0;\
+ array->cust_array_field.alloc_count=0;\
+ array->cust_array_field.items=NULL;\
+}\
+\
+int \
+cust_prefix##_insert_at(cust_array_t *array, cust_item_t *item, unsigned indx)\
+{\
+ unsigned cnt=array->cust_array_field.count; \
+ uloi_ciddes_t **p; \
+\
+ if(indx>cnt) indx=cnt;\
+ if(cnt+1>=array->cust_array_field.alloc_count)\
+ return -1;\
+\
+ p=array->cust_array_field.items+indx;\
+ memmove(p+1,p,(char*)(array->cust_array_field.items+cnt)-(char*)p);\
+ array->cust_array_field.count=cnt+1;\
+ *p=item;\
+ return 0;\
+}\
+\
+int \
+cust_prefix##_delete_at(cust_array_t *array, unsigned indx)\
+{\
+ unsigned cnt=array->cust_array_field.count;\
+ uloi_ciddes_t **p;\
+ if(indx>=cnt) return -1;\
+ p=array->cust_array_field.items+indx;\
+ array->cust_array_field.count=--cnt;\
+ memmove(p,p+1,(array->cust_array_field.items+cnt-p)*sizeof(void *));\
+ return 0;\
+}\
+
+
#ifdef __cplusplus
} /* extern "C"*/
#endif