Imported the initial C files that make up a decent sorting network toolkit already.
[sort-networks.git] / src / sn_comparator.h
1 #ifndef SN_COMPARATOR_H
2 #define SN_COMPARATOR_H 1
3
4 struct sn_comparator_s
5 {
6   int min;
7   int max;
8 };
9 typedef struct sn_comparator_s sn_comparator_t;
10
11 #define SN_COMP_LEFT(c)  (((c)->min < (c)->max) ? (c)->min : (c)->max)
12 #define SN_COMP_RIGHT(c) (((c)->min > (c)->max) ? (c)->min : (c)->max)
13 #define SN_COMP_MIN(c) (c)->min
14 #define SN_COMP_MAX(c) (c)->max
15
16 sn_comparator_t *sn_comparator_create (int min, int max);
17 void sn_comparator_destroy (sn_comparator_t *c);
18 void sn_comparator_invert (sn_comparator_t *c);
19 void sn_comparator_swap (sn_comparator_t *c, int con0, int con1);
20
21 int sn_comparator_compare (const void *, const void *);
22
23 #endif /* SN_COMPARATOR_H */
24
25 /* vim: set shiftwidth=2 softtabstop=2 : */