summaryrefslogtreecommitdiff
path: root/include/osm/utils.h
blob: 5a53f4126ebbf9103bb4a672e0401763f0ff19a2 (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
#ifndef OSM_UTILS_H
#define OSM_UTILS_H

// Vector utilities

/**
 * Vector represents a dynamic array
 */
typedef struct {
	unsigned int count, size, elsz;
	void *data;
} Vector;

Vector vect_init(unsigned int elsz);

/**
 * Add an element to an arbitrary index in the vector
 */
void vect_add(Vector *vec, unsigned int index);

/**
 * Remove an element from an arbitrary index in the vector
 */
void vect_remove(Vector *vec, unsigned int index);

/**
 * Push an element to the end of the vector
 */
void vect_push(Vector *vec, void *el);

/**
 * Pop an element from the end of the vector
 */
void vect_pop(Vector *vec);

/**
 * Get an element from the vector
 */
void *vect_get(Vector *vec, unsigned int index);

/**
 * Set an element inside the vector
 */
void *vect_set(Vector *vec, unsigned int index, void *el);

/**
 * Remove all associated data from the vector
 */
void vect_end(Vector *vect);


#endif