A simple C dynamic vector library.
Works with any type. Even structs.
Doc:
Vec: the vector struct. contains: the vector itself, the size, the typesize.
vecNew: macro function used to init the vector size to 0. returns a vector.
vecGetElem: macro function used to get a vector element. Params: vector, index, element type. returns the element.
vecPush: function used to insert an element at the front of a vector. Params: vector, element to insert.
vecPop: function used to get an element out of a vector, starting at the front. Params: vector, element to get out.
vecFree: variadic function used to free vectors. Params: number of vectors to be freed, vectors to free.
vecAlloc: function used by the API to initialize a vector's memory. Not meant to be used by the user.
vecResize: function used by the API to resize a vector. Not meant to be used by the user.
Example usage:
Vec vec = vecNew();
int n = 2;
vecPush(&vec, &n);
for (int i = 0; i < vec.size; i++)
{
printf("ELEM %d: %d", i, vecGetElem(vec, i, int));
}
vecFree(1, vec);