Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef VECTOR_GENERIC_MACROS
- #define VECTOR_GENERIC_MACROS
- #ifndef TOKENPASTE
- #define TOKENPASTE(x, y) x ## y
- #endif
- #define vector_at(vector, pos) (vector).data[pos]
- #define vector_init(T) TOKENPASTE(vector_init_, T)
- #define vector_destroy(T) TOKENPASTE(vector_destroy_, T)
- #define vector_push_back(T) TOKENPASTE(vector_push_back_, T)
- #define vector_pop_back(T) TOKENPASTE(vector_pop_back_, T)
- #define vector_resize(T) TOKENPASTE(vector_resize_, T)
- #define vector_reserve(T) TOKENPASTE(vector_reserve_, T)
- #define vector_t(T) TOKENPASTE(vector_t_, T)
- #endif
- typedef struct
- {
- size_t size;
- size_t capacity;
- TYPE *data;
- } vector_t(TYPE);
- void vector_init(TYPE)(vector_t(TYPE) *vector, size_t size);
- void vector_destroy(TYPE)(vector_t(TYPE) *vector);
- void vector_push_back(TYPE)(vector_t(TYPE) *vector, TYPE value);
- TYPE vector_pop_back(TYPE)(vector_t(TYPE) *vector);
- void vector_resize(TYPE)(vector_t(TYPE) *vector, size_t size);
- void vector_reserve(TYPE)(vector_t(TYPE) *vector, size_t size);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement