#ifndef LEO_VEC_H #define LEO_VEC_H #include #include "../error.h" #include "alloc.h" static const size_t LEO_Vec_GROWTH_FACTOR_NUMER = 3; static const size_t LEO_Vec_GROWTH_FACTOR_DENOM = 2; static const size_t LEO_Vec_DEFAULT_CAPACITY = 8; typedef struct { LEO_Allocator allocator; void *data; size_t item_size; size_t length; size_t capacity; } LEO_Vec; LEO_Error LEO_Vec_init (LEO_Vec *vec, size_t item_size, LEO_Allocator allocator); void LEO_Vec_free (LEO_Vec *vec); LEO_Error LEO_Vec_push (LEO_Vec *vec, const void *item); LEO_Error LEO_Vec_pop (LEO_Vec *vec, void *item); LEO_Error LEO_Vec_get (LEO_Vec *vec, size_t i, void *item); #endif