-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvector.h
44 lines (30 loc) · 1.2 KB
/
vector.h
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
#ifndef VECTOR_H
#define VECTOR_H
#include "parser.h"
#include <stdbool.h>
#include <stddef.h>
typedef struct vec_vector vec_Vector;
// Initializes a new vector
vec_Vector *vec_new(void);
// Pushes a value to vector
bool vec_push(vec_Vector *restrict vec, ns_Item item);
// Removes an item from the end of the vector and assigns it to dest
ns_Item vec_pop(vec_Vector *restrict vec);
// Returns how many items are in the vector
size_t vec_len(const vec_Vector *vec);
// Returns the total amount of items that can currently be stored
size_t vec_capacity(const vec_Vector *vec);
// Clears out all the memory used by the vector
void vec_free(vec_Vector *restrict vec);
// Returns item at index
ns_Item vec_get(const vec_Vector *vec, const size_t index);
// Prints the vector with the specified format specifier
void vec_printf(const char *restrict fmt, const vec_Vector *vec);
// Inserts a new item at index
bool vec_insert(vec_Vector *vec, const size_t index, ns_Item *item);
// Removes an item at index
bool vec_remove(vec_Vector *restrict vec, const size_t index);
bool vec_is_empty(const vec_Vector *vec);
// Appends vector from src to dest
bool vec_append(vec_Vector *restrict dest, const vec_Vector *src);
#endif