|
|
|
@ -47,11 +47,13 @@ int Vector_Pop(Vector *v, void *ptr);
|
|
|
|
|
* Put an element at pos.
|
|
|
|
|
* Note: If pos is outside the vector capacity, we resize it accordingly
|
|
|
|
|
*/
|
|
|
|
|
#define Vector_Put(v, pos, elem) __vector_PutPtr(v, pos, elem ? &(typeof(elem)){elem} : NULL)
|
|
|
|
|
#define Vector_Put(v, pos, elem) \
|
|
|
|
|
__vector_PutPtr(v, pos, elem ? &(typeof(elem)){elem} : NULL)
|
|
|
|
|
|
|
|
|
|
/* Push an element at the end of v, resizing it if needed. This macro wraps
|
|
|
|
|
* __vector_PushPtr */
|
|
|
|
|
#define Vector_Push(v, elem) __vector_PushPtr(v, elem ? &(typeof(elem)){elem} : NULL)
|
|
|
|
|
#define Vector_Push(v, elem) \
|
|
|
|
|
__vector_PushPtr(v, elem ? &(typeof(elem)){elem} : NULL)
|
|
|
|
|
|
|
|
|
|
int __vector_PushPtr(Vector *v, void *elem);
|
|
|
|
|
|
|
|
|
@ -59,10 +61,10 @@ int __vector_PushPtr(Vector *v, void *elem);
|
|
|
|
|
int Vector_Resize(Vector *v, size_t newcap);
|
|
|
|
|
|
|
|
|
|
/* return the used size of the vector, regardless of capacity */
|
|
|
|
|
inline int Vector_Size(Vector *v) { return v->top; }
|
|
|
|
|
int Vector_Size(Vector *v);
|
|
|
|
|
|
|
|
|
|
/* return the actual capacity */
|
|
|
|
|
inline int Vector_Cap(Vector *v) { return v->cap; }
|
|
|
|
|
int Vector_Cap(Vector *v);
|
|
|
|
|
|
|
|
|
|
/* free the vector and the underlying data. Does not release its elements if
|
|
|
|
|
* they are pointers*/
|
|
|
|
|