SayoriOS 0.3.3

vector.h
1 // libvector - simple dynamic array (vector) library for C by NDRAEY.
2
3 #pragma once
4
5 #include "common.h"
6
7 typedef struct vector {
8 size_t* data;
9
10 size_t size;
11 size_t capacity;
12 } vector_t;
13
14 typedef struct vector_result {
15 bool error;
16 size_t element;
17 } vector_result_t;
18
19 #define VEC_ERR (vector_result_t){true, 0}
20 #define VEC_OK(value) (vector_result_t){false, value}
21
22 vector_t* vector_new();
23 void vector_resize(vector_t* vec, size_t size);
24 void vector_push_back(vector_t* vec, size_t element);
25 vector_result_t vector_pop_back(vector_t* vec);
26 vector_result_t vector_get(vector_t* vec, size_t index);
27 vector_result_t vector_erase_nth(vector_t* vec, size_t n);
28 void vector_erase_all(vector_t* vec);
29 void vector_shrink_fit(vector_t* original);
30 void vector_swap(vector_t* vec, size_t first, size_t second);
31 vector_t* vector_clone(vector_t* original);
32 void vector_insert(vector_t* vec, size_t index, size_t value);
33 void vector_destroy(vector_t* vec);
common.h
Основные определения ядра
vector_result
Definition: vector.h:14
vector
Definition: vector.h:7