blob: 441cce2ceabc46ab6963cafb2964d9034141d8e7 (
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#ifndef OSM_UTILS_H
#define OSM_UTILS_H
#include <stdbool.h>
// Vector utilities
/**
* Vector represents a dynamic array
*/
typedef struct {
unsigned int count, size, elsz;
void *data;
} Vector;
/**
* Get an initialized vector struct
*/
Vector vect_init(unsigned int elsz);
/**
* Add an element to an arbitrary index in the vector
*/
bool vect_add(Vector *vec, unsigned int index, void *el);
/**
* Remove an element from an arbitrary index in the vector
*/
bool vect_remove(Vector *vec, unsigned int index);
/**
* Push an element to the end of the vector
*/
bool vect_push(Vector *vec, void *el);
/**
* Pop an element from the end of the vector
*/
bool vect_pop(Vector *vec);
/**
* Get an element from the vector
*/
void *vect_get(Vector *vec, unsigned int index);
/**
* Set an element inside the vector
*/
bool vect_set(Vector *vec, unsigned int index, void *el);
/**
* Clear all data in a vector
*/
void vect_clear(Vector *vec);
/**
* Remove all associated data from the vector
*/
void vect_end(Vector *vect);
#endif
|