cvecadv.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef __CVECADV_H__
  2. #define __CVECADV_H__
  3. #include "cvector.h"
  4. /* copy the vec_src to vec_dest
  5. [out] vec_dest
  6. [in] vec_src
  7. @@@ return vector
  8. */
  9. #define cvector_copy(vec_dest, vec_src) cvector_copy_func((void **) &vec_dest, vec_src, vec_src ? sizeof(*vec_src) : 0)
  10. #define cvector_ccopy(vec_dest, vec_src, foo) \
  11. do { \
  12. cvector_destroy(vec_dest); \
  13. vec_dest = vec_src ? __cvector_initialization_type(cvector_get_size(vec_src), sizeof(*vec_src)) : NULL; \
  14. cvector_set_size(vec_dest, cvector_get_size(vec_src)); \
  15. cvector_set_constructor(vec_dest, cvector_get_constructor(vec_src)); \
  16. cvector_set_destructor(vec_dest, cvector_get_destructor(vec_src)); \
  17. for (int i = 0; i < cvector_get_size(vec_src); ++i) { \
  18. foo(&(vec_dest)[i], &(vec_src)[i]); \
  19. } \
  20. } while(0)
  21. /* concatenation two of vectors
  22. [out] vec_dest
  23. [out] vec_src = NULL
  24. @@@ return resulting vector
  25. */
  26. #define cvector_con(vec_dest, vec_src) cvector_concatenation((void **) &vec_dest, (void **) &vec_src, vec_src ? sizeof(*vec_src) : 0)
  27. void* cvector_copy_func(void** vec_dest, void* vec_src, size_t size_object);
  28. void* cvector_concatenation(void** vec_dest, void** vec_src, size_t size_object);
  29. #endif // __CVECADV_H__