language: C (gcc-4.7.2)
date: 561 days 0 hours ago
link:
visibility: public
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
 
#include "deque.h"
 
#ifndef DEQUE_TAG
#error "Must define DEQUE_TAG to use this header file"
#ifndef DEQUE_VALUE_TYPE
#error "Must define DEQUE_VALUE_TYPE to use this header file"
#endif
#else
 
/* possible to define DEQUE_WRAPPER and DEQUE_UNWRAPPER */
 
 
#define DEQUE_GEN_PASTE_(x,y) x ## y
#define DEQUE_GEN_PASTE(x,y) DEQUE_GEN_PASTE_(x,y)
#define DQTAG(suffix) DEQUE_GEN_PASTE(DEQUE_TAG,suffix)
 
#define DQVALUE DEQUE_VALUE_TYPE
 
#define DQREF DQTAG(_ref_t)
 
#ifdef DEQUE_WRAPPER
#define WRAP(x) DEQUE_WRAPPER(x)
#else
#define WRAP(x) x
#endif
 
#ifdef DEQUE_UNWRAPPER
#define UNWRAP(x) DEQUE_UNWRAPPER(x)
#else
#define UNWRAP(x) x
#endif
 
 
typedef struct {
    deque_t *dq;
} DQREF;
 
 
static inline DQREF DQTAG(_next) (DQREF ref) {
    return (DQREF){deque_next(ref.dq)};
}
 
static inline DQVALUE DQTAG(_value) (DQREF ref) {
    return WRAP(deque_value(ref.dq));
}
 
static inline void DQTAG(_prepend) (DQREF *ref, DQVALUE val) {
    deque_prepend(&ref->dq, UNWRAP(val));
}
 
static inline void DQTAG(_append) (DQREF *ref, DQVALUE val) {
    deque_append(&ref->dq, UNWRAP(val));
}
 
static inline DQVALUE DQTAG(_pop_front) (DQREF *ref) {
    return WRAP(deque_pop_front(&ref->dq));
}
 
static inline DQVALUE DQTAG(_pop_back) (DQREF *ref) {
    return WRAP(deque_pop_back(&ref->dq));
}
 
static inline bool DQTAG(_empty) (DQREF ref) {
    return deque_empty(ref.dq);
}
 
static inline void DQTAG(_free) (DQREF *ref) {
    deque_free(&ref->dq);
}
 
void DQTAG(_insert_sorted) (DQREF *ref, DQVALUE value,
                         void *ctx,
                         int (*cmp)(void *, void *, void *)) {
    deque_insert_sorted(&ref->dq, UNWRAP(value), ctx, cmp);
}
 
static inline void DQTAG(_merge) (DQREF *mq, DQREF *p, DQREF *q,
                 void *ctx, int (*cmp)(void *, void *, void *)) {
    deque_merge(&mq->dq, &p->dq, &q->dq, ctx, cmp);
}
 
static inline void DQTAG(_forward_each) (const DQREF ref, void (*f)(void *)) {
    deque_forward_each(ref.dq, f);
}
 
static inline void DQTAG(_forward_map) (DQREF ref, void *ctx, void *(*f)(void *, void *)) {
    deque_forward_map(ref.dq, ctx, f);
}
 
static inline DQREF DQTAG(_wrap_ref) (deque_t *dq) {
    return (DQREF){dq};
}
 
static inline deque_t *DQTAG(_unwrap_ref) (DQREF ref) {
    return ref.dq;
}
 
 
#undef DEQUE_VALUE_TYPE
#undef DQVALUE
#undef DEQUE_TAG
#undef TAG
#undef DEQUE_GEN_PASTE
#undef DQTAG
#undef DQREF
#undef WRAP
#undef UNWRAP
#undef DEQUE_WRAPPER
#undef DEQUE_UNWRAPPER
 
#endif
 
prog.c:2:19: error: deque.h: No such file or directory
prog.c:5:2: error: #error "Must define DEQUE_TAG to use this header file"
prog.c:7:2: error: #error "Must define DEQUE_VALUE_TYPE to use this header file"