cvx
Loading...
Searching...
No Matches
core.h
Go to the documentation of this file.
1#ifndef CVX_CORE_H
2#define CVX_CORE_H
3
4#include <stdbool.h>
5#include <stddef.h>
6
7#include "flags.h"
8
9#define CVX__(A, B) A##B
10#define CVX_(A, B) CVX__(A, B)
11
12#define VTABLE(X) CVX_(X, _vtable)
13#define GLOBAL_VTABLE(SNAME, X, NAME) CVX_(CVX_(CVX_(cvx_vtables_, SNAME), X), NAME)
14
15#define CVX_VTAB_COMP(name, T) int (*name)(T, T)
16#define CVX_VTAB_COPY(name, T) T (*name)(T)
17#define CVX_VTAB_DROP(name, T) void (*name)(T)
18#define CVX_VTAB_HASH(name, T) size_t (*name)(T)
19#define CVX_VTAB_PRIO(name, T) int (*name)(T, T)
20
21#define CVX_VTAB_DEFINITION(T) \
22 CVX_VTAB_COMP(comp, T); \
23 CVX_VTAB_COPY(clone, T); \
24 CVX_VTAB_DROP(drop, T); \
25 CVX_VTAB_HASH(hash, T); \
26 CVX_VTAB_PRIO(prio, T);
27
28#ifndef CVX_ITER_TAG_MULT
29// Iterator tag equals to the user-provided tag times this value
30#define CVX_ITER_TAG_MULT 100
31#endif
32
33#ifndef CVX_BUFFER_GROWTH_RATE
34#define CVX_BUFFER_GROWTH_RATE 1.5
35#endif
36#ifndef CVX_BUFFER_MIN_SIZE
37#define CVX_BUFFER_MIN_SIZE 8
38#endif
39#if CVX_BUFFER_MIN_SIZE < 2
40#error "CVX_BUFFER_MIN_SIZE must be greater than 1"
41#endif
42
43typedef struct cvx_container
44{
45 int tag;
46 enum cvx_flags flag;
48
61
62#define CVX_CONTAINER_GUARDS(TAG, _col_, error_value) \
63 if (_col_->tag != TAG) \
64 { \
65 _col_->flag = CVX_FLAG_WRONG_TAG; \
66 return error_value; \
67 }
68
69#endif /* CVX_CORE_H */
cvx_flags
binary_heap.h
Definition binary_heap.h:78
cvx_heap_order
enum cvx_heap_order
Definition binary_heap.h:148
@ CVX_MAX_HEAP
Definition core.h:58
@ CVX_MIN_HEAP
Definition core.h:59
Definition binary_heap.h:135
int tag
Definition binary_heap.h:136
enum cvx_flags flag
Definition binary_heap.h:137