prosperon/source/engine/vec.h

33 lines
861 B
C
Raw Normal View History

2021-11-30 21:29:18 -06:00
#ifndef VEC_H
#define VEC_H
#include <stdio.h>
struct vec {
int len;
int size;
2022-02-06 10:14:57 -06:00
size_t width;
2021-11-30 21:29:18 -06:00
void *data;
};
2022-02-06 10:14:57 -06:00
struct vec *vec_make(size_t width, int size);
2021-11-30 21:29:18 -06:00
void *vec_get(struct vec *vec, int n);
void vec_walk(struct vec *vec, void (*fn)(void *data));
void vec_clear(struct vec *vec);
2022-02-06 10:14:57 -06:00
void *vec_add(struct vec *vec, const void *data);
2021-11-30 21:29:18 -06:00
/* sort returns 0 for a<=b, 1 for a>b */
void *vec_add_sort(struct vec *vec, void *data,
int (*sort)(void *a, void *b));
void *vec_insert(struct vec *vec, void *data, int n);
void *vec_set(struct vec *vec, int n, void *data);
void vec_delete(struct vec *vec, int n);
void vec_del_order(struct vec *vec, int n);
void vec_store(struct vec *vec, FILE *f);
void vec_load(struct vec *vec, FILE *f);
char *vec_p(struct vec *vec, int n);
void vec_expand(struct vec *vec);
void vec_fit(struct vec *vec);
2022-02-06 10:14:57 -06:00
#endif