-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvector.h
More file actions
29 lines (25 loc) · 827 Bytes
/
vector.h
File metadata and controls
29 lines (25 loc) · 827 Bytes
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 VECTOR_H
#define VECTOR_H
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#define VECTOR struct vector
struct vector {
size_t capacity;
size_t size;
size_t elem_size;
void *data;
void (*push)(struct vector *v, void *data);
// void (*at)(struct vector *v, size_t index) = NULL;
void *(*at)(struct vector *v, size_t index);
void (*free_mem)(struct vector *v);
void (*push_string)(struct vector *v, char *string, size_t string_size);
bool (*compare_str)(struct vector *v, char *string_to_compared_with);
};
struct vector create_void_vector();
struct vector create_string_vector();
struct vector buffer_to_vector(void *buffer, int buffer_size);
void *vector_to_buffer(struct vector vec);
void append_vector_to_vector(struct vector *dest, struct vector *src);
#endif