blob: 889b649d556dfaaa14f62a52cda8c672b5aedc8d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#ifndef LEO_VEC_H
#define LEO_VEC_H
#include <stddef.h>
#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
|