-
Notifications
You must be signed in to change notification settings - Fork 0
/
comparator.h
39 lines (30 loc) · 1.12 KB
/
comparator.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
#ifndef COMPARATOR_H
#define COMPARATOR_H
typedef struct Comparator_methods {
int (*compare)(const void* data, const void* x, const void* y);
} Comparator_methods;
typedef struct Comparator {
void* data;
const Comparator_methods* methods;
} Comparator;
static inline int comparator_compare(Comparator comparator, const void* x, const void* y) {
return comparator.methods->compare(comparator.data, x, y);
}
extern const Comparator char_comparator;
extern const Comparator wchar_comparator;
extern const Comparator schar_comparator;
extern const Comparator short_comparator;
extern const Comparator int_comparator;
extern const Comparator long_comparator;
extern const Comparator llong_comparator;
extern const Comparator uchar_comparator;
extern const Comparator ushort_comparator;
extern const Comparator uint_comparator;
extern const Comparator ulong_comparator;
extern const Comparator ullong_comparator;
extern const Comparator float_comparator;
extern const Comparator double_comparator;
extern const Comparator ldouble_comparator;
extern const Comparator string_comparator;
extern const Comparator wstring_comparator;
#endif