Go to the source code of this file.
|
#define | new_mp_vector(mp, type, data) new_mp_vector(mp, sizeof(type), data) |
|
#define | free_mp_vector(mp, type, data) free_mp_vector(mp, sizeof(type), data) |
|
#define | mp_vector_add(mp, a, type, data) |
|
#define | mp_vector_at(a, type, index) ((type*)((a)->ptr + (index) * sizeof(type))) |
|
#define | mp_vector_set(a, type, index, data) *(type*)((a)->ptr + (index) * sizeof(type)) = (data) |
|
#define | mp_vector_pop(a, type) ((type*)mp_vector_pop(a, sizeof(type))) |
|
#define | mp_vector_rem(a, type, idx) mp_vector_rem(a, sizeof(type), idx) |
|
#define | mp_vector_rem2(a, type, data) |
|
#define | mp_vector_back(a, type) ((type*)((a)->ptr + (a->len-1) * sizeof(type))) |
|
|
static ANN void | mp_vector_resize (const MemPool mp, MP_Vector **ap, const uint32_t size, const uint32_t cap) |
|
ANN MP_Vector * | new_mp_vector (const MemPool mp, const uint32_t size, const uint32_t len) |
|
static ANN void | free_mp_vector (const MemPool mp, const uint32_t size, MP_Vector *a) |
|
static uint32_t | mp_vector_len (MP_Vector *a) |
|
static ANN void | mp_vector_rem (MP_Vector *const a, const uint32_t size, const uint32_t idx) |
|
static ANN m_bit * | mp_vector_pop (MP_Vector *const a, const uint32_t size) |
|
◆ free_mp_vector
#define free_mp_vector |
( |
| mp, |
|
|
| type, |
|
|
| data ) free_mp_vector(mp, sizeof(type), data) |
Definition at line 29 of file mp_vector.h.
29#define free_mp_vector(mp, type, data) \
30 free_mp_vector(mp, sizeof(type), data)
◆ mp_vector_add
#define mp_vector_add |
( |
| mp, |
|
|
| a, |
|
|
| type, |
|
|
| data ) |
Value: { \
if (++((*a))->len >= ((*a))->cap) \
mp_vector_resize(mp, (a), sizeof(type), (*(a))->cap * 2); \
*(type*)((*(a))->ptr + ((*a)->len - 1) * sizeof(type)) = data; }\
Definition at line 32 of file mp_vector.h.
32#define mp_vector_add(mp, a, type, data) { \
33 if (++((*a))->len >= ((*a))->cap) \
34 mp_vector_resize(mp, (a), sizeof(type), (*(a))->cap * 2); \
35 *(type*)((*(a))->ptr + ((*a)->len - 1) * sizeof(type)) = data; }\
36
◆ mp_vector_at
#define mp_vector_at |
( |
| a, |
|
|
| type, |
|
|
| index ) ((type*)((a)->ptr + (index) * sizeof(type))) |
Definition at line 37 of file mp_vector.h.
37#define mp_vector_at(a, type, index) \
38 ((type*)((a)->ptr + (index) * sizeof(type)))
◆ mp_vector_back
#define mp_vector_back |
( |
| a, |
|
|
| type ) ((type*)((a)->ptr + (a->len-1) * sizeof(type))) |
Definition at line 69 of file mp_vector.h.
69#define mp_vector_back(a, type) \
70 ((type*)((a)->ptr + (a->len-1) * sizeof(type)))
◆ mp_vector_pop
#define mp_vector_pop |
( |
| a, |
|
|
| type ) ((type*)mp_vector_pop(a, sizeof(type))) |
Definition at line 55 of file mp_vector.h.
55#define mp_vector_pop(a, type) \
56 ((type*)mp_vector_pop(a, sizeof(type)))
◆ mp_vector_rem
#define mp_vector_rem |
( |
| a, |
|
|
| type, |
|
|
| idx ) mp_vector_rem(a, sizeof(type), idx) |
Definition at line 58 of file mp_vector.h.
58#define mp_vector_rem(a, type, idx) \
59 mp_vector_rem(a, sizeof(type), idx)
◆ mp_vector_rem2
#define mp_vector_rem2 |
( |
| a, |
|
|
| type, |
|
|
| data ) |
Value: for(uint32_t i = 0; i < a->len; i++) { \
mp_vector_rem(a, type, i); \
break; \
} \
}
#define mp_vector_at(a, type, index)
Definition at line 61 of file mp_vector.h.
61#define mp_vector_rem2(a, type, data) \
62 for(uint32_t i = 0; i < a->len; i++) { \
63 if(data == mp_vector_at(a, type, i)) { \
64 mp_vector_rem(a, type, i); \
65 break; \
66 } \
67 }
◆ mp_vector_set
#define mp_vector_set |
( |
| a, |
|
|
| type, |
|
|
| index, |
|
|
| data ) *(type*)((a)->ptr + (index) * sizeof(type)) = (data) |
Definition at line 40 of file mp_vector.h.
40#define mp_vector_set(a, type, index, data) \
41 *(type*)((a)->ptr + (index) * sizeof(type)) = (data)
◆ new_mp_vector
#define new_mp_vector |
( |
| mp, |
|
|
| type, |
|
|
| data ) new_mp_vector(mp, sizeof(type), data) |
Definition at line 26 of file mp_vector.h.
26#define new_mp_vector(mp, type, data) \
27 new_mp_vector(mp, sizeof(type), data)
◆ MP_Vector
typedef struct MP_Vector MP_Vector |
◆ free_mp_vector()
Definition at line 18 of file mp_vector.h.
18 {
20}
#define mp_free2(p, sz, a)
◆ mp_vector_len()
static uint32_t mp_vector_len |
( |
MP_Vector * | a | ) |
|
|
inlinestatic |
◆ mp_vector_pop()
Definition at line 50 of file mp_vector.h.
50 {
51 m_bit *data = ((a)->ptr + (a->
len--) * size);
52 return data;
53}
◆ mp_vector_rem()
static ANN void mp_vector_rem |
( |
MP_Vector *const | a, |
|
|
const uint32_t | size, |
|
|
const uint32_t | idx ) |
|
inlinestatic |
Definition at line 43 of file mp_vector.h.
43 {
44 if (idx >= a->
len)
return;
45 if (idx < a->len - 1)
47 (a->
len - idx - 1) * size);
48}
◆ mp_vector_resize()
static ANN void mp_vector_resize |
( |
const MemPool | mp, |
|
|
MP_Vector ** | ap, |
|
|
const uint32_t | size, |
|
|
const uint32_t | cap ) |
|
inlinestatic |
Definition at line 10 of file mp_vector.h.
10 {
14}
struct MP_Vector MP_Vector
void * mp_realloc(MemPool mp, void *ptr, const m_uint curr, const m_uint next)
◆ new_mp_vector()
Definition at line 3 of file mp_vector.c.
3 {
5 while (cap < len) cap *= 2;
6 const size_t sz = cap * size;
10 return a;
11}
#define mp_malloc2(p, sz)