-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
cvector_i.h
60 lines (47 loc) · 1.62 KB
/
cvector_i.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef CVECTORI_H
#define CVECTORI_H
#ifndef CVEC_SIZE_T
#include <stdlib.h>
#define CVEC_SIZE_T size_t
#endif
#ifndef CVEC_SZ
#define CVEC_SZ
typedef CVEC_SIZE_T cvec_sz;
#endif
#ifdef __cplusplus
extern "C" {
#endif
/** Data structure for int vector. */
typedef struct cvector_i
{
int* a; /**< Array. */
cvec_sz size; /**< Current size (amount you use when manipulating array directly). */
cvec_sz capacity; /**< Allocated size of array; always >= size. */
} cvector_i;
extern cvec_sz CVEC_I_START_SZ;
int cvec_i(cvector_i* vec, cvec_sz size, cvec_sz capacity);
int cvec_init_i(cvector_i* vec, int* vals, cvec_sz num);
cvector_i* cvec_i_heap(cvec_sz size, cvec_sz capacity);
cvector_i* cvec_init_i_heap(int* vals, cvec_sz num);
int cvec_copyc_i(void* dest, void* src);
int cvec_copy_i(cvector_i* dest, cvector_i* src);
int cvec_push_i(cvector_i* vec, int a);
int cvec_pop_i(cvector_i* vec);
int cvec_extend_i(cvector_i* vec, cvec_sz num);
int cvec_insert_i(cvector_i* vec, cvec_sz i, int a);
int cvec_insert_array_i(cvector_i* vec, cvec_sz i, int* a, cvec_sz num);
int cvec_replace_i(cvector_i* vec, cvec_sz i, int a);
void cvec_erase_i(cvector_i* vec, cvec_sz start, cvec_sz end);
int cvec_reserve_i(cvector_i* vec, cvec_sz size);
#define cvec_shrink_to_fit_i(vec) cvec_set_cap_i((vec), (vec)->size)
int cvec_set_cap_i(cvector_i* vec, cvec_sz size);
void cvec_set_val_sz_i(cvector_i* vec, int val);
void cvec_set_val_cap_i(cvector_i* vec, int val);
int* cvec_back_i(cvector_i* vec);
void cvec_clear_i(cvector_i* vec);
void cvec_free_i_heap(void* vec);
void cvec_free_i(void* vec);
#ifdef __cplusplus
}
#endif
#endif